Merge branch 'camera' of ssh://codereview.qt-project.org:29418/qt/qtmultimediakit

Conflicts:
	src/imports/multimedia/multimedia.cpp
	src/imports/multimedia/multimedia.pro

Change-Id: I9d4bc1aa65f89ac24dd12c1e2c21a02f49913e13
This commit is contained in:
Michael Goddard
2011-09-26 14:17:32 +10:00
16 changed files with 2323 additions and 964 deletions

View File

@@ -50,10 +50,13 @@
#include "qdeclarativevideooutput_p.h" #include "qdeclarativevideooutput_p.h"
#include "qdeclarativeradio_p.h" #include "qdeclarativeradio_p.h"
#include "qdeclarativebackgroundaudio_p.h" #include "qdeclarativebackgroundaudio_p.h"
#if 0
#include "qdeclarativecamera_p.h" #include "qdeclarativecamera_p.h"
#include "qdeclarativecamerapreviewprovider_p.h" #include "qdeclarativecamerapreviewprovider_p.h"
#endif #include "qdeclarativecameraexposure_p.h"
#include "qdeclarativecameraflash_p.h"
#include "qdeclarativecamerafocus_p.h"
#include "qdeclarativecameraimageprocessing_p.h"
QML_DECLARE_TYPE(QSoundEffect) QML_DECLARE_TYPE(QSoundEffect)
@@ -73,20 +76,24 @@ public:
qmlRegisterType<QDeclarativeVideoOutput>(uri, 4, 0, "VideoOutput"); qmlRegisterType<QDeclarativeVideoOutput>(uri, 4, 0, "VideoOutput");
qmlRegisterType<QDeclarativeRadio>(uri, 4, 0, "Radio"); qmlRegisterType<QDeclarativeRadio>(uri, 4, 0, "Radio");
qmlRegisterType<QDeclarativeBackgroundAudio>(uri, 4, 0, "BackgroundAudio"); qmlRegisterType<QDeclarativeBackgroundAudio>(uri, 4, 0, "BackgroundAudio");
/* Disabled until ported to scenegraph */
#if 0
qmlRegisterType<QDeclarativeCamera>(uri, 4, 0, "Camera"); qmlRegisterType<QDeclarativeCamera>(uri, 4, 0, "Camera");
#endif qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, 4, 0, "CameraCapture",
trUtf8("CameraCapture is only provided by Camera element"));
qmlRegisterUncreatableType<QDeclarativeCameraRecorder>(uri, 4, 0, "CameraRecorder",
trUtf8("CameraRecorder is only provided by Camera element"));
qmlRegisterUncreatableType<QDeclarativeCameraExposure>(uri, 4, 0, "CameraExposure",
trUtf8("CameraExposure is only provided by Camera element"));
qmlRegisterUncreatableType<QDeclarativeCameraFocus>(uri, 4, 0, "CameraFocus",
trUtf8("CameraFocus is only provided by Camera element"));
qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing>(uri, 4, 0, "CameraImageProcessing",
trUtf8("CameraImageProcessing is only provided by Camera element"));
qmlRegisterType<QDeclarativeMediaMetaData>(); qmlRegisterType<QDeclarativeMediaMetaData>();
} }
void initializeEngine(QDeclarativeEngine *engine, const char *uri) void initializeEngine(QDeclarativeEngine *engine, const char *uri)
{ {
Q_UNUSED(uri); Q_UNUSED(uri);
Q_UNUSED(engine);
#if 0
engine->addImageProvider("camera", new QDeclarativeCameraPreviewProvider); engine->addImageProvider("camera", new QDeclarativeCameraPreviewProvider);
#endif
} }
}; };

View File

@@ -17,7 +17,15 @@ HEADERS += \
qsgvideonode_i420.h \ qsgvideonode_i420.h \
qsgvideonode_rgb32.h \ qsgvideonode_rgb32.h \
qdeclarativeradio_p.h \ qdeclarativeradio_p.h \
qdeclarativebackgroundaudio_p.h qdeclarativebackgroundaudio_p.h \
qdeclarativecamera_p.h \
qdeclarativecameracapture_p.h \
qdeclarativecamerarecorder_p.h \
qdeclarativecameraexposure_p.h \
qdeclarativecameraflash_p.h \
qdeclarativecamerafocus_p.h \
qdeclarativecameraimageprocessing_p.h \
qdeclarativecamerapreviewprovider_p.h
SOURCES += \ SOURCES += \
multimedia.cpp \ multimedia.cpp \
@@ -28,18 +36,24 @@ SOURCES += \
qsgvideonode_i420.cpp \ qsgvideonode_i420.cpp \
qsgvideonode_rgb32.cpp \ qsgvideonode_rgb32.cpp \
qdeclarativeradio.cpp \ qdeclarativeradio.cpp \
qdeclarativebackgroundaudio.cpp qdeclarativebackgroundaudio.cpp \
qdeclarativecamera.cpp \
qdeclarativecameracapture.cpp \
qdeclarativecamerarecorder.cpp \
qdeclarativecameraexposure.cpp \
qdeclarativecameraflash.cpp \
qdeclarativecamerafocus.cpp \
qdeclarativecameraimageprocessing.cpp \
qdeclarativecamerapreviewprovider.cpp
disabled { disabled {
HEADERS += \ HEADERS += \
qdeclarativevideo_p.h \ qdeclarativevideo_p.h \
qdeclarativecamera_p.h \
qdeclarativecamerapreviewprovider_p.h
SOURCES += \ SOURCES += \
qdeclarativevideo.cpp \ qdeclarativevideo.cpp \
qdeclarativecamera.cpp \
qdeclarativecamerapreviewprovider.cpp
} }
qmldir.files += $$PWD/qmldir qmldir.files += $$PWD/qmldir

File diff suppressed because it is too large Load Diff

View File

@@ -53,57 +53,66 @@
// We mean it. // We mean it.
// //
#include "qgraphicsvideoitem.h"
#include <QtCore/qbasictimer.h> #include <QtCore/qbasictimer.h>
#include <QtQuick1/qdeclarativeitem.h> #include <QtCore/qdatetime.h>
#include <QtCore/QTime> #include <QtDeclarative/qdeclarative.h>
#include <QtDeclarative/qdeclarativeparserstatus.h>
#include <qcamera.h> #include <qcamera.h>
#include <qcameraimageprocessing.h> #include <qcameraimageprocessing.h>
#include <qcameraimagecapture.h> #include <qcameraimagecapture.h>
#include <qdeclarativecameracapture_p.h>
#include <qdeclarativecamerarecorder_p.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QTimerEvent; class QDeclarativeCameraExposure;
class QVideoSurfaceFormat; class QDeclarativeCameraFocus;
class QDeclarativeCameraFlash;
class QDeclarativeCameraImageProcessing;
class QDeclarativeCamera : public QObject, public QDeclarativeParserStatus
class QDeclarativeCamera : public QDeclarativeItem
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(QDeclarativeParserStatus)
Q_PROPERTY(CaptureMode captureMode READ captureMode WRITE setCaptureMode NOTIFY captureModeChanged)
Q_PROPERTY(State cameraState READ cameraState WRITE setCameraState NOTIFY cameraStateChanged) Q_PROPERTY(State cameraState READ cameraState WRITE setCameraState NOTIFY cameraStateChanged)
Q_PROPERTY(LockStatus lockStatus READ lockStatus NOTIFY lockStatusChanged) Q_PROPERTY(LockStatus lockStatus READ lockStatus NOTIFY lockStatusChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
Q_PROPERTY(QString capturedImagePath READ capturedImagePath NOTIFY imageSaved)
Q_PROPERTY(int iso READ isoSensitivity WRITE setManualIsoSensitivity NOTIFY isoSensitivityChanged)
Q_PROPERTY(qreal shutterSpeed READ shutterSpeed NOTIFY shutterSpeedChanged)
Q_PROPERTY(qreal aperture READ aperture NOTIFY apertureChanged)
Q_PROPERTY(qreal exposureCompensation READ exposureCompensation WRITE setExposureCompensation NOTIFY exposureCompensationChanged)
Q_PROPERTY(ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged)
Q_PROPERTY(int flashMode READ flashMode WRITE setFlashMode NOTIFY flashModeChanged)
Q_PROPERTY(WhiteBalanceMode whiteBalanceMode READ whiteBalanceMode WRITE setWhiteBalanceMode NOTIFY whiteBalanceModeChanged)
Q_PROPERTY(int manualWhiteBalance READ manualWhiteBalance WRITE setManualWhiteBalance NOTIFY manualWhiteBalanceChanged)
Q_PROPERTY(QSize captureResolution READ captureResolution WRITE setCaptureResolution NOTIFY captureResolutionChanged)
Q_PROPERTY(qreal opticalZoom READ opticalZoom WRITE setOpticalZoom NOTIFY opticalZoomChanged) Q_PROPERTY(qreal opticalZoom READ opticalZoom WRITE setOpticalZoom NOTIFY opticalZoomChanged)
Q_PROPERTY(qreal maximumOpticalZoom READ maximumOpticalZoom NOTIFY maximumOpticalZoomChanged) Q_PROPERTY(qreal maximumOpticalZoom READ maximumOpticalZoom NOTIFY maximumOpticalZoomChanged)
Q_PROPERTY(qreal digitalZoom READ digitalZoom WRITE setDigitalZoom NOTIFY digitalZoomChanged) Q_PROPERTY(qreal digitalZoom READ digitalZoom WRITE setDigitalZoom NOTIFY digitalZoomChanged)
Q_PROPERTY(qreal maximumDigitalZoom READ maximumDigitalZoom NOTIFY maximumDigitalZoomChanged) Q_PROPERTY(qreal maximumDigitalZoom READ maximumDigitalZoom NOTIFY maximumDigitalZoomChanged)
Q_PROPERTY(QObject *mediaObject READ mediaObject NOTIFY mediaObjectChanged SCRIPTABLE false DESIGNABLE false)
Q_PROPERTY(QDeclarativeCameraCapture* imageCapture READ imageCapture CONSTANT)
Q_PROPERTY(QDeclarativeCameraRecorder* videoRecorder READ videoRecorder CONSTANT)
Q_PROPERTY(QDeclarativeCameraExposure* exposure READ exposure CONSTANT)
Q_PROPERTY(QDeclarativeCameraFlash* flash READ flash CONSTANT)
Q_PROPERTY(QDeclarativeCameraFocus* focus READ focus CONSTANT)
Q_PROPERTY(QDeclarativeCameraImageProcessing* imageProcessing READ imageProcessing CONSTANT)
Q_ENUMS(CaptureMode)
Q_ENUMS(State) Q_ENUMS(State)
Q_ENUMS(LockStatus) Q_ENUMS(LockStatus)
Q_ENUMS(Error) Q_ENUMS(Error)
Q_ENUMS(FlashMode) Q_ENUMS(FlashMode)
Q_ENUMS(ExposureMode) Q_ENUMS(ExposureMode)
Q_ENUMS(WhiteBalanceMode)
Q_ENUMS(FocusMode)
Q_ENUMS(FocusPointMode)
Q_ENUMS(FocusAreaStatus)
public: public:
enum CaptureMode {
CaptureStillImage = QCamera::CaptureStillImage,
CaptureVideo = QCamera::CaptureVideo
};
enum State enum State
{ {
ActiveState = QCamera::ActiveState, ActiveState = QCamera::ActiveState,
@@ -128,49 +137,69 @@ public:
}; };
enum FlashMode { enum FlashMode {
FlashAuto = 0x1, FlashAuto = QCameraExposure::FlashAuto,
FlashOff = 0x2, FlashOff = QCameraExposure::FlashOff,
FlashOn = 0x4, FlashOn = QCameraExposure::FlashOn,
FlashRedEyeReduction = 0x8, FlashRedEyeReduction = QCameraExposure::FlashRedEyeReduction,
FlashFill = 0x10, FlashFill = QCameraExposure::FlashFill,
FlashTorch = 0x20, FlashTorch = QCameraExposure::FlashTorch,
FlashSlowSyncFrontCurtain = 0x40, FlashSlowSyncFrontCurtain = QCameraExposure::FlashSlowSyncFrontCurtain,
FlashSlowSyncRearCurtain = 0x80, FlashSlowSyncRearCurtain = QCameraExposure::FlashSlowSyncRearCurtain,
FlashManual = 0x100 FlashManual = QCameraExposure::FlashManual
}; };
enum ExposureMode { enum ExposureMode {
ExposureAuto = 0, ExposureAuto = QCameraExposure::ExposureAuto,
ExposureManual = 1, ExposureManual = QCameraExposure::ExposureManual,
ExposurePortrait = 2, ExposurePortrait = QCameraExposure::ExposurePortrait,
ExposureNight = 3, ExposureNight = QCameraExposure::ExposureNight,
ExposureBacklight = 4, ExposureBacklight = QCameraExposure::ExposureBacklight,
ExposureSpotlight = 5, ExposureSpotlight = QCameraExposure::ExposureSpotlight,
ExposureSports = 6, ExposureSports = QCameraExposure::ExposureSports,
ExposureSnow = 7, ExposureSnow = QCameraExposure::ExposureSnow,
ExposureBeach = 8, ExposureBeach = QCameraExposure::ExposureBeach,
ExposureLargeAperture = 9, ExposureLargeAperture = QCameraExposure::ExposureLargeAperture,
ExposureSmallAperture = 10, ExposureSmallAperture = QCameraExposure::ExposureSmallAperture,
ExposureModeVendor = 1000 ExposureModeVendor = QCameraExposure::ExposureModeVendor
}; };
enum WhiteBalanceMode { enum FocusMode {
WhiteBalanceAuto = 0, FocusManual = QCameraFocus::ManualFocus,
WhiteBalanceManual = 1, FocusHyperfocal = QCameraFocus::HyperfocalFocus,
WhiteBalanceSunlight = 2, FocusInfinity = QCameraFocus::InfinityFocus,
WhiteBalanceCloudy = 3, FocusAuto = QCameraFocus::AutoFocus,
WhiteBalanceShade = 4, FocusContinuous = QCameraFocus::ContinuousFocus,
WhiteBalanceTungsten = 5, FocusMacro = QCameraFocus::MacroFocus
WhiteBalanceFluorescent = 6, };
WhiteBalanceIncandescent = 7, Q_DECLARE_FLAGS(FocusModes, FocusMode)
WhiteBalanceFlash = 8,
WhiteBalanceSunset = 9, enum FocusPointMode {
WhiteBalanceVendor = 1000 FocusPointAuto = QCameraFocus::FocusPointAuto,
FocusPointCenter = QCameraFocus::FocusPointCenter,
FocusPointFaceDetection = QCameraFocus::FocusPointFaceDetection,
FocusPointCustom = QCameraFocus::FocusPointCustom
}; };
QDeclarativeCamera(QDeclarativeItem *parent = 0); enum FocusAreaStatus {
FocusAreaUnused = QCameraFocusZone::Unused,
FocusAreaSelected = QCameraFocusZone::Selected,
FocusAreaFocused = QCameraFocusZone::Focused
};
QDeclarativeCamera(QObject *parent = 0);
~QDeclarativeCamera(); ~QDeclarativeCamera();
QObject *mediaObject() { return m_camera; }
QDeclarativeCameraCapture *imageCapture() { return m_imageCapture; }
QDeclarativeCameraRecorder *videoRecorder() { return m_videoRecorder; }
QDeclarativeCameraExposure *exposure() { return m_exposure; }
QDeclarativeCameraFlash *flash() { return m_flash; }
QDeclarativeCameraFocus *focus() { return m_focus; }
QDeclarativeCameraImageProcessing *imageProcessing() { return m_imageProcessing; }
CaptureMode captureMode() const;
State cameraState() const; State cameraState() const;
Error error() const; Error error() const;
@@ -178,23 +207,6 @@ public:
LockStatus lockStatus() const; LockStatus lockStatus() const;
QImage capturedImagePreview() const;
QString capturedImagePath() const;
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
int flashMode() const;
ExposureMode exposureMode() const;
qreal exposureCompensation() const;
int isoSensitivity() const;
qreal shutterSpeed() const;
qreal aperture() const;
WhiteBalanceMode whiteBalanceMode() const;
int manualWhiteBalance() const;
QSize captureResolution() const;
qreal maximumOpticalZoom() const; qreal maximumOpticalZoom() const;
qreal maximumDigitalZoom() const; qreal maximumDigitalZoom() const;
@@ -202,6 +214,8 @@ public:
qreal digitalZoom() const; qreal digitalZoom() const;
public Q_SLOTS: public Q_SLOTS:
void setCaptureMode(CaptureMode mode);
void start(); void start();
void stop(); void stop();
@@ -210,18 +224,6 @@ public Q_SLOTS:
void searchAndLock(); void searchAndLock();
void unlock(); void unlock();
void captureImage();
void setFlashMode(int);
void setExposureMode(QDeclarativeCamera::ExposureMode);
void setExposureCompensation(qreal ev);
void setManualIsoSensitivity(int iso);
void setWhiteBalanceMode(QDeclarativeCamera::WhiteBalanceMode mode) const;
void setManualWhiteBalance(int colorTemp) const;
void setCaptureResolution(const QSize &size);
void setOpticalZoom(qreal); void setOpticalZoom(qreal);
void setDigitalZoom(qreal); void setDigitalZoom(qreal);
@@ -229,68 +231,39 @@ Q_SIGNALS:
void errorChanged(); void errorChanged();
void error(QDeclarativeCamera::Error error, const QString &errorString); void error(QDeclarativeCamera::Error error, const QString &errorString);
void captureModeChanged();
void cameraStateChanged(QDeclarativeCamera::State); void cameraStateChanged(QDeclarativeCamera::State);
void lockStatusChanged(); void lockStatusChanged();
void imageCaptured(const QString &preview);
void imageSaved(const QString &path);
void captureFailed(const QString &message);
void isoSensitivityChanged(int);
void apertureChanged(qreal);
void shutterSpeedChanged(qreal);
void exposureCompensationChanged(qreal);
void exposureModeChanged(QDeclarativeCamera::ExposureMode);
void flashModeChanged(int);
void whiteBalanceModeChanged(QDeclarativeCamera::WhiteBalanceMode) const;
void manualWhiteBalanceChanged(int) const;
void captureResolutionChanged(const QSize&);
void opticalZoomChanged(qreal); void opticalZoomChanged(qreal);
void digitalZoomChanged(qreal); void digitalZoomChanged(qreal);
void maximumOpticalZoomChanged(qreal); void maximumOpticalZoomChanged(qreal);
void maximumDigitalZoomChanged(qreal); void maximumDigitalZoomChanged(qreal);
protected: void mediaObjectChanged();
void geometryChanged(const QRectF &geometry, const QRectF &);
void keyPressEvent(QKeyEvent * event);
void keyReleaseEvent(QKeyEvent * event);
private Q_SLOTS: private Q_SLOTS:
void _q_updateState(QCamera::State); void _q_updateState(QCamera::State);
void _q_nativeSizeChanged(const QSizeF &size);
void _q_error(int, const QString &); void _q_error(int, const QString &);
void _q_imageCaptured(int, const QImage&);
void _q_imageSaved(int, const QString&); protected:
void _q_captureFailed(int, QCameraImageCapture::Error, const QString&); void classBegin();
void _q_updateFocusZones(); void componentComplete();
void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason);
void _q_updateImageSettings();
void _q_applyPendingState();
private: private:
Q_DISABLE_COPY(QDeclarativeCamera) Q_DISABLE_COPY(QDeclarativeCamera)
QCamera *m_camera; QCamera *m_camera;
QGraphicsVideoItem *m_viewfinderItem;
QCameraExposure *m_exposure; QDeclarativeCameraCapture *m_imageCapture;
QCameraFocus *m_focus; QDeclarativeCameraRecorder *m_videoRecorder;
QCameraImageCapture *m_capture; QDeclarativeCameraExposure *m_exposure;
QDeclarativeCameraFlash *m_flash;
QImage m_capturedImagePreview; QDeclarativeCameraFocus *m_focus;
QString m_capturedImagePath; QDeclarativeCameraImageProcessing *m_imageProcessing;
QList <QGraphicsItem*> m_focusZones;
QTime m_focusFailedTime;
QImageEncoderSettings m_imageSettings;
bool m_imageSettingsChanged;
State m_pendingState; State m_pendingState;
bool m_isStateSet; bool m_componentComplete;
bool m_isValid;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@@ -0,0 +1,233 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qdeclarativecamera_p.h"
#include "qdeclarativecameracapture_p.h"
#include "qdeclarativecamerapreviewprovider_p.h"
#include <QtCore/qurl.h>
QT_BEGIN_NAMESPACE
QDeclarativeCameraCapture::QDeclarativeCameraCapture(QCamera *camera, QObject *parent) :
QObject(parent),
m_camera(camera)
{
m_capture = new QCameraImageCapture(camera, this);
connect(m_capture, SIGNAL(readyForCaptureChanged(bool)), this, SIGNAL(readyForCaptureChanged(bool)));
connect(m_capture, SIGNAL(imageExposed(int)), this, SIGNAL(imageExposed()));
connect(m_capture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(_q_imageCaptured(int, QImage)));
connect(m_capture, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), this,
SLOT(_q_imageMetadataAvailable(int,QString,QVariant)));
connect(m_capture, SIGNAL(imageSaved(int,QString)), this, SLOT(_q_imageSaved(int, QString)));
connect(m_capture, SIGNAL(error(int,QCameraImageCapture::Error,QString)),
this, SLOT(_q_captureFailed(int,QCameraImageCapture::Error,QString)));
}
QDeclarativeCameraCapture::~QDeclarativeCameraCapture()
{
}
/*!
\qmlproperty string CameraCapture::ready
\property QDeclarativeCameraCapture::ready
Indicates camera is ready to capture photo.
*/
bool QDeclarativeCameraCapture::isReadyForCapture() const
{
return m_capture->isReadyForCapture();
}
/*!
\qmlmethod CameraCapture::capture()
\fn QDeclarativeCameraCapture::capture()
Start image capture. The \l onImageCaptured() and \l onImageSaved() signals will
be emitted when the capture is complete.
*/
void QDeclarativeCameraCapture::capture()
{
m_capture->capture();
}
/*!
\qmlmethod CameraCapture::captureToLocation()
\fn QDeclarativeCameraCapture::captureToLocation()
Start image capture to specified \a location. The \l onImageCaptured() and \l onImageSaved() signals will
be emitted when the capture is complete.
*/
void QDeclarativeCameraCapture::captureToLocation(const QString &location)
{
m_capture->capture(location);
}
/*!
\qmlmethod CameraCapture::cancelCapture()
\fn QDeclarativeCameraCapture::cancelCapture()
Cancel pendig image capture requests.
*/
void QDeclarativeCameraCapture::cancelCapture()
{
m_capture->cancelCapture();
}
/*!
\qmlproperty string CameraCapture::capturedImagePath
\property QDeclarativeCameraCapture::capturedImagePath
The path to the captured image.
*/
QString QDeclarativeCameraCapture::capturedImagePath() const
{
return m_capturedImagePath;
}
void QDeclarativeCameraCapture::_q_imageCaptured(int id, const QImage &preview)
{
QString previewId = QString("preview_%1").arg(id);
QDeclarativeCameraPreviewProvider::registerPreview(previewId, preview);
emit imageCaptured(QLatin1String("image://camera/")+previewId);
}
void QDeclarativeCameraCapture::_q_imageSaved(int id, const QString &fileName)
{
Q_UNUSED(id);
m_capturedImagePath = fileName;
emit imageSaved(fileName);
}
void QDeclarativeCameraCapture::_q_imageMetadataAvailable(int id, const QString &key, const QVariant &value)
{
Q_UNUSED(id);
emit imageMetadataAvailable(key, value);
}
void QDeclarativeCameraCapture::_q_captureFailed(int id, QCameraImageCapture::Error error, const QString &message)
{
Q_UNUSED(id);
Q_UNUSED(error);
qWarning() << "QCameraImageCapture error:" << message;
emit captureFailed(message);
}
/*!
\qmlproperty size CameraCapture::resolution
\property QDeclarativeCameraCapture::resolution
The resolution to capture the image at. If empty, the system will pick
a good size.
*/
QSize QDeclarativeCameraCapture::resolution()
{
return m_imageSettings.resolution();
}
void QDeclarativeCameraCapture::setResolution(const QSize &captureResolution)
{
if (captureResolution != resolution()) {
m_imageSettings.setResolution(captureResolution);
m_capture->setEncodingSettings(m_imageSettings);
emit resolutionChanged(captureResolution);
}
}
QCameraImageCapture::Error QDeclarativeCameraCapture::error() const
{
return m_capture->error();
}
/*!
\qmlproperty size CameraCapture::errorString
\property QDeclarativeCameraCapture::errorString
The last capture related error message.
*/
QString QDeclarativeCameraCapture::errorString() const
{
return m_capture->errorString();
}
void QDeclarativeCameraCapture::setMetadata(const QString &key, const QVariant &value)
{
Q_UNUSED(key);
Q_UNUSED(value);
//m_capture->setExtendedMetaData(key, value);
}
/*!
\qmlsignal CameraCapture::onCaptureFailed(message)
\fn QDeclarativeCameraCapture::captureFailed(const QString &message)
This handler is called when an error occurs during capture. A descriptive message is available in \a message.
*/
/*!
\qmlsignal CameraCapture::onImageCaptured(preview)
\fn QDeclarativeCameraCapture::imageCaptured(const QString &preview)
This handler is called when an image has been captured but not yet saved to the filesystem. The \a preview
parameter can be used as the URL supplied to an Image element.
\sa onImageSaved
*/
/*!
\qmlsignal CameraCapture::onImageSaved(path)
\fn QDeclarativeCameraCapture::imageSaved(const QString &path)
This handler is called after the image has been written to the filesystem. The \a path is a local file path, not a URL.
\sa onImageCaptured
*/
QT_END_NAMESPACE
#include "moc_qdeclarativecameracapture_p.cpp"

View File

@@ -0,0 +1,126 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QDECLARATIVECAMERACAPTURE_H
#define QDECLARATIVECAMERACAPTURE_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <qcamera.h>
#include <qcameraimagecapture.h>
#include <qmediaencodersettings.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QDeclarativeCamera;
class QDeclarativeCameraCapture : public QObject
{
Q_OBJECT
Q_PROPERTY(bool ready READ isReadyForCapture NOTIFY readyForCaptureChanged)
Q_PROPERTY(QString capturedImagePath READ capturedImagePath NOTIFY imageSaved)
Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY captureFailed)
public:
~QDeclarativeCameraCapture();
bool isReadyForCapture() const;
QSize resolution();
QString capturedImagePath() const;
QCameraImageCapture::Error error() const;
QString errorString() const;
public Q_SLOTS:
void capture();
void captureToLocation(const QString &location);
void cancelCapture();
void setResolution(const QSize &resolution);
void setMetadata(const QString &key, const QVariant &value);
Q_SIGNALS:
void readyForCaptureChanged(bool);
void imageExposed();
void imageCaptured(const QString &preview);
void imageMetadataAvailable(const QString &key, const QVariant &value);
void imageSaved(const QString &path);
void captureFailed(const QString &message);
void resolutionChanged(const QSize &);
private slots:
void _q_imageCaptured(int, const QImage&);
void _q_imageSaved(int, const QString&);
void _q_imageMetadataAvailable(int, const QString &, const QVariant &);
void _q_captureFailed(int, QCameraImageCapture::Error, const QString&);
private:
friend class QDeclarativeCamera;
QDeclarativeCameraCapture(QCamera *camera, QObject *parent = 0);
QCamera *m_camera;
QCameraImageCapture *m_capture;
QImageEncoderSettings m_imageSettings;
QString m_capturedImagePath;
};
QT_END_NAMESPACE
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraCapture))
QT_END_HEADER
#endif

View File

@@ -0,0 +1,260 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qdeclarativecamera_p.h"
#include "qdeclarativecameraexposure_p.h"
QT_BEGIN_NAMESPACE
/*!
\qmlclass CameraExposure QDeclarativeCameraExposure
\since 4.0
\brief The CameraExposure element provides interface for exposure related camera settings.
\ingroup qml-multimedia
This element is part of the \bold{Qt.multimediakit 4.0} module.
It should not be constructed separately but provided by Camera.exposure.
\qml
import QtQuick 2.0
import Qt.multimediakit 4.0
Camera {
id: camera
exposure.exposureCompensation: -1.0
exposure.exposureMode: Camera.ExposurePortrait
}
\endqml
*/
/*!
\class QDeclarativeCameraExposure
\brief The CameraExposure element provides interface for exposure related camera settings.
*/
/*!
Construct a declarative camera exposure object using \a parent object.
*/
QDeclarativeCameraExposure::QDeclarativeCameraExposure(QCamera *camera, QObject *parent) :
QObject(parent)
{
m_exposure = camera->exposure();
connect(m_exposure, SIGNAL(isoSensitivityChanged(int)), this, SIGNAL(isoSensitivityChanged(int)));
connect(m_exposure, SIGNAL(apertureChanged(qreal)), this, SIGNAL(apertureChanged(qreal)));
connect(m_exposure, SIGNAL(shutterSpeedChanged(qreal)), this, SIGNAL(shutterSpeedChanged(qreal)));
connect(m_exposure, SIGNAL(exposureCompensationChanged(qreal)), this, SIGNAL(exposureCompensationChanged(qreal)));
}
QDeclarativeCameraExposure::~QDeclarativeCameraExposure()
{
}
/*!
\qmlproperty real CameraExposure::exposureCompensation
\property QDeclarativeCameraExposure::exposureCompensation
Adjustment for the automatically calculated exposure. The value is
in EV units.
*/
qreal QDeclarativeCameraExposure::exposureCompensation() const
{
return m_exposure->exposureCompensation();
}
void QDeclarativeCameraExposure::setExposureCompensation(qreal ev)
{
m_exposure->setExposureCompensation(ev);
}
/*!
\qmlproperty real CameraExposure::isoSensitivity
\property QDeclarativeCameraExposure::iso
The sensor's ISO sensitivity.
*/
int QDeclarativeCameraExposure::isoSensitivity() const
{
return m_exposure->isoSensitivity();
}
/*!
\qmlproperty real CameraExposure::shutterSpeed
\property QDeclarativeCameraExposure::shutterSpeed
The camera's shutter speed, in seconds.
*/
qreal QDeclarativeCameraExposure::shutterSpeed() const
{
return m_exposure->shutterSpeed();
}
/*!
\qmlproperty real CameraExposure::aperture
\property QDeclarativeCameraExposure::aperture
The lens aperture as an F number (the ratio of the focal length to effective aperture diameter).
*/
qreal QDeclarativeCameraExposure::aperture() const
{
return m_exposure->aperture();
}
int QDeclarativeCameraExposure::manualIsoSensitivity() const
{
return m_manualIso;
}
void QDeclarativeCameraExposure::setManualIsoSensitivity(int iso)
{
m_manualIso = iso;
if (iso > 0)
m_exposure->setManualIsoSensitivity(iso);
else
m_exposure->setAutoIsoSensitivity();
emit manualIsoSensitivityChanged(iso);
}
qreal QDeclarativeCameraExposure::manualShutterSpeed() const
{
return m_manualShutterSpeed;
}
void QDeclarativeCameraExposure::setManualShutterSpeed(qreal speed)
{
m_manualShutterSpeed = speed;
if (speed > 0)
m_exposure->setManualShutterSpeed(speed);
else
m_exposure->setAutoShutterSpeed();
emit manualShutterSpeedChanged(speed);
}
qreal QDeclarativeCameraExposure::manualAperture() const
{
return m_manualAperture;
}
void QDeclarativeCameraExposure::setManualAperture(qreal aperture)
{
m_manualAperture = aperture;
if (aperture > 0)
m_exposure->setManualAperture(aperture);
else
m_exposure->setAutoAperture();
emit manualApertureChanged(aperture);
}
/*!
Turn on auto aperture. The manual aperture value is reset to -1.0
*/
void QDeclarativeCameraExposure::setAutoAperture()
{
setManualAperture(-1.0);
}
/*!
Turn on auto shutter speed. The manual shutter speed value is reset to -1.0
*/
void QDeclarativeCameraExposure::setAutoShutterSpeed()
{
setManualShutterSpeed(-1.0);
}
/*!
Turn on auto ISO sensitivity. The manual ISO value is reset to -1.
*/
void QDeclarativeCameraExposure::setAutoIsoSensitivity()
{
setManualIsoSensitivity(-1);
}
/*!
\qmlproperty enumeration CameraExposure::exposureMode
\property QDeclarativeCameraExposure::exposureMode
\table
\header \o Value \o Description
\row \o Camera.ExposureManual \o Manual mode.
\row \o Camera.ExposureAuto \o Automatic mode.
\row \o Camera.ExposureNight \o Night mode.
\row \o Camera.ExposureBacklight \o Backlight exposure mode.
\row \o Camera.ExposureSpotlight \o Spotlight exposure mode.
\row \o Camera.ExposureSports \o Spots exposure mode.
\row \o Camera.ExposureSnow \o Snow exposure mode.
\row \o Camera.ExposureBeach \o Beach exposure mode.
\row \o Camera.ExposureLargeAperture \o Use larger aperture with small depth of field.
\row \o Camera.ExposureSmallAperture \o Use smaller aperture.
\row \o Camera.ExposurePortrait \o Portrait exposure mode.
\row \o Camera.ExposureModeVendor \o The base value for device specific exposure modes.
\endtable
*/
QDeclarativeCamera::ExposureMode QDeclarativeCameraExposure::exposureMode() const
{
return QDeclarativeCamera::ExposureMode(m_exposure->exposureMode());
}
void QDeclarativeCameraExposure::setExposureMode(QDeclarativeCamera::ExposureMode mode)
{
if (exposureMode() != mode) {
m_exposure->setExposureMode(QCameraExposure::ExposureMode(mode));
emit exposureModeChanged(exposureMode());
}
}
/*!
\qmlsignal CameraExposure::exposureModeChanged(CameraExposure::ExposureMode)
\fn void QDeclarativeCameraExposure::exposureModeChanged(QDeclarativeCamera::ExposureMode)
*/
QT_END_NAMESPACE
#include "moc_qdeclarativecameraexposure_p.cpp"

View File

@@ -0,0 +1,135 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QDECLARATIVECAMERAEXPOSURE_H
#define QDECLARATIVECAMERAEXPOSURE_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <qcamera.h>
#include <qcameraexposure.h>
#include <qdeclarativecamera_p.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QDeclarativeCamera;
class QDeclarativeCameraExposure : public QObject
{
Q_OBJECT
Q_PROPERTY(qreal exposureCompensation READ exposureCompensation WRITE setExposureCompensation NOTIFY exposureCompensationChanged)
Q_PROPERTY(int iso READ isoSensitivity NOTIFY isoSensitivityChanged)
Q_PROPERTY(qreal shutterSpeed READ shutterSpeed NOTIFY shutterSpeedChanged)
Q_PROPERTY(qreal aperture READ aperture NOTIFY apertureChanged)
Q_PROPERTY(qreal manualShutterSpeed READ manualShutterSpeed WRITE setManualShutterSpeed NOTIFY manualShutterSpeedChanged)
Q_PROPERTY(qreal manualAperture READ manualAperture WRITE setManualAperture NOTIFY manualApertureChanged)
Q_PROPERTY(qreal manualIso READ manualIsoSensitivity WRITE setManualIsoSensitivity NOTIFY manualIsoSensitivityChanged)
Q_PROPERTY(QDeclarativeCamera::ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged)
public:
~QDeclarativeCameraExposure();
QDeclarativeCamera::ExposureMode exposureMode() const;
qreal exposureCompensation() const;
int isoSensitivity() const;
qreal shutterSpeed() const;
qreal aperture() const;
int manualIsoSensitivity() const;
qreal manualShutterSpeed() const;
qreal manualAperture() const;
public Q_SLOTS:
void setExposureMode(QDeclarativeCamera::ExposureMode);
void setExposureCompensation(qreal ev);
void setManualAperture(qreal);
void setManualShutterSpeed(qreal);
void setManualIsoSensitivity(int iso);
void setAutoAperture();
void setAutoShutterSpeed();
void setAutoIsoSensitivity();
Q_SIGNALS:
void isoSensitivityChanged(int);
void apertureChanged(qreal);
void shutterSpeedChanged(qreal);
void manualIsoSensitivityChanged(int);
void manualApertureChanged(qreal);
void manualShutterSpeedChanged(qreal);
void exposureCompensationChanged(qreal);
void exposureModeChanged(QDeclarativeCamera::ExposureMode);
private:
friend class QDeclarativeCamera;
QDeclarativeCameraExposure(QCamera *camera, QObject *parent = 0);
QCameraExposure *m_exposure;
int m_manualIso;
qreal m_manualAperture;
qreal m_manualShutterSpeed;
};
QT_END_NAMESPACE
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraExposure))
QT_END_HEADER
#endif

View File

@@ -0,0 +1,148 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qdeclarativecamera_p.h"
#include "qdeclarativecameraflash_p.h"
QT_BEGIN_NAMESPACE
/*!
\qmlclass CameraFlash QDeclarativeCameraFlash
\since 4.0
\brief The CameraFlash element provides interface for flash related camera settings.
\ingroup qml-multimedia
This element is part of the \bold{Qt.multimediakit 4.0} module.
It should not be constructed separately but provided by Camera.flash.
\qml
import QtQuick 2.0
import Qt.multimediakit 4.0
Camera {
id: camera
exposure.exposureCompensation: -1.0
flash.mode: Camera.FlashRedEyeReduction
}
\endqml
*/
/*!
\class QDeclarativeCameraFlash
\internal
\brief The CameraFlash element provides interface for flash related camera settings.
*/
/*!
Construct a declarative camera flash object using \a parent object.
*/
QDeclarativeCameraFlash::QDeclarativeCameraFlash(QCamera *camera, QObject *parent) :
QObject(parent)
{
m_exposure = camera->exposure();
connect(m_exposure, SIGNAL(flashReady(bool)), this, SIGNAL(flashReady(bool)));
}
QDeclarativeCameraFlash::~QDeclarativeCameraFlash()
{
}
/*!
\qmlproperty bool QDeclarativeCameraFlash::ready
\property bool QDeclarativeCameraFlash::ready
Indicates flash is charged.
*/
bool QDeclarativeCameraFlash::isFlashReady() const
{
return m_exposure->isFlashReady();
}
/*!
\qmlproperty enumeration CameraExposure::flashMode
\property QDeclarativeCameraFlash::flashMode
\table
\header \o Value \o Description
\row \o Camera.FlashOff \o Flash is Off.
\row \o Camera.FlashOn \o Flash is On.
\row \o Camera.FlashAuto \o Automatic flash.
\row \o Camera.FlashRedEyeReduction \o Red eye reduction flash.
\row \o Camera.FlashFill \o Use flash to fillin shadows.
\row \o Camera.FlashTorch \o Constant light source, useful for focusing and video capture.
\row \o Camera.FlashSlowSyncFrontCurtain
\o Use the flash in conjunction with a slow shutter speed.
This mode allows better exposure of distant objects and/or motion blur effect.
\row \o Camera.FlashSlowSyncRearCurtain
\o The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
\row \o Camera.FlashManual \o Flash power is manually set.
\endtable
*/
int QDeclarativeCameraFlash::flashMode() const
{
return m_exposure->flashMode();
}
void QDeclarativeCameraFlash::setFlashMode(int mode)
{
if (m_exposure->flashMode() != mode) {
m_exposure->setFlashMode(QCameraExposure::FlashModes(mode));
emit flashModeChanged(mode);
}
}
/*!
\qmlsignal CameraExposure::flashModeChanged(int)
\fn void QDeclarativeCameraFlash::flashModeChanged(int)
*/
/*!
\qmlsignal CameraExposure::flashReady(bool)
\fn void QDeclarativeCameraFlash::flashReady(bool)
*/
QT_END_NAMESPACE
#include "moc_qdeclarativecameraflash_p.cpp"

View File

@@ -0,0 +1,96 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QDECLARATIVECAMERAFLASH_H
#define QDECLARATIVECAMERAFLASH_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <qcamera.h>
#include <qcameraexposure.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QDeclarativeCamera;
class QDeclarativeCameraFlash : public QObject
{
Q_OBJECT
Q_PROPERTY(bool ready READ isFlashReady NOTIFY flashReady)
Q_PROPERTY(int mode READ flashMode WRITE setFlashMode NOTIFY flashModeChanged)
public:
~QDeclarativeCameraFlash();
int flashMode() const;
bool isFlashReady() const;
public Q_SLOTS:
void setFlashMode(int);
Q_SIGNALS:
void flashReady(bool status);
void flashModeChanged(int);
private:
friend class QDeclarativeCamera;
QDeclarativeCameraFlash(QCamera *camera, QObject *parent = 0);
QCameraExposure *m_exposure;
};
QT_END_NAMESPACE
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraFlash))
QT_END_HEADER
#endif

View File

@@ -0,0 +1,259 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qdeclarativecamera_p.h"
#include "qdeclarativecamerafocus_p.h"
QT_BEGIN_NAMESPACE
/*!
\qmlclass CameraFocus QDeclarativeCameraFocus
\since 4.0
\brief The CameraFocus element provides interface for focus related camera settings.
\ingroup qml-multimedia
This element is part of the \bold{Qt.multimediakit 4.0} module.
It should not be constructed separately but provided by Camera.focus.
\qml
import QtQuick 2.0
import Qt.multimediakit 4.0
Camera {
id: camera
focus {
focusMode: Camera.FocusMacro
focusPointMode: Camera.FocusPointCustom
customFocusPoint: Qt.point(0.2, 0.2) //focus to top-left corner
}
}
\endqml
*/
/*!
\class QDeclarativeCameraFocus
\brief The CameraFocus element provides interface for focus related camera settings.
*/
/*!
Construct a declarative camera focus object using \a parent object.
*/
QDeclarativeCameraFocus::QDeclarativeCameraFocus(QCamera *camera, QObject *parent) :
QObject(parent)
{
m_focus = camera->focus();
m_focusZones = new FocusZonesModel(this);
updateFocusZones();
connect(m_focus, SIGNAL(focusZonesChanged()), SLOT(updateFocusZones()));
}
QDeclarativeCameraFocus::~QDeclarativeCameraFocus()
{
}
/*!
\qmlproperty Camera::FocusModes CameraFocus::focusMode
\property QDeclarativeCameraFocus::focusMode
The current camera focus mode.
It's possible to combine multiple Camera::FocusMode values,
for example Camera.FocusMacro + Camera.FocusContinuous.
*/
QDeclarativeCamera::FocusModes QDeclarativeCameraFocus::focusMode() const
{
return QDeclarativeCamera::FocusModes(m_focus->focusMode());
}
bool QDeclarativeCameraFocus::isFocusModeSupported(QDeclarativeCamera::FocusModes mode) const
{
return m_focus->isFocusModeSupported(QCameraFocus::FocusMode(int(mode)));
}
void QDeclarativeCameraFocus::setFocusMode(QDeclarativeCamera::FocusModes mode)
{
m_focus->setFocusMode(QCameraFocus::FocusMode(int(mode)));
}
/*!
\qmlproperty CameraFocus::FocusPointMode CameraFocus::focusPointMode
\property QDeclarativeCameraFocus::focusPointMode
The current camera focus point mode.
*/
QDeclarativeCamera::FocusPointMode QDeclarativeCameraFocus::focusPointMode() const
{
return QDeclarativeCamera::FocusPointMode(m_focus->focusPointMode());
}
void QDeclarativeCameraFocus::setFocusPointMode(QDeclarativeCamera::FocusPointMode mode)
{
if (mode != focusPointMode()) {
m_focus->setFocusPointMode(QCameraFocus::FocusPointMode(mode));
emit focusPointModeChanged(focusPointMode());
}
}
bool QDeclarativeCameraFocus::isFocusPointModeSupported(QDeclarativeCamera::FocusPointMode mode) const
{
return m_focus->isFocusPointModeSupported(QCameraFocus::FocusPointMode(mode));
}
/*!
\qmlproperty QPointF CameraFocus::customFocusPoint
\property QDeclarativeCameraFocus::customFocusPoint
Position of custom focus point, in relative frame coordinates:
QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center.
Custom focus point is used only in FocusPointCustom focus mode.
*/
QPointF QDeclarativeCameraFocus::customFocusPoint() const
{
return m_focus->customFocusPoint();
}
void QDeclarativeCameraFocus::setCustomFocusPoint(const QPointF &point)
{
if (point != customFocusPoint()) {
m_focus->setCustomFocusPoint(point);
emit customFocusPointChanged(customFocusPoint());
}
}
/*!
\qmlproperty QPointF CameraFocus::focusZones
\property QDeclarativeCameraFocus::focusZones
List of current camera focus zones,
each including area specified in the same coordinates as \l customFocusPoint
and zone status.
\qml
VideoOutput {
id: viewfinder
source: camera
//display focus areas on camera viewfinder:
Repeater {
model: camera.focus.focusZones
Rectangle {
border {
width: 2
color: status == CameraFocus.Focused ? "green" : "white"
}
color: "transparent"
x: area.x * viewfinder.width
y: area.y * viewfinder.height
width: area.width * viewfinder.width
height: area.height * viewfinder.height
}
}
}
\endqml
*/
QAbstractListModel *QDeclarativeCameraFocus::focusZones() const
{
return m_focusZones;
}
/*! \internal */
void QDeclarativeCameraFocus::updateFocusZones()
{
m_focusZones->setFocusZones(m_focus->focusZones());
}
FocusZonesModel::FocusZonesModel(QObject *parent)
:QAbstractListModel(parent)
{
QHash<int, QByteArray> roles;
roles[StatusRole] = "status";
roles[AreaRole] = "area";
setRoleNames(roles);
}
int FocusZonesModel::rowCount(const QModelIndex &parent) const
{
if (parent == QModelIndex())
return m_focusZones.count();
return 0;
}
QVariant FocusZonesModel::data(const QModelIndex &index, int role) const
{
if (index.row() < 0 || index.row() > m_focusZones.count())
return QVariant();
QCameraFocusZone zone = m_focusZones.value(index.row());
if (role == StatusRole)
return zone.status();
if (role == AreaRole)
return zone.area();
return QVariant();
}
void FocusZonesModel::setFocusZones(const QCameraFocusZoneList &zones)
{
beginResetModel();
m_focusZones = zones;
endResetModel();
}
QT_END_NAMESPACE
#include "moc_qdeclarativecamerafocus_p.cpp"

View File

@@ -0,0 +1,136 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QDECLARATIVECAMERAFOCUS_H
#define QDECLARATIVECAMERAFOCUS_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qabstractitemmodel.h>
#include <qcamera.h>
#include <qcamerafocus.h>
#include "qdeclarativecamera_p.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class FocusZonesModel;
class QDeclarativeCamera;
class QDeclarativeCameraFocus : public QObject
{
Q_OBJECT
Q_PROPERTY(QDeclarativeCamera::FocusModes focusMode READ focusMode WRITE setFocusMode NOTIFY focusModeChanged)
Q_PROPERTY(QDeclarativeCamera::FocusPointMode focusPointMode READ focusPointMode WRITE setFocusPointMode NOTIFY focusPointModeChanged)
Q_PROPERTY(QPointF customFocusPoint READ customFocusPoint WRITE setCustomFocusPoint NOTIFY customFocusPointChanged)
Q_PROPERTY(QObject *focusZones READ focusZones CONSTANT)
public:
~QDeclarativeCameraFocus();
QDeclarativeCamera::FocusModes focusMode() const;
QDeclarativeCamera::FocusPointMode focusPointMode() const;
QPointF customFocusPoint() const;
QAbstractListModel *focusZones() const;
Q_INVOKABLE bool isFocusModeSupported(QDeclarativeCamera::FocusModes mode) const;
Q_INVOKABLE bool isFocusPointModeSupported(QDeclarativeCamera::FocusPointMode) const;
public Q_SLOTS:
void setFocusMode(QDeclarativeCamera::FocusModes);
void setFocusPointMode(QDeclarativeCamera::FocusPointMode mode);
void setCustomFocusPoint(const QPointF &point);
Q_SIGNALS:
void focusModeChanged(QDeclarativeCamera::FocusModes);
void focusPointModeChanged(QDeclarativeCamera::FocusPointMode);
void customFocusPointChanged(const QPointF &);
private Q_SLOTS:
void updateFocusZones();
private:
friend class QDeclarativeCamera;
QDeclarativeCameraFocus(QCamera *camera, QObject *parent = 0);
QCameraFocus *m_focus;
FocusZonesModel *m_focusZones;
};
class FocusZonesModel : public QAbstractListModel
{
Q_OBJECT
public:
enum FocusZoneRoles {
StatusRole = Qt::UserRole + 1,
AreaRole
};
FocusZonesModel(QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
public slots:
void setFocusZones(const QCameraFocusZoneList &zones);
private:
QCameraFocusZoneList m_focusZones;
};
QT_END_NAMESPACE
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraFocus))
QT_END_HEADER
#endif

View File

@@ -0,0 +1,204 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qdeclarativecamera_p.h"
#include "qdeclarativecameraimageprocessing_p.h"
QT_BEGIN_NAMESPACE
QDeclarativeCameraImageProcessing::QDeclarativeCameraImageProcessing(QCamera *camera, QObject *parent) :
QObject(parent)
{
m_imageProcessing = camera->imageProcessing();
}
QDeclarativeCameraImageProcessing::~QDeclarativeCameraImageProcessing()
{
}
/*!
\qmlproperty enumeration CameraImageProcessing::whiteBalanceMode
\table
\header \o Value \o Description
\row \o WhiteBalanceManual \o Manual white balance. In this mode the manual white balance property value is used.
\row \o WhiteBalanceAuto \o Auto white balance mode.
\row \o WhiteBalanceSunlight \o Sunlight white balance mode.
\row \o WhiteBalanceCloudy \o Cloudy white balance mode.
\row \o WhiteBalanceShade \o Shade white balance mode.
\row \o WhiteBalanceTungsten \o Tungsten white balance mode.
\row \o WhiteBalanceFluorescent \o Fluorescent white balance mode.
\row \o WhiteBalanceFlash \o Flash white balance mode.
\row \o WhiteBalanceSunset \o Sunset white balance mode.
\row \o WhiteBalanceVendor \o Vendor defined white balance mode.
\endtable
\sa manualWhiteBalance
*/
/*!
\property QDeclarativeCameraImageProcessing::whiteBalanceMode
\sa WhiteBalanceMode
*/
QDeclarativeCameraImageProcessing::WhiteBalanceMode QDeclarativeCameraImageProcessing::whiteBalanceMode() const
{
return WhiteBalanceMode(m_imageProcessing->whiteBalanceMode());
}
void QDeclarativeCameraImageProcessing::setWhiteBalanceMode(QDeclarativeCameraImageProcessing::WhiteBalanceMode mode) const
{
if (whiteBalanceMode() != mode) {
m_imageProcessing->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode(mode));
emit whiteBalanceModeChanged(whiteBalanceMode());
}
}
/*!
\qmlproperty int CameraImageProcessing::manualWhiteBalance
The color temperature used when in manual white balance mode (WhiteBalanceManual).
\sa whiteBalanceMode
*/
int QDeclarativeCameraImageProcessing::manualWhiteBalance() const
{
return m_imageProcessing->manualWhiteBalance();
}
void QDeclarativeCameraImageProcessing::setManualWhiteBalance(int colorTemp) const
{
if (manualWhiteBalance() != colorTemp) {
m_imageProcessing->setManualWhiteBalance(colorTemp);
emit manualWhiteBalanceChanged(manualWhiteBalance());
}
}
/*!
\qmlproperty int CameraImageProcessing::contrast
Image contrast.
Valid contrast values range between -100 and 100, the default is 0.
*/
int QDeclarativeCameraImageProcessing::contrast() const
{
return m_imageProcessing->contrast();
}
void QDeclarativeCameraImageProcessing::setContrast(int value)
{
if (value != contrast()) {
m_imageProcessing->setContrast(value);
emit contrastChanged(contrast());
}
}
/*!
\qmlproperty int CameraImageProcessing::saturation
Image saturation.
Valid saturation values range between -100 and 100, the default is 0.
*/
int QDeclarativeCameraImageProcessing::saturation() const
{
return m_imageProcessing->saturation();
}
void QDeclarativeCameraImageProcessing::setSaturation(int value)
{
if (value != saturation()) {
m_imageProcessing->setSaturation(value);
emit saturationChanged(saturation());
}
}
/*!
\qmlproperty int CameraImageProcessing::sharpeningLevel
Level of sharpening applied to image.
Valid sharpening level values range between -1 for default sharpening level,
0 for sharpening disabled and 100 for maximum sharpening applied.
*/
int QDeclarativeCameraImageProcessing::sharpeningLevel() const
{
return m_imageProcessing->sharpeningLevel();
}
void QDeclarativeCameraImageProcessing::setSharpeningLevel(int value)
{
if (value != sharpeningLevel()) {
m_imageProcessing->setSharpeningLevel(value);
emit sharpeningLevelChanged(sharpeningLevel());
}
}
/*!
\qmlproperty int CameraImageProcessing::denoisingLevel
Level of denoising applied to image.
Valid denoising level values range between -1 for default denoising level,
0 for denoising disabled and 100 for maximum denoising applied.
*/
int QDeclarativeCameraImageProcessing::denoisingLevel() const
{
return m_imageProcessing->denoisingLevel();
}
void QDeclarativeCameraImageProcessing::setDenoisingLevel(int value)
{
if (value != denoisingLevel()) {
m_imageProcessing->setDenoisingLevel(value);
emit denoisingLevelChanged(denoisingLevel());
}
}
/*!
\qmlsignal Camera::whiteBalanceModeChanged(Camera::WhiteBalanceMode)
*/
/*!
\qmlsignal Camera::manualWhiteBalanceChanged(int)
*/
QT_END_NAMESPACE
#include "moc_qdeclarativecameraimageprocessing_p.cpp"

View File

@@ -0,0 +1,132 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QDECLARATIVECAMERAIMAGEPROCESSING_H
#define QDECLARATIVECAMERAIMAGEPROCESSING_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <qcamera.h>
#include <qcameraimageprocessing.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QDeclarativeCamera;
class QDeclarativeCameraImageProcessing : public QObject
{
Q_OBJECT
Q_ENUMS(WhiteBalanceMode)
Q_PROPERTY(WhiteBalanceMode whiteBalanceMode READ whiteBalanceMode WRITE setWhiteBalanceMode NOTIFY whiteBalanceModeChanged)
Q_PROPERTY(int manualWhiteBalance READ manualWhiteBalance WRITE setManualWhiteBalance NOTIFY manualWhiteBalanceChanged)
Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged)
Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
Q_PROPERTY(int sharpeningLevel READ sharpeningLevel WRITE setSharpeningLevel NOTIFY sharpeningLevelChanged)
Q_PROPERTY(int denoisingLevel READ denoisingLevel WRITE setDenoisingLevel NOTIFY denoisingLevelChanged)
public:
enum WhiteBalanceMode {
WhiteBalanceAuto = QCameraImageProcessing::WhiteBalanceAuto,
WhiteBalanceManual = QCameraImageProcessing::WhiteBalanceManual,
WhiteBalanceSunlight = QCameraImageProcessing::WhiteBalanceSunlight,
WhiteBalanceCloudy = QCameraImageProcessing::WhiteBalanceCloudy,
WhiteBalanceShade = QCameraImageProcessing::WhiteBalanceShade,
WhiteBalanceTungsten = QCameraImageProcessing::WhiteBalanceTungsten,
WhiteBalanceFluorescent = QCameraImageProcessing::WhiteBalanceFluorescent,
WhiteBalanceFlash = QCameraImageProcessing::WhiteBalanceFlash,
WhiteBalanceSunset = QCameraImageProcessing::WhiteBalanceSunset,
WhiteBalanceVendor = QCameraImageProcessing::WhiteBalanceVendor
};
~QDeclarativeCameraImageProcessing();
WhiteBalanceMode whiteBalanceMode() const;
int manualWhiteBalance() const;
int contrast() const;
int saturation() const;
int sharpeningLevel() const;
int denoisingLevel() const;
public Q_SLOTS:
void setWhiteBalanceMode(QDeclarativeCameraImageProcessing::WhiteBalanceMode mode) const;
void setManualWhiteBalance(int colorTemp) const;
void setContrast(int value);
void setSaturation(int value);
void setSharpeningLevel(int value);
void setDenoisingLevel(int value);
Q_SIGNALS:
void whiteBalanceModeChanged(QDeclarativeCameraImageProcessing::WhiteBalanceMode) const;
void manualWhiteBalanceChanged(int) const;
void contrastChanged(int);
void saturationChanged(int);
void sharpeningLevelChanged(int);
void denoisingLevelChanged(int);
private:
friend class QDeclarativeCamera;
QDeclarativeCameraImageProcessing(QCamera *camera, QObject *parent = 0);
QCameraImageProcessing *m_imageProcessing;
};
QT_END_NAMESPACE
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraImageProcessing))
QT_END_HEADER
#endif

View File

@@ -0,0 +1,226 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qdeclarativecamera_p.h"
#include "qdeclarativecamerarecorder_p.h"
#include <QtCore/qurl.h>
QT_BEGIN_NAMESPACE
QDeclarativeCameraRecorder::QDeclarativeCameraRecorder(QCamera *camera, QObject *parent) :
QObject(parent)
{
m_recorder = new QMediaRecorder(camera, this);
connect(m_recorder, SIGNAL(stateChanged(QMediaRecorder::State)),
SLOT(updateRecorderState(QMediaRecorder::State)));
connect(m_recorder, SIGNAL(error(QMediaRecorder::Error)),
SLOT(updateRecorderError(QMediaRecorder::Error)));
connect(m_recorder, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool)));
connect(m_recorder, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64)));
}
QDeclarativeCameraRecorder::~QDeclarativeCameraRecorder()
{
}
QSize QDeclarativeCameraRecorder::captureResolution()
{
return m_videoSettings.resolution();
}
QString QDeclarativeCameraRecorder::audioCodec() const
{
return m_audioSettings.codec();
}
QString QDeclarativeCameraRecorder::videoCodec() const
{
return m_videoSettings.codec();
}
QString QDeclarativeCameraRecorder::mediaContainer() const
{
return m_mediaContainer;
}
void QDeclarativeCameraRecorder::setCaptureResolution(const QSize &resolution)
{
if (resolution != captureResolution()) {
m_videoSettings.setResolution(resolution);
applySettings();
emit captureResolutionChanged(resolution);
}
}
void QDeclarativeCameraRecorder::setAudioCodec(const QString &codec)
{
if (codec != audioCodec()) {
m_audioSettings.setCodec(codec);
applySettings();
emit audioCodecChanged(codec);
}
}
void QDeclarativeCameraRecorder::setVideoCodec(const QString &codec)
{
if (codec != videoCodec()) {
m_videoSettings.setCodec(codec);
applySettings();
emit videoCodecChanged(codec);
}
}
void QDeclarativeCameraRecorder::setMediaContainer(const QString &container)
{
if (container != m_mediaContainer) {
m_mediaContainer = container;
applySettings();
emit mediaContainerChanged(container);
}
}
void QDeclarativeCameraRecorder::applySettings()
{
m_recorder->setEncodingSettings(m_audioSettings,
m_videoSettings,
m_mediaContainer);
}
QMediaRecorder::Error QDeclarativeCameraRecorder::error() const
{
return m_recorder->error();
}
QString QDeclarativeCameraRecorder::errorString() const
{
return m_recorder->errorString();
}
QDeclarativeCameraRecorder::RecorderState QDeclarativeCameraRecorder::recorderState() const
{
//paused state is not supported for camera
QMediaRecorder::State state = m_recorder->state();
if (state == QMediaRecorder::PausedState)
state = QMediaRecorder::StoppedState;
return RecorderState(state);
}
void QDeclarativeCameraRecorder::record()
{
setRecorderState(RecordingState);
}
void QDeclarativeCameraRecorder::stop()
{
setRecorderState(StoppedState);
}
void QDeclarativeCameraRecorder::setRecorderState(QDeclarativeCameraRecorder::RecorderState state)
{
if (!m_recorder)
return;
switch (state) {
case QDeclarativeCameraRecorder::RecordingState:
m_recorder->record();
break;
case QDeclarativeCameraRecorder::StoppedState:
m_recorder->stop();
break;
}
}
QString QDeclarativeCameraRecorder::outputLocation() const
{
return m_recorder->outputLocation().toString();
}
void QDeclarativeCameraRecorder::setOutputLocation(const QUrl &location)
{
m_recorder->setOutputLocation(location);
}
qint64 QDeclarativeCameraRecorder::duration() const
{
return m_recorder->duration();
}
bool QDeclarativeCameraRecorder::isMuted() const
{
return m_recorder->isMuted();
}
void QDeclarativeCameraRecorder::setMuted(bool muted)
{
m_recorder->setMuted(muted);
}
void QDeclarativeCameraRecorder::setMetadata(const QString &key, const QVariant &value)
{
m_recorder->setExtendedMetaData(key, value);
}
void QDeclarativeCameraRecorder::updateRecorderState(QMediaRecorder::State state)
{
if (state == QMediaRecorder::PausedState)
state = QMediaRecorder::StoppedState;
if (state == QMediaRecorder::StoppedState) {
QString location = outputLocation();
if (!location.isEmpty())
emit outputLocationChanged(location);
}
emit recorderStateChanged(RecorderState(state));
}
void QDeclarativeCameraRecorder::updateRecorderError(QMediaRecorder::Error errorCode)
{
qWarning() << "QMediaRecorder error:" << errorString();
emit error(errorCode);
}
QT_END_NAMESPACE
#include "moc_qdeclarativecamerarecorder_p.cpp"

View File

@@ -0,0 +1,162 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QDECLARATIVECAMERARECORDER_H
#define QDECLARATIVECAMERARECORDER_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <qcamera.h>
#include <qmediarecorder.h>
#include <qmediaencodersettings.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QDeclarativeCamera;
class QDeclarativeCameraRecorder : public QObject
{
Q_OBJECT
Q_ENUMS(RecorderState)
Q_PROPERTY(RecorderState recorderState READ recorderState WRITE setRecorderState NOTIFY recorderStateChanged)
Q_PROPERTY(QSize resolution READ captureResolution WRITE setCaptureResolution NOTIFY captureResolutionChanged)
Q_PROPERTY(QString videoCodec READ videoCodec WRITE setVideoCodec NOTIFY videoCodecChanged)
Q_PROPERTY(QString audioCodec READ audioCodec WRITE setAudioCodec NOTIFY audioCodecChanged)
Q_PROPERTY(QString mediaContainer READ mediaContainer WRITE setMediaContainer NOTIFY mediaContainerChanged)
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
Q_PROPERTY(QString outputLocation READ outputLocation WRITE setOutputLocation NOTIFY outputLocationChanged)
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY error)
public:
enum RecorderState
{
StoppedState = QMediaRecorder::StoppedState,
RecordingState = QMediaRecorder::RecordingState
};
~QDeclarativeCameraRecorder();
RecorderState recorderState() const;
QSize captureResolution();
QString outputLocation() const;
qint64 duration() const;
bool isMuted() const;
QString audioCodec() const;
QString videoCodec() const;
QString mediaContainer() const;
QMediaRecorder::Error error() const;
QString errorString() const;
public Q_SLOTS:
void setOutputLocation(const QUrl &location);
void record();
void stop();
void setRecorderState(QDeclarativeCameraRecorder::RecorderState state);
void setMuted(bool muted);
void setMetadata(const QString &key, const QVariant &value);
void setCaptureResolution(const QSize &resolution);
void setAudioCodec(const QString &codec);
void setVideoCodec(const QString &codec);
void setMediaContainer(const QString &container);
Q_SIGNALS:
void recorderStateChanged(QDeclarativeCameraRecorder::RecorderState state);
void durationChanged(qint64 duration);
void mutedChanged(bool muted);
void outputLocationChanged(const QString &location);
void error(QMediaRecorder::Error errorCode);
void metaDataAvailableChanged(bool available);
void metaDataWritableChanged(bool writable);
void metaDataChanged();
void captureResolutionChanged(const QSize &);
void audioCodecChanged(const QString &codec);
void videoCodecChanged(const QString &codec);
void mediaContainerChanged(const QString &container);
private slots:
void updateRecorderState(QMediaRecorder::State);
void updateRecorderError(QMediaRecorder::Error);
private:
friend class QDeclarativeCamera;
QDeclarativeCameraRecorder(QCamera *camera, QObject *parent = 0);
void applySettings();
QMediaRecorder *m_recorder;
QAudioEncoderSettings m_audioSettings;
QVideoEncoderSettings m_videoSettings;
QString m_mediaContainer;
};
QT_END_NAMESPACE
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraRecorder))
QT_END_HEADER
#endif