summaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2011-06-29 13:38:46 +1000
committerMichael Goddard <michael.goddard@nokia.com>2011-06-29 13:38:46 +1000
commit2a34e88c1e1ced28e75c487cd13402e1c9cf9fa3 (patch)
treee6c1b770c5c47212792a1f9344fa034ea3e54c44 /src/imports
Initial copy of QtMultimediaKit.
Comes from original repo, with SHA1: 2c82d5611655e5967f5c5095af50c0991c4378b2
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/imports.pro5
-rw-r--r--src/imports/multimedia/multimedia.cpp85
-rw-r--r--src/imports/multimedia/multimedia.pro41
-rw-r--r--src/imports/multimedia/qdeclarativeaudio.cpp698
-rw-r--r--src/imports/multimedia/qdeclarativeaudio_p.h178
-rw-r--r--src/imports/multimedia/qdeclarativecamera.cpp1342
-rw-r--r--src/imports/multimedia/qdeclarativecamera_p.h302
-rw-r--r--src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp97
-rw-r--r--src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h76
-rw-r--r--src/imports/multimedia/qdeclarativemediabase.cpp567
-rw-r--r--src/imports/multimedia/qdeclarativemediabase_p.h187
-rw-r--r--src/imports/multimedia/qdeclarativemediametadata_p.h185
-rw-r--r--src/imports/multimedia/qdeclarativevideo.cpp951
-rw-r--r--src/imports/multimedia/qdeclarativevideo_p.h202
-rw-r--r--src/imports/multimedia/qmldir1
-rw-r--r--src/imports/qimportbase.pri38
16 files changed, 4955 insertions, 0 deletions
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
new file mode 100644
index 000000000..669064baa
--- /dev/null
+++ b/src/imports/imports.pro
@@ -0,0 +1,5 @@
+
+TEMPLATE = subdirs
+
+SUBDIRS += multimedia
+
diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp
new file mode 100644
index 000000000..59137390b
--- /dev/null
+++ b/src/imports/multimedia/multimedia.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include "private/qsoundeffect_p.h"
+
+#include "qdeclarativevideo_p.h"
+#include "qdeclarativeaudio_p.h"
+#include "qdeclarativemediametadata_p.h"
+#include "qdeclarativecamera_p.h"
+#include "qdeclarativecamerapreviewprovider_p.h"
+
+QML_DECLARE_TYPE(QSoundEffect)
+
+QT_BEGIN_NAMESPACE
+
+class QMultimediaDeclarativeModule : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtMultimediaKit"));
+
+ qmlRegisterType<QSoundEffect>(uri, 1, 1, "SoundEffect");
+ qmlRegisterType<QDeclarativeAudio>(uri, 1, 1, "Audio");
+ qmlRegisterType<QDeclarativeVideo>(uri, 1, 1, "Video");
+ qmlRegisterType<QDeclarativeCamera>(uri, 1, 1, "Camera");
+ qmlRegisterType<QDeclarativeMediaMetaData>();
+ }
+
+ void initializeEngine(QDeclarativeEngine *engine, const char *uri)
+ {
+ Q_UNUSED(uri);
+ engine->addImageProvider("camera", new QDeclarativeCameraPreviewProvider);
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "multimedia.moc"
+
+Q_EXPORT_PLUGIN2(qmultimediadeclarativemodule, QT_PREPEND_NAMESPACE(QMultimediaDeclarativeModule));
+
diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro
new file mode 100644
index 000000000..c3874d3ba
--- /dev/null
+++ b/src/imports/multimedia/multimedia.pro
@@ -0,0 +1,41 @@
+TARGET = declarative_multimedia
+TARGETPATH = Qt/multimediakit
+
+include(../qimportbase.pri)
+
+QT += declarative network multimediakit-private
+
+DESTDIR = $$QT.multimediakit.imports/$$TARGETPATH
+target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+
+HEADERS += \
+ qdeclarativeaudio_p.h \
+ qdeclarativemediabase_p.h \
+ qdeclarativemediametadata_p.h \
+ qdeclarativevideo_p.h \
+ qdeclarativecamera_p.h \
+ qdeclarativecamerapreviewprovider_p.h
+
+SOURCES += \
+ multimedia.cpp \
+ qdeclarativeaudio.cpp \
+ qdeclarativemediabase.cpp \
+ qdeclarativevideo.cpp \
+ qdeclarativecamera.cpp \
+ qdeclarativecamerapreviewprovider.cpp
+
+qmldir.files += $$PWD/qmldir
+qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+
+INSTALLS += target qmldir
+
+symbian {
+ # In Symbian, a library should enjoy _largest_ possible capability set.
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0x20021313
+ TARGET.EPOCALLOWDLLDATA=1
+ # Specifies what files shall be deployed: the plugin itself and the qmldir file.
+ importFiles.sources = $$DESTDIR/declarative_multimedia$${QT_LIBINFIX}.dll qmldir
+ importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
+ DEPLOYMENT = importFiles
+}
diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp
new file mode 100644
index 000000000..6ba8b39de
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativeaudio.cpp
@@ -0,0 +1,698 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativeaudio_p.h"
+
+#include <qmediaplayercontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+
+/*!
+ \qmlclass Audio QDeclarativeAudio
+ \brief The Audio element allows you to add audio playback to a scene.
+
+ \ingroup qml-multimedia
+
+ This element is part of the \bold{QtMultimediaKit 1.1} module.
+
+ \qml
+ import Qt 4.7
+ import QtMultimediaKit 1.1
+
+ Text {
+ text: "Click Me!";
+ font.pointSize: 24;
+ width: 150; height: 50;
+
+ Audio {
+ id: playMusic
+ source: "music.wav"
+ }
+ MouseArea {
+ id: playArea
+ anchors.fill: parent
+ onPressed: { playMusic.play() }
+ }
+ }
+ \endqml
+
+ \sa Video
+*/
+
+/*!
+ \internal
+ \class QDeclarativeAudio
+ \brief The QDeclarativeAudio class provides an audio item that you can add to a QDeclarativeView.
+*/
+
+void QDeclarativeAudio::_q_error(int errorCode, const QString &errorString)
+{
+ m_error = QMediaPlayer::Error(errorCode);
+ m_errorString = errorString;
+
+ emit error(Error(errorCode), errorString);
+ emit errorChanged();
+}
+
+
+QDeclarativeAudio::QDeclarativeAudio(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QDeclarativeAudio::~QDeclarativeAudio()
+{
+ shutdown();
+}
+
+/*!
+ \qmlmethod Audio::play()
+
+ Starts playback of the media.
+
+ Sets the \l playing property to true, and the \l paused property to false.
+*/
+
+void QDeclarativeAudio::play()
+{
+ if (!m_complete)
+ return;
+
+ setPaused(false);
+ setPlaying(true);
+}
+
+/*!
+ \qmlmethod Audio::pause()
+
+ Pauses playback of the media.
+
+ Sets the \l playing and \l paused properties to true.
+*/
+
+void QDeclarativeAudio::pause()
+{
+ if (!m_complete)
+ return;
+
+ setPaused(true);
+ setPlaying(true);
+}
+
+/*!
+ \qmlmethod Audio::stop()
+
+ Stops playback of the media.
+
+ Sets the \l playing and \l paused properties to false.
+*/
+
+void QDeclarativeAudio::stop()
+{
+ if (!m_complete)
+ return;
+
+ setPlaying(false);
+ setPaused(false);
+}
+
+/*!
+ \qmlproperty url Audio::source
+
+ This property holds the source URL of the media.
+*/
+
+/*!
+ \qmlproperty url Audio::autoLoad
+
+ This property indicates if loading of media should begin immediately.
+
+ Defaults to true, if false media will not be loaded until playback is started.
+*/
+
+/*!
+ \qmlproperty bool Audio::playing
+
+ This property holds whether the media is playing.
+
+ Defaults to false, and can be set to true to start playback.
+*/
+
+/*!
+ \qmlproperty bool Audio::paused
+
+ This property holds whether the media is paused.
+
+ Defaults to false, and can be set to true to pause playback.
+*/
+
+/*!
+ \qmlsignal Audio::onStarted()
+
+ This handler is called when playback is started.
+*/
+
+/*!
+ \qmlsignal Audio::onResumed()
+
+ This handler is called when playback is resumed from the paused state.
+*/
+
+/*!
+ \qmlsignal Audio::onPaused()
+
+ This handler is called when playback is paused.
+*/
+
+/*!
+ \qmlsignal Audio::onStopped()
+
+ This handler is called when playback is stopped.
+*/
+
+/*!
+ \qmlproperty enumeration Audio::status
+
+ This property holds the status of media loading. It can be one of:
+
+ \list
+ \o NoMedia - no media has been set.
+ \o Loading - the media is currently being loaded.
+ \o Loaded - the media has been loaded.
+ \o Buffering - the media is buffering data.
+ \o Stalled - playback has been interrupted while the media is buffering data.
+ \o Buffered - the media has buffered data.
+ \o EndOfMedia - the media has played to the end.
+ \o InvalidMedia - the media cannot be played.
+ \o UnknownStatus - the status of the media is unknown.
+ \endlist
+*/
+
+QDeclarativeAudio::Status QDeclarativeAudio::status() const
+{
+ return Status(m_status);
+}
+
+/*!
+ \qmlproperty int Audio::duration
+
+ This property holds the duration of the media in milliseconds.
+
+ If the media doesn't have a fixed duration (a live stream for example) this will be 0.
+*/
+
+/*!
+ \qmlproperty int Audio::position
+
+ This property holds the current playback position in milliseconds.
+
+ If the \l seekable property is true, this property can be set to seek to a new position.
+*/
+
+/*!
+ \qmlproperty real Audio::volume
+
+ This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
+*/
+
+/*!
+ \qmlproperty bool Audio::muted
+
+ This property holds whether the audio output is muted.
+*/
+
+/*!
+ \qmlproperty real Audio::bufferProgress
+
+ This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0
+ (full).
+*/
+
+/*!
+ \qmlproperty bool Audio::seekable
+
+ This property holds whether position of the audio can be changed.
+
+ If true; setting a \l position value will cause playback to seek to the new position.
+*/
+
+/*!
+ \qmlproperty real Audio::playbackRate
+
+ This property holds the rate at which audio is played at as a multiple of the normal rate.
+*/
+
+/*!
+ \qmlproperty enumeration Audio::error
+
+ This property holds the error state of the audio. It can be one of:
+
+ \list
+ \o NoError - there is no current error.
+ \o ResourceError - the audio cannot be played due to a problem allocating resources.
+ \o FormatError - the audio format is not supported.
+ \o NetworkError - the audio cannot be played due to network issues.
+ \o AccessDenied - the audio cannot be played due to insufficient permissions.
+ \o ServiceMissing - the audio cannot be played because the media service could not be
+ instantiated.
+ \endlist
+*/
+
+QDeclarativeAudio::Error QDeclarativeAudio::error() const
+{
+ return Error(m_error);
+}
+
+void QDeclarativeAudio::classBegin()
+{
+ setObject(this);
+}
+
+void QDeclarativeAudio::componentComplete()
+{
+ QDeclarativeMediaBase::componentComplete();
+}
+
+
+/*!
+ \qmlproperty string Audio::errorString
+
+ This property holds a string describing the current error condition in more detail.
+*/
+
+/*!
+ \qmlsignal Audio::onError(error, errorString)
+
+ This handler is called when an \l {QMediaPlayer::Error}{error} has
+ occurred. The errorString parameter may contain more detailed
+ information about the error.
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.title
+
+ This property holds the tile of the media.
+
+ \sa {QtMultimediaKit::Title}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.subTitle
+
+ This property holds the sub-title of the media.
+
+ \sa {QtMultimediaKit::SubTitle}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.author
+
+ This property holds the author of the media.
+
+ \sa {QtMultimediaKit::Author}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.comment
+
+ This property holds a user comment about the media.
+
+ \sa {QtMultimediaKit::Comment}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.description
+
+ This property holds a description of the media.
+
+ \sa {QtMultimediaKit::Description}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.category
+
+ This property holds the category of the media
+
+ \sa {QtMultimediaKit::Category}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.genre
+
+ This property holds the genre of the media.
+
+ \sa {QtMultimediaKit::Genre}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.year
+
+ This property holds the year of release of the media.
+
+ \sa {QtMultimediaKit::Year}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.date
+
+ This property holds the date of the media.
+
+ \sa {QtMultimediaKit::Date}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.userRating
+
+ This property holds a user rating of the media in the range of 0 to 100.
+
+ \sa {QtMultimediaKit::UserRating}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.keywords
+
+ This property holds a list of keywords describing the media.
+
+ \sa {QtMultimediaKit::Keywords}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.language
+
+ This property holds the language of the media, as an ISO 639-2 code.
+
+ \sa {QtMultimediaKit::Language}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.publisher
+
+ This property holds the publisher of the media.
+
+ \sa {QtMultimediaKit::Publisher}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.copyright
+
+ This property holds the media's copyright notice.
+
+ \sa {QtMultimediaKit::Copyright}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.parentalRating
+
+ This property holds the parental rating of the media.
+
+ \sa {QtMultimediaKit::ParentalRating}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.ratingOrganisation
+
+ This property holds the name of the rating organisation responsible for the
+ parental rating of the media.
+
+ \sa {QtMultimediaKit::RatingOrganisation}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.size
+
+ This property property holds the size of the media in bytes.
+
+ \sa {QtMultimediaKit::Size}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.mediaType
+
+ This property holds the type of the media.
+
+ \sa {QtMultimediaKit::MediaType}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.audioBitRate
+
+ This property holds the bit rate of the media's audio stream ni bits per
+ second.
+
+ \sa {QtMultimediaKit::AudioBitRate}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.audioCodec
+
+ This property holds the encoding of the media audio stream.
+
+ \sa {QtMultimediaKit::AudioCodec}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.averageLevel
+
+ This property holds the average volume level of the media.
+
+ \sa {QtMultimediaKit::AverageLevel}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.channelCount
+
+ This property holds the number of channels in the media's audio stream.
+
+ \sa {QtMultimediaKit::ChannelCount}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.peakValue
+
+ This property holds the peak volume of media's audio stream.
+
+ \sa {QtMultimediaKit::PeakValue}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.sampleRate
+
+ This property holds the sample rate of the media's audio stream in hertz.
+
+ \sa {QtMultimediaKit::SampleRate}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.albumTitle
+
+ This property holds the title of the album the media belongs to.
+
+ \sa {QtMultimediaKit::AlbumTitle}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.albumArtist
+
+ This property holds the name of the principal artist of the album the media
+ belongs to.
+
+ \sa {QtMultimediaKit::AlbumArtist}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.contributingArtist
+
+ This property holds the names of artists contributing to the media.
+
+ \sa {QtMultimediaKit::ContributingArtist}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.composer
+
+ This property holds the composer of the media.
+
+ \sa {QtMultimediaKit::Composer}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.conductor
+
+ This property holds the conductor of the media.
+
+ \sa {QtMultimediaKit::Conductor}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.lyrics
+
+ This property holds the lyrics to the media.
+
+ \sa {QtMultimediaKit::Lyrics}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.mood
+
+ This property holds the mood of the media.
+
+ \sa {QtMultimediaKit::Mood}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.trackNumber
+
+ This property holds the track number of the media.
+
+ \sa {QtMultimediaKit::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.trackCount
+
+ This property holds the number of track on the album containing the media.
+
+ \sa {QtMultimediaKit::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.coverArtUrlSmall
+
+ This property holds the URL of a small cover art image.
+
+ \sa {QtMultimediaKit::CoverArtUrlSmall}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.coverArtUrlLarge
+
+ This property holds the URL of a large cover art image.
+
+ \sa {QtMultimediaKit::CoverArtUrlLarge}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.resolution
+
+ This property holds the dimension of an image or video.
+
+ \sa {QtMultimediaKit::Resolution}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.pixelAspectRatio
+
+ This property holds the pixel aspect ratio of an image or video.
+
+ \sa {QtMultimediaKit::PixelAspectRatio}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.videoFrameRate
+
+ This property holds the frame rate of the media's video stream.
+
+ \sa {QtMultimediaKit::VideoFrameRate}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.videoBitRate
+
+ This property holds the bit rate of the media's video stream in bits per
+ second.
+
+ \sa {QtMultimediaKit::VideoBitRate}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.videoCodec
+
+ This property holds the encoding of the media's video stream.
+
+ \sa {QtMultimediaKit::VideoCodec}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.posterUrl
+
+ This property holds the URL of a poster image.
+
+ \sa {QtMultimediaKit::PosterUrl}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.chapterNumber
+
+ This property holds the chapter number of the media.
+
+ \sa {QtMultimediaKit::ChapterNumber}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.director
+
+ This property holds the director of the media.
+
+ \sa {QtMultimediaKit::Director}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.leadPerformer
+
+ This property holds the lead performer in the media.
+
+ \sa {QtMultimediaKit::LeadPerformer}
+*/
+
+/*!
+ \qmlproperty variant Audio::metaData.writer
+
+ This property holds the writer of the media.
+
+ \sa {QtMultimediaKit::Writer}
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativeaudio_p.cpp"
+
+
diff --git a/src/imports/multimedia/qdeclarativeaudio_p.h b/src/imports/multimedia/qdeclarativeaudio_p.h
new file mode 100644
index 000000000..6b7c64453
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativeaudio_p.h
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEAUDIO_P_H
+#define QDECLARATIVEAUDIO_P_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 "qdeclarativemediabase_p.h"
+
+#include <QtCore/qbasictimer.h>
+#include <QtDeclarative/qdeclarativeitem.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QTimerEvent;
+
+class QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged)
+ Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
+ Q_PROPERTY(int loops READ loopCount WRITE setLoopCount NOTIFY loopCountChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
+ Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
+ Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
+ Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
+ Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
+ Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
+ Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
+ Q_PROPERTY(Error error READ error NOTIFY errorChanged)
+ Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
+ Q_PROPERTY(QDeclarativeMediaMetaData *metaData READ metaData CONSTANT)
+ Q_ENUMS(Status)
+ Q_ENUMS(Error)
+ Q_ENUMS(Loop)
+ Q_INTERFACES(QDeclarativeParserStatus)
+public:
+ enum Status
+ {
+ UnknownStatus = QMediaPlayer::UnknownMediaStatus,
+ NoMedia = QMediaPlayer::NoMedia,
+ Loading = QMediaPlayer::LoadingMedia,
+ Loaded = QMediaPlayer::LoadedMedia,
+ Stalled = QMediaPlayer::StalledMedia,
+ Buffering = QMediaPlayer::BufferingMedia,
+ Buffered = QMediaPlayer::BufferedMedia,
+ EndOfMedia = QMediaPlayer::EndOfMedia,
+ InvalidMedia = QMediaPlayer::InvalidMedia
+ };
+
+ enum Error
+ {
+ NoError = QMediaPlayer::NoError,
+ ResourceError = QMediaPlayer::ResourceError,
+ FormatError = QMediaPlayer::FormatError,
+ NetworkError = QMediaPlayer::NetworkError,
+ AccessDenied = QMediaPlayer::AccessDeniedError,
+ ServiceMissing = QMediaPlayer::ServiceMissingError
+ };
+
+ enum Loop
+ {
+ Infinite = QDeclarativeMediaBase::INFINITE
+ };
+
+ QDeclarativeAudio(QObject *parent = 0);
+ ~QDeclarativeAudio();
+
+ Status status() const;
+ Error error() const;
+
+ void classBegin();
+ void componentComplete();
+
+public Q_SLOTS:
+ void play();
+ void pause();
+ void stop();
+
+Q_SIGNALS:
+ void sourceChanged();
+ void autoLoadChanged();
+ void playingChanged();
+ void pausedChanged();
+ void loopCountChanged();
+
+ void started();
+ void resumed();
+ void paused();
+ void stopped();
+
+ void statusChanged();
+
+ void durationChanged();
+ void positionChanged();
+
+ void volumeChanged();
+ void mutedChanged();
+
+ void bufferProgressChanged();
+
+ void seekableChanged();
+ void playbackRateChanged();
+
+ void errorChanged();
+ void error(QDeclarativeAudio::Error error, const QString &errorString);
+
+private Q_SLOTS:
+ void _q_error(int, const QString &);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeAudio)
+ Q_PRIVATE_SLOT(mediaBase(), void _q_statusChanged())
+
+ inline QDeclarativeMediaBase *mediaBase() { return this; }
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeAudio))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativecamera.cpp b/src/imports/multimedia/qdeclarativecamera.cpp
new file mode 100644
index 000000000..08562dd76
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecamera.cpp
@@ -0,0 +1,1342 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecamera_p.h"
+#include "qdeclarativecamerapreviewprovider_p.h"
+
+#include <qmediaplayercontrol.h>
+#include <qmediaservice.h>
+#include <private/qpaintervideosurface_p.h>
+#include <qvideorenderercontrol.h>
+#include <QtDeclarative/qdeclarativeinfo.h>
+
+#include <QtCore/QTimer>
+#include <QtGui/qevent.h>
+
+
+QT_BEGIN_NAMESPACE
+
+class FocusZoneItem : public QGraphicsItem {
+public:
+ FocusZoneItem(const QCameraFocusZone & zone, const QColor &color, QGraphicsItem *parent = 0)
+ :QGraphicsItem(parent),m_zone(zone), m_color(color)
+ {}
+
+ virtual ~FocusZoneItem() {}
+ void paint(QPainter *painter,
+ const QStyleOptionGraphicsItem *option,
+ QWidget *widget = 0)
+ {
+ Q_UNUSED(widget);
+ Q_UNUSED(option);
+
+ painter->setPen(QPen(QBrush(m_color), 2.5));
+ QRectF r = boundingRect();
+ QPointF dw(r.width()/10, 0);
+ QPointF dh(0, r.width()/10);
+
+ painter->drawLine(r.topLeft(), r.topLeft()+dw);
+ painter->drawLine(r.topLeft(), r.topLeft()+dh);
+
+ painter->drawLine(r.topRight(), r.topRight()-dw);
+ painter->drawLine(r.topRight(), r.topRight()+dh);
+
+ painter->drawLine(r.bottomLeft(), r.bottomLeft()+dw);
+ painter->drawLine(r.bottomLeft(), r.bottomLeft()-dh);
+
+ painter->drawLine(r.bottomRight(), r.bottomRight()-dw);
+ painter->drawLine(r.bottomRight(), r.bottomRight()-dh);
+ }
+
+ QRectF boundingRect() const {
+ if (!parentItem())
+ return QRectF();
+
+ QRectF p = parentItem()->boundingRect();
+ QRectF zone = m_zone.area();
+
+ return QRectF(p.left() + zone.left()*p.width(),
+ p.top() + zone.top()*p.height(),
+ p.width()*zone.width(),
+ p.height()*zone.height());
+ }
+
+
+ QCameraFocusZone m_zone;
+ QColor m_color;
+};
+
+
+void QDeclarativeCamera::_q_nativeSizeChanged(const QSizeF &size)
+{
+ setImplicitWidth(size.width());
+ setImplicitHeight(size.height());
+}
+
+void QDeclarativeCamera::_q_error(int errorCode, const QString &errorString)
+{
+ emit error(Error(errorCode), errorString);
+ emit errorChanged();
+}
+
+void QDeclarativeCamera::_q_imageCaptured(int id, const QImage &preview)
+{
+ m_capturedImagePreview = preview;
+ QString previewId = QString("preview_%1").arg(id);
+ QDeclarativeCameraPreviewProvider::registerPreview(previewId, preview);
+
+ emit imageCaptured(QLatin1String("image://camera/")+previewId);
+}
+
+void QDeclarativeCamera::_q_imageSaved(int id, const QString &fileName)
+{
+ Q_UNUSED(id);
+ m_capturedImagePath = fileName;
+ emit imageSaved(fileName);
+}
+
+void QDeclarativeCamera::_q_updateState(QCamera::State state)
+{
+ emit cameraStateChanged(QDeclarativeCamera::State(state));
+}
+
+void QDeclarativeCamera::_q_updateLockStatus(QCamera::LockType type,
+ QCamera::LockStatus status,
+ QCamera::LockChangeReason reason)
+{
+ if (type == QCamera::LockFocus) {
+ if (status == QCamera::Unlocked && reason == QCamera::LockFailed) {
+ //display failed focus points in red for 1 second
+ m_focusFailedTime = QTime::currentTime();
+ QTimer::singleShot(1000, this, SLOT(_q_updateFocusZones()));
+ } else {
+ m_focusFailedTime = QTime();
+ }
+ _q_updateFocusZones();
+ }
+}
+
+void QDeclarativeCamera::_q_updateFocusZones()
+{
+ qDeleteAll(m_focusZones);
+ m_focusZones.clear();
+
+ foreach(const QCameraFocusZone &zone, m_camera->focus()->focusZones()) {
+ QColor c;
+ QCamera::LockStatus lockStatus = m_camera->lockStatus(QCamera::LockFocus);
+
+ if (lockStatus == QCamera::Unlocked) {
+ //display failed focus points in red for 1 second
+ if (zone.status() == QCameraFocusZone::Selected &&
+ m_focusFailedTime.msecsTo(QTime::currentTime()) < 500) {
+ c = Qt::red;
+ }
+ } else {
+ switch (zone.status()) {
+ case QCameraFocusZone::Focused:
+ c = Qt::green;
+ break;
+ case QCameraFocusZone::Selected:
+ c = lockStatus == QCamera::Searching ? Qt::yellow : Qt::black;
+ break;
+ default:
+ c= QColor::Invalid;
+ break;
+ }
+ }
+
+ if (c.isValid())
+ m_focusZones.append(new FocusZoneItem(zone, c, m_viewfinderItem));
+ }
+}
+
+void QDeclarativeCamera::_q_updateImageSettings()
+{
+ if (m_imageSettingsChanged) {
+ m_imageSettingsChanged = false;
+ m_capture->setEncodingSettings(m_imageSettings);
+ }
+}
+
+void QDeclarativeCamera::_q_applyPendingState()
+{
+ if (!m_isStateSet) {
+ m_isStateSet = true;
+ setCameraState(m_pendingState);
+ }
+}
+
+void QDeclarativeCamera::_q_captureFailed(int id, QCameraImageCapture::Error error, const QString &message)
+{
+ Q_UNUSED(id);
+ Q_UNUSED(error);
+ emit captureFailed(message);
+}
+
+
+/*!
+ \qmlclass Camera QDeclarativeCamera
+ \since 4.7
+ \brief The Camera element allows you to add camera viewfinder to a scene.
+ \ingroup qml-multimedia
+ \inherits Item
+
+ This element is part of the \bold{QtMultimediaKit 1.1} module.
+
+ \qml
+ import Qt 4.7
+ import QtMultimediaKit 1.1
+
+ Camera {
+ focus : visible // to receive focus and capture key events when visible
+
+ flashMode: Camera.FlashRedEyeReduction
+ whiteBalanceMode: Camera.WhiteBalanceFlash
+ exposureCompensation: -1.0
+
+ onImageCaptured : {
+ photoPreview.source = preview // Show the preview in an Image element
+ }
+
+ }
+ \endqml
+
+ You can use the \c Camera element to capture images from a camera, and manipulate the capture and
+ processing settings that get applied to the image.
+
+ \note On Symbian, your process requires the \c UserEnvironment capability to use this element.
+*/
+
+/*!
+ \class QDeclarativeCamera
+ \brief The QDeclarativeCamera class provides a camera item that you can add to a QDeclarativeView.
+*/
+
+/*!
+ Construct a declarative camera object using \a parent object.
+ */
+QDeclarativeCamera::QDeclarativeCamera(QDeclarativeItem *parent) :
+ QDeclarativeItem(parent),
+ m_camera(0),
+ m_viewfinderItem(0),
+ m_imageSettingsChanged(false),
+ m_pendingState(ActiveState),
+ m_isStateSet(false),
+ m_isValid(true)
+{
+#if defined(Q_OS_SYMBIAN)
+ RProcess thisProcess;
+ if (!thisProcess.HasCapability(ECapabilityUserEnvironment)) {
+ qmlInfo(this) << "Camera Element requires UserEnvironment Capability to be successfully used on Symbian";
+ m_isValid = false;
+ return;
+ }
+#endif
+ m_camera = new QCamera(this);
+ m_viewfinderItem = new QGraphicsVideoItem(this);
+ m_camera->setViewfinder(m_viewfinderItem);
+ m_exposure = m_camera->exposure();
+ m_focus = m_camera->focus();
+
+ connect(m_viewfinderItem, SIGNAL(nativeSizeChanged(QSizeF)),
+ this, SLOT(_q_nativeSizeChanged(QSizeF)));
+
+ connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)), this, SIGNAL(lockStatusChanged()));
+ connect(m_camera, SIGNAL(stateChanged(QCamera::State)), this, SLOT(_q_updateState(QCamera::State)));
+
+ m_capture = new QCameraImageCapture(m_camera, this);
+
+ connect(m_capture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(_q_imageCaptured(int, QImage)));
+ 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)));
+
+ connect(m_focus, SIGNAL(focusZonesChanged()), this, SLOT(_q_updateFocusZones()));
+ connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)),
+ this, SLOT(_q_updateLockStatus(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
+
+ 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)));
+
+ connect(m_focus, SIGNAL(opticalZoomChanged(qreal)), this, SIGNAL(opticalZoomChanged(qreal)));
+ connect(m_focus, SIGNAL(digitalZoomChanged(qreal)), this, SIGNAL(digitalZoomChanged(qreal)));
+ connect(m_focus, SIGNAL(maximumOpticalZoomChanged(qreal)), this, SIGNAL(maximumOpticalZoomChanged(qreal)));
+ connect(m_focus, SIGNAL(maximumDigitalZoomChanged(qreal)), this, SIGNAL(maximumDigitalZoomChanged(qreal)));
+
+ //delayed start to evoid stopping the cammera immediately if
+ //stop() is called after constructor,
+ //or to set the rest of camera settings before starting the camera
+ QMetaObject::invokeMethod(this, "_q_applyPendingState", Qt::QueuedConnection);
+
+}
+
+/*! Destructor, clean up memory */
+QDeclarativeCamera::~QDeclarativeCamera()
+{
+ if (m_isValid) {
+ m_camera->unload();
+
+ delete m_viewfinderItem;
+ delete m_capture;
+ delete m_camera;
+ }
+}
+
+/*!
+ Returns any camera error.
+ \sa QDeclarativeError::Error
+*/
+QDeclarativeCamera::Error QDeclarativeCamera::error() const
+{
+ if (!m_isValid)
+ return QDeclarativeCamera::CameraError;
+
+ return QDeclarativeCamera::Error(m_camera->error());
+}
+
+/*!
+ \qmlproperty string Camera::errorString
+
+ A description of the current error, if any.
+*/
+/*!
+ \property QDeclarativeCamera::errorString
+
+ A description of the current error, if any.
+*/
+QString QDeclarativeCamera::errorString() const
+{
+ if (!m_isValid)
+ return QString();
+
+ return m_camera->errorString();
+}
+
+/*!
+ \qmlproperty enumeration Camera::cameraState
+
+ The current state of the camera object.
+
+ \table
+ \header \o Value \o Description
+ \row \o UnloadedState
+ \o The initial camera state, with camera not loaded,
+ the camera capabilities except of supported capture modes
+ are unknown.
+ While the supported settings are unknown in this state,
+ it's allowed to set the camera capture settings like codec,
+ resolution, or frame rate.
+
+ \row \o LoadedState
+ \o The camera is loaded and ready to be configured.
+
+ In the Idle state it's allowed to query camera capabilities,
+ set capture resolution, codecs, etc.
+
+ The viewfinder is not active in the loaded state.
+
+ \row \o ActiveState
+ \o In the active state as soon as camera is started
+ the viewfinder displays video frames and the
+ camera is ready for capture.
+ \endtable
+*/
+/*!
+ \property QDeclarativeCamera::cameraState
+
+ The current state of the camera object.
+
+ \table
+ \header \o Value \o Description
+ \row \o UnloadedState
+ \o The initial camera state, with camera not loaded,
+ the camera capabilities except of supported capture modes
+ are unknown.
+ While the supported settings are unknown in this state,
+ it's allowed to set the camera capture settings like codec,
+ resolution, or frame rate.
+
+ \row \o LoadedState
+ \o The camera is loaded and ready to be configured.
+
+ In the Idle state it's allowed to query camera capabilities,
+ set capture resolution, codecs, etc.
+
+ The viewfinder is not active in the loaded state.
+
+ \row \o ActiveState
+ \o In the active state as soon as camera is started
+ the viewfinder displays video frames and the
+ camera is ready for capture.
+ \endtable
+*/
+/*!
+ \enum QDeclarativeCamera::State
+ \value UnloadedState
+ The initial camera state, with camera not loaded,
+ the camera capabilities except of supported capture modes
+ are unknown.
+ While the supported settings are unknown in this state,
+ it's allowed to set the camera capture settings like codec,
+ resolution, or frame rate.
+
+ \value LoadedState
+ The camera is loaded and ready to be configured.
+ In the Idle state it's allowed to query camera capabilities,
+ set capture resolution, codecs, etc.
+ The viewfinder is not active in the loaded state.
+
+ \value ActiveState
+ In the active state as soon as camera is started
+ the viewfinder displays video frames and the
+ camera is ready for capture.
+
+
+ The default camera state is ActiveState.
+*/
+
+QDeclarativeCamera::State QDeclarativeCamera::cameraState() const
+{
+ if (!m_isValid)
+ return QDeclarativeCamera::UnloadedState;
+
+ return m_isStateSet ? QDeclarativeCamera::State(m_camera->state()) : m_pendingState;
+}
+
+void QDeclarativeCamera::setCameraState(QDeclarativeCamera::State state)
+{
+ if (!m_isValid)
+ return;
+
+ if (!m_isStateSet) {
+ m_pendingState = state;
+ return;
+ }
+
+ switch (state) {
+ case QDeclarativeCamera::ActiveState:
+ m_camera->start();
+ break;
+ case QDeclarativeCamera::UnloadedState:
+ m_camera->unload();
+ break;
+ case QDeclarativeCamera::LoadedState:
+ m_camera->load();
+ break;
+ }
+}
+
+/*!
+ \qmlmethod Camera::start()
+ \fn QDeclarativeCamera::start()
+
+ Starts the camera.
+*/
+void QDeclarativeCamera::start()
+{
+ if (m_isValid)
+ m_camera->start();
+}
+
+/*!
+ \qmlmethod Camera::stop()
+ \fn QDeclarativeCamera::stop()
+
+ Stops the camera.
+*/
+void QDeclarativeCamera::stop()
+{
+ if (m_isValid)
+ m_camera->stop();
+}
+
+
+/*!
+ \qmlproperty enumeration Camera::lockStatus
+
+ The overall status for all the requested camera locks.
+
+ \table
+ \header \o Value \o Description
+ \row \o Unlocked
+ \o The application is not interested in camera settings value.
+ The camera may keep this parameter without changes, this is common with camera focus,
+ or adjust exposure and white balance constantly to keep the viewfinder image nice.
+
+ \row \o Searching
+ \o The application has requested the camera focus, exposure or white balance lock with
+ searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance.
+
+ \row \o Locked
+ \o The camera focus, exposure or white balance is locked.
+ The camera is ready to capture, application may check the exposure parameters.
+
+ The locked state usually means the requested parameter stays the same,
+ except in the cases when the parameter is requested to be constantly updated.
+ For example in continuous focusing mode, the focus is considered locked as long
+ and the object is in focus, even while the actual focusing distance may be constantly changing.
+ \endtable
+*/
+/*!
+ \property QDeclarativeCamera::lockStatus
+
+ The overall status for all the requested camera locks.
+
+ \table
+ \header \o Value \o Description
+ \row \o Unlocked
+ \o The application is not interested in camera settings value.
+ The camera may keep this parameter without changes, this is common with camera focus,
+ or adjust exposure and white balance constantly to keep the viewfinder image nice.
+
+ \row \o Searching
+ \o The application has requested the camera focus, exposure or white balance lock with
+ searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance.
+
+ \row \o Locked
+ \o The camera focus, exposure or white balance is locked.
+ The camera is ready to capture, application may check the exposure parameters.
+
+ The locked state usually means the requested parameter stays the same,
+ except in the cases when the parameter is requested to be constantly updated.
+ For example in continuous focusing mode, the focus is considered locked as long
+ and the object is in focus, even while the actual focusing distance may be constantly changing.
+ \endtable
+*/
+/*!
+ \enum QDeclarativeCamera::LockStatus
+ \value Unlocked
+ The application is not interested in camera settings value.
+ The camera may keep this parameter without changes, this is common with camera focus,
+ or adjust exposure and white balance constantly to keep the viewfinder image nice.
+
+ \value Searching
+ The application has requested the camera focus, exposure or white balance lock with
+ searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance.
+
+ \value Locked
+ The camera focus, exposure or white balance is locked.
+ The camera is ready to capture, application may check the exposure parameters.
+
+ The locked state usually means the requested parameter stays the same,
+ except in the cases when the parameter is requested to be constantly updated.
+ For example in continuous focusing mode, the focus is considered locked as long
+ and the object is in focus, even while the actual focusing distance may be constantly changing.
+*/
+QDeclarativeCamera::LockStatus QDeclarativeCamera::lockStatus() const
+{
+ if (!m_isValid)
+ return QDeclarativeCamera::Unlocked;
+
+ return QDeclarativeCamera::LockStatus(m_camera->lockStatus());
+}
+
+/*!
+ \qmlmethod Camera::searchAndLock()
+ \fn QDeclarativeCamera::searchAndLock()
+
+ Start focusing, exposure and white balance calculation.
+ If the camera has keyboard focus, searchAndLock() is called
+ automatically when the camera focus button is pressed.
+*/
+void QDeclarativeCamera::searchAndLock()
+{
+ if (m_isValid)
+ m_camera->searchAndLock();
+}
+
+/*!
+ \qmlmethod Camera::unlock()
+ \fn QDeclarativeCamera::unlock()
+
+ Unlock focus.
+
+ If the camera has keyboard focus, unlock() is called automatically
+ when the camera focus button is released.
+ */
+void QDeclarativeCamera::unlock()
+{
+ if (m_isValid)
+ m_camera->unlock();
+}
+
+/*!
+ \qmlmethod Camera::captureImage()
+ \fn QDeclarativeCamera::captureImage()
+
+ Start image capture. The \l onImageCaptured() and \l onImageSaved() signals will
+ be emitted when the capture is complete.
+*/
+void QDeclarativeCamera::captureImage()
+{
+ if (m_isValid)
+ m_capture->capture();
+}
+
+// XXX this doesn't seem to be used
+/*!
+ \fn QDeclarativeCamera::capturedImagePreview() const
+*/
+QImage QDeclarativeCamera::capturedImagePreview() const
+{
+ return m_capturedImagePreview;
+}
+
+/*!
+ \qmlproperty string Camera::capturedImagePath
+
+ The path to the captured image.
+*/
+/*!
+ \property QDeclarativeCamera::capturedImagePath
+
+ The path to the captured image.
+*/
+QString QDeclarativeCamera::capturedImagePath() const
+{
+ return m_capturedImagePath;
+}
+
+/*!
+ Paint method.
+*/
+void QDeclarativeCamera::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+{
+}
+
+/*!
+ Change viewfinder size to \a newGeometry and returning the \a oldGeometry
+*/
+void QDeclarativeCamera::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ m_viewfinderItem->setSize(newGeometry.size());
+ _q_updateFocusZones();
+
+ QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+void QDeclarativeCamera::keyPressEvent(QKeyEvent * event)
+{
+ if (!m_isValid || event->isAutoRepeat())
+ return;
+
+ switch (event->key()) {
+ case Qt::Key_CameraFocus:
+ m_camera->searchAndLock();
+ event->accept();
+ break;
+ case Qt::Key_Camera:
+ if (m_camera->captureMode() == QCamera::CaptureStillImage)
+ captureImage();
+ //else
+ // m_recorder->record();
+ event->accept();
+ break;
+ default:
+ QDeclarativeItem::keyPressEvent(event);
+ }
+}
+
+/*!
+ Handle the release of a key in \a event and take action if needed.
+*/
+void QDeclarativeCamera::keyReleaseEvent(QKeyEvent * event)
+{
+ if (!m_isValid || event->isAutoRepeat())
+ return;
+
+ switch (event->key()) {
+ case Qt::Key_CameraFocus:
+ m_camera->unlock();
+ event->accept();
+ break;
+ case Qt::Key_Camera:
+ //if (m_camera->captureMode() == QCamera::CaptureVideo)
+ // m_recorder->stop();
+ event->accept();
+ break;
+ default:
+ QDeclarativeItem::keyReleaseEvent(event);
+ }
+}
+
+
+/*!
+ \qmlproperty enumeration Camera::flashMode
+
+ \table
+ \header \o Value \o Description
+ \row \o FlashOff \o Flash is Off.
+ \row \o FlashOn \o Flash is On.
+ \row \o FlashAuto \o Automatic flash.
+ \row \o FlashRedEyeReduction \o Red eye reduction flash.
+ \row \o FlashFill \o Use flash to fillin shadows.
+ \row \o FlashTorch \o Constant light source, useful for focusing and video capture.
+ \row \o 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 FlashSlowSyncRearCurtain
+ \o The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
+ \row \o FlashManual \o Flash power is manually set.
+ \endtable
+
+*/
+/*!
+ \property QDeclarativeCamera::flashMode
+
+ \table
+ \header \o Value \o Description
+ \row \o FlashOff \o Flash is Off.
+ \row \o FlashOn \o Flash is On.
+ \row \o FlashAuto \o Automatic flash.
+ \row \o FlashRedEyeReduction \o Red eye reduction flash.
+ \row \o FlashFill \o Use flash to fillin shadows.
+ \row \o FlashTorch \o Constant light source, useful for focusing and video capture.
+ \row \o 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 FlashSlowSyncRearCurtain
+ \o The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
+ \row \o FlashManual \o Flash power is manually set.
+ \endtable
+
+*/
+/*!
+ \enum QDeclarativeCamera::FlashMode
+ \value FlashOff Flash is Off.
+ \value FlashOn Flash is On.
+ \value FlashAuto Automatic flash.
+ \value FlashRedEyeReduction Red eye reduction flash.
+ \value FlashFill Use flash to fillin shadows.
+ \value FlashTorch Constant light source, useful for focusing and video capture.
+ \value FlashSlowSyncFrontCurtain
+ Use the flash in conjunction with a slow shutter speed.
+ This mode allows better exposure of distant objects and/or motion blur effect.
+ \value FlashSlowSyncRearCurtain
+ The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
+ \value FlashManual Flash power is manually set.
+
+*/
+int QDeclarativeCamera::flashMode() const
+{
+ if (!m_isValid)
+ return 0;
+
+ return m_exposure->flashMode();
+}
+
+void QDeclarativeCamera::setFlashMode(int mode)
+{
+ if (m_isValid && m_exposure->flashMode() != mode) {
+ m_exposure->setFlashMode(QCameraExposure::FlashModes(mode));
+ emit flashModeChanged(mode);
+ }
+}
+
+/*!
+ \qmlproperty real Camera::exposureCompensation
+
+ Adjustment for the automatically calculated exposure. The value is
+ in EV units.
+ */
+/*!
+ \property QDeclarativeCamera::exposureCompensation
+
+ Adjustment for the automatically calculated exposure. The value is
+ in EV units.
+ */
+qreal QDeclarativeCamera::exposureCompensation() const
+{
+ if (!m_isValid)
+ return 0.0;
+
+ return m_exposure->exposureCompensation();
+}
+
+void QDeclarativeCamera::setExposureCompensation(qreal ev)
+{
+ if (m_isValid)
+ m_exposure->setExposureCompensation(ev);
+}
+
+/*!
+ \qmlproperty real Camera::isoSensitivity
+
+ The sensor's ISO sensitivity.
+ */
+/*!
+ \property QDeclarativeCamera::iso
+
+ The sensor's ISO sensitivity.
+ */
+int QDeclarativeCamera::isoSensitivity() const
+{
+ if (!m_isValid)
+ return 0;
+
+ return m_exposure->isoSensitivity();
+}
+
+void QDeclarativeCamera::setManualIsoSensitivity(int iso)
+{
+ if (!m_isValid)
+ return;
+
+ m_exposure->setManualIsoSensitivity(iso);
+}
+
+/*!
+ \qmlproperty real Camera::shutterSpeed
+
+ The camera's shutter speed, in seconds.
+*/
+/*!
+ \property QDeclarativeCamera::shutterSpeed
+
+ The camera's shutter speed, in seconds.
+*/
+qreal QDeclarativeCamera::shutterSpeed() const
+{
+ if (!m_isValid)
+ return 0.0;
+
+ return m_exposure->shutterSpeed();
+}
+
+/*!
+ \qmlproperty real Camera::aperture
+
+ The lens aperture as an F number (the ratio of the focal length to effective aperture diameter).
+*/
+/*!
+ \property QDeclarativeCamera::aperture
+
+ The lens aperture as an F number (the ratio of the focal length to effective aperture diameter).
+*/
+qreal QDeclarativeCamera::aperture() const
+{
+ if (!m_isValid)
+ return 0.0;
+
+ return m_exposure->aperture();
+}
+
+/*!
+ \qmlproperty enumeration Camera::exposureMode
+
+ \table
+ \header \o Value \o Description
+ \row \o ExposureManual \o Manual mode.
+ \row \o ExposureAuto \o Automatic mode.
+ \row \o ExposureNight \o Night mode.
+ \row \o ExposureBacklight \o Backlight exposure mode.
+ \row \o ExposureSpotlight \o Spotlight exposure mode.
+ \row \o ExposureSports \o Spots exposure mode.
+ \row \o ExposureSnow \o Snow exposure mode.
+ \row \o ExposureBeach \o Beach exposure mode.
+ \row \o ExposureLargeAperture \o Use larger aperture with small depth of field.
+ \row \o ExposureSmallAperture \o Use smaller aperture.
+ \row \o ExposurePortrait \o Portrait exposure mode.
+ \row \o ExposureModeVendor \o The base value for device specific exposure modes.
+ \endtable
+
+*/
+/*!
+ \enum QDeclarativeCamera::ExposureMode
+ \value ExposureManual Manual mode.
+ \value ExposureAuto Automatic mode.
+ \value ExposureNight Night mode.
+ \value ExposureBacklight Backlight exposure mode.
+ \value ExposureSpotlight Spotlight exposure mode.
+ \value ExposureSports Spots exposure mode.
+ \value ExposureSnow Snow exposure mode.
+ \value ExposureBeach Beach exposure mode.
+ \value ExposureLargeAperture Use larger aperture with small depth of field.
+ \value ExposureSmallAperture Use smaller aperture.
+ \value ExposurePortrait Portrait exposure mode.
+ \value ExposureModeVendor The base value for device specific exposure modes.
+
+*/
+/*!
+ \property QDeclarativeCamera::exposureMode
+
+ Camera exposure modes.
+*/
+QDeclarativeCamera::ExposureMode QDeclarativeCamera::exposureMode() const
+{
+ if (!m_isValid)
+ return QDeclarativeCamera::ExposureAuto;
+
+ return ExposureMode(m_exposure->exposureMode());
+}
+
+void QDeclarativeCamera::setExposureMode(QDeclarativeCamera::ExposureMode mode)
+{
+ if (!m_isValid)
+ return;
+
+ if (exposureMode() != mode) {
+ m_exposure->setExposureMode(QCameraExposure::ExposureMode(mode));
+ emit exposureModeChanged(exposureMode());
+ }
+}
+
+/*!
+ \qmlproperty size Camera::captureResolution
+
+ The resolution to capture the image at. If empty, the system will pick
+ a good size.
+*/
+/*!
+ \property QDeclarativeCamera::captureResolution
+
+ The resolution to capture the image at. If empty, the system will pick
+ a good size.
+*/
+QSize QDeclarativeCamera::captureResolution() const
+{
+ if (!m_isValid)
+ return QSize();
+
+ return m_imageSettings.resolution();
+}
+
+void QDeclarativeCamera::setCaptureResolution(const QSize &resolution)
+{
+ if (m_isValid && m_imageSettings.resolution() != resolution) {
+ m_imageSettings.setResolution(resolution);
+
+ if (!m_imageSettingsChanged) {
+ m_imageSettingsChanged = true;
+ QMetaObject::invokeMethod(this, "_q_updateImageSettings", Qt::QueuedConnection);
+ }
+
+ emit captureResolutionChanged(resolution);
+ }
+}
+
+/*!
+ \qmlproperty real Camera::maximumOpticalZoom
+
+ The maximum optical zoom factor, or 1.0 if optical zoom is not supported.
+*/
+/*!
+ \property QDeclarativeCamera::maximumOpticalZoom
+
+ The maximum optical zoom factor, or 1.0 if optical zoom is not supported.
+*/
+qreal QDeclarativeCamera::maximumOpticalZoom() const
+{
+ if (!m_isValid)
+ return 0.0;
+
+ return m_focus->maximumOpticalZoom();
+}
+
+/*!
+ \qmlproperty real Camera::maximumDigitalZoom
+
+ The maximum digital zoom factor, or 1.0 if digital zoom is not supported.
+*/
+/*!
+ \property QDeclarativeCamera::maximumDigitalZoom
+
+ The maximum digital zoom factor, or 1.0 if digital zoom is not supported.
+*/
+qreal QDeclarativeCamera::maximumDigitalZoom() const
+{
+ if (!m_isValid)
+ return 0.0;
+
+ return m_focus->maximumDigitalZoom();
+}
+
+/*!
+ \qmlproperty real Camera::opticalZoom
+
+ The current optical zoom factor.
+*/
+/*!
+ \property QDeclarativeCamera::opticalZoom
+
+ The current optical zoom factor.
+*/
+qreal QDeclarativeCamera::opticalZoom() const
+{
+ if (!m_isValid)
+ return 0.0;
+
+ return m_focus->opticalZoom();
+}
+
+void QDeclarativeCamera::setOpticalZoom(qreal value)
+{
+ if (m_isValid)
+ m_focus->zoomTo(value, digitalZoom());
+}
+
+/*!
+ \qmlproperty real Camera::digitalZoom
+
+ The current digital zoom factor.
+*/
+/*!
+ \property QDeclarativeCamera::digitalZoom
+
+ The current digital zoom factor.
+*/
+qreal QDeclarativeCamera::digitalZoom() const
+{
+ if (!m_isValid)
+ return 0.0;
+
+ return m_focus->digitalZoom();
+}
+
+void QDeclarativeCamera::setDigitalZoom(qreal value)
+{
+ if (m_isValid)
+ m_focus->zoomTo(opticalZoom(), value);
+}
+
+/*!
+ \enum QDeclarativeCamera::WhiteBalanceMode
+ \value WhiteBalanceManual Manual white balance. In this mode the manual white balance property value is used.
+ \value WhiteBalanceAuto Auto white balance mode.
+ \value WhiteBalanceSunlight Sunlight white balance mode.
+ \value WhiteBalanceCloudy Cloudy white balance mode.
+ \value WhiteBalanceShade Shade white balance mode.
+ \value WhiteBalanceTungsten Tungsten white balance mode.
+ \value WhiteBalanceFluorescent Fluorescent white balance mode.
+ \value WhiteBalanceIncandescent Incandescent white balance mode.
+ \value WhiteBalanceFlash Flash white balance mode.
+ \value WhiteBalanceSunset Sunset white balance mode.
+ \value WhiteBalanceVendor Vendor defined white balance mode.
+*/
+/*!
+ \qmlproperty enumeration Camera::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 WhiteBalanceIncandescent \o Incandescent 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 QDeclarativeCamera::whiteBalanceMode
+
+ \sa WhiteBalanceMode
+*/
+QDeclarativeCamera::WhiteBalanceMode QDeclarativeCamera::whiteBalanceMode() const
+{
+ if (!m_isValid)
+ return QDeclarativeCamera::WhiteBalanceAuto;
+
+ return WhiteBalanceMode(m_camera->imageProcessing()->whiteBalanceMode());
+}
+
+void QDeclarativeCamera::setWhiteBalanceMode(QDeclarativeCamera::WhiteBalanceMode mode) const
+{
+ if (m_isValid && whiteBalanceMode() != mode) {
+ m_camera->imageProcessing()->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode(mode));
+ emit whiteBalanceModeChanged(whiteBalanceMode());
+ }
+}
+
+/*!
+ \qmlproperty int Camera::manualWhiteBalance
+
+ The color temperature used when in manual white balance mode (WhiteBalanceManual).
+
+ \sa whiteBalanceMode
+*/
+/*!
+ \property QDeclarativeCamera::manualWhiteBalance
+
+ The color temperature used when in manual white balance mode (WhiteBalanceManual).
+
+ \sa whiteBalanceMode
+*/
+int QDeclarativeCamera::manualWhiteBalance() const
+{
+ if (!m_isValid)
+ return 0;
+
+ return m_camera->imageProcessing()->manualWhiteBalance();
+}
+
+void QDeclarativeCamera::setManualWhiteBalance(int colorTemp) const
+{
+ if (m_isValid && manualWhiteBalance() != colorTemp) {
+ m_camera->imageProcessing()->setManualWhiteBalance(colorTemp);
+ emit manualWhiteBalanceChanged(manualWhiteBalance());
+ }
+}
+
+/*!
+ \qmlsignal Camera::onError(error, errorString)
+
+
+ This handler is called when an error occurs. The enumeration value \a error is one of the
+ values defined below, and a descriptive string value is available in \a errorString.
+
+ \table
+ \header \o Value \o Description
+ \row \o NoError \o No errors have occurred.
+ \row \o CameraError \o An error has occurred.
+ \row \o InvalidRequestError \o System resource doesn't support requested functionality.
+ \row \o ServiceMissingError \o No camera service available.
+ \row \o NotSupportedFeatureError \o The feature is not supported.
+ \endtable
+*/
+/*!
+ \qmlsignal Camera::onError(error, errorString)
+
+
+ This handler is called when an error occurs. The enumeration value \a error is one of the
+ values defined below, and a descriptive string value is available in \a errorString.
+*/
+/*!
+ \enum QDeclarativeCamera::Error
+ \value NoError No errors have occurred.
+ \value CameraError An error has occurred.
+ \value InvalidRequestError System resource doesn't support requested functionality.
+ \value ServiceMissingError No camera service available.
+ \value NotSupportedFeatureError The feature is not supported.
+*/
+
+
+/*!
+ \qmlsignal Camera::onCaptureFailed(message)
+
+ This handler is called when an error occurs during capture. A descriptive message is available in \a message.
+*/
+/*!
+ \fn QDeclarativeCamera::captureFailed(const QString &message)
+
+ This handler is called when an error occurs during capture. A descriptive message is available in \a message.
+*/
+
+/*!
+ \qmlsignal Camera::onImageCaptured(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
+*/
+/*!
+ \fn QDeclarativeCamera::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 imageSaved()
+*/
+
+/*!
+ \qmlsignal Camera::onImageSaved(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
+*/
+/*!
+ \fn QDeclarativeCamera::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 imageCaptured()
+*/
+
+
+/*!
+ \fn void QDeclarativeCamera::lockStatusChanged()
+
+ \qmlsignal Camera::lockStatusChanged()
+*/
+
+/*!
+ \fn void QDeclarativeCamera::stateChanged(QDeclarativeCamera::State)
+
+ \qmlsignal Camera::stateChanged(Camera::State)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::imageCaptured(const QString &)
+
+ \qmlsignal Camera::imageCaptured(string)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::imageSaved(const QString &)
+
+ \qmlsignal Camera::imageSaved(string)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::error(QDeclarativeCamera::Error , const QString &)
+
+ \qmlsignal Camera::error(Camera::Error, string)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::errorChanged()
+
+*/
+/*!
+ \qmlsignal Camera::errorChanged()
+*/
+
+/*!
+ \fn void QDeclarativeCamera::isoSensitivityChanged(int)
+*/
+/*!
+ \qmlsignal Camera::isoSensitivityChanged(int)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::apertureChanged(qreal)
+
+ \qmlsignal Camera::apertureChanged(real)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::shutterSpeedChanged(qreal)
+
+*/
+/*!
+ \qmlsignal Camera::shutterSpeedChanged(real)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::exposureCompensationChanged(qreal)
+
+*/
+/*!
+ \qmlsignal Camera::exposureCompensationChanged(real)
+*/
+
+/*!
+ \fn void QDeclarativeCamera:opticalZoomChanged(qreal zoom)
+
+ Optical zoom changed to \a zoom.
+*/
+/*!
+ \qmlsignal Camera::opticalZoomChanged(real)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::digitalZoomChanged(qreal)
+
+ \qmlsignal Camera::digitalZoomChanged(real)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::maximumOpticalZoomChanged(qreal)
+
+ \qmlsignal Camera::maximumOpticalZoomChanged(real)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::maximumDigitalZoomChanged(qreal)
+
+ \qmlsignal Camera::maximumDigitalZoomChanged(real)
+*/
+
+
+/*!
+ \fn void QDeclarativeCamera::exposureModeChanged(QDeclarativeCamera::ExposureMode)
+
+ \qmlsignal Camera::exposureModeChanged(Camera::ExposureMode)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::flashModeChanged(int)
+*/
+/*!
+ \qmlsignal Camera::flashModeChanged(int)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::whiteBalanceModeChanged(QDeclarativeCamera::WhiteBalanceMode) const
+
+*/
+/*!
+ \qmlsignal Camera::whiteBalanceModeChanged(Camera::WhiteBalanceMode)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::manualWhiteBalanceChanged(int) const
+*/
+/*!
+ \qmlsignal Camera::manualWhiteBalanceChanged(int)
+*/
+
+/*!
+ \fn void QDeclarativeCamera::captureResolutionChanged(const QSize &)
+
+ \qmlsignal Camera::captureResolutionChanged(Item)
+*/
+
+/*!
+ \fn QDeclarativeCamera::cameraStateChanged(QDeclarativeCamera::State)
+
+*/
+
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativecamera_p.cpp"
diff --git a/src/imports/multimedia/qdeclarativecamera_p.h b/src/imports/multimedia/qdeclarativecamera_p.h
new file mode 100644
index 000000000..e477538b2
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecamera_p.h
@@ -0,0 +1,302 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECAMERA_H
+#define QDECLARATIVECAMERA_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 "qgraphicsvideoitem.h"
+#include <QtCore/qbasictimer.h>
+#include <QtDeclarative/qdeclarativeitem.h>
+#include <QtCore/QTime>
+
+#include <qcamera.h>
+#include <qcameraimageprocessing.h>
+#include <qcameraimagecapture.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QTimerEvent;
+class QVideoSurfaceFormat;
+
+
+class QDeclarativeCamera : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_PROPERTY(State cameraState READ cameraState WRITE setCameraState NOTIFY cameraStateChanged)
+ Q_PROPERTY(LockStatus lockStatus READ lockStatus NOTIFY lockStatusChanged)
+ 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 maximumOpticalZoom READ maximumOpticalZoom NOTIFY maximumOpticalZoomChanged)
+ Q_PROPERTY(qreal digitalZoom READ digitalZoom WRITE setDigitalZoom NOTIFY digitalZoomChanged)
+ Q_PROPERTY(qreal maximumDigitalZoom READ maximumDigitalZoom NOTIFY maximumDigitalZoomChanged)
+
+ Q_ENUMS(State)
+ Q_ENUMS(LockStatus)
+ Q_ENUMS(Error)
+ Q_ENUMS(FlashMode)
+ Q_ENUMS(ExposureMode)
+ Q_ENUMS(WhiteBalanceMode)
+public:
+ enum State
+ {
+ ActiveState = QCamera::ActiveState,
+ LoadedState = QCamera::LoadedState,
+ UnloadedState = QCamera::UnloadedState
+ };
+
+ enum LockStatus
+ {
+ Unlocked = QCamera::Unlocked,
+ Searching = QCamera::Searching,
+ Locked = QCamera::Locked
+ };
+
+ enum Error
+ {
+ NoError = QCamera::NoError,
+ CameraError = QCamera::CameraError,
+ InvalidRequestError = QCamera::InvalidRequestError,
+ ServiceMissingError = QCamera::ServiceMissingError,
+ NotSupportedFeatureError = QCamera::NotSupportedFeatureError
+ };
+
+ enum FlashMode {
+ FlashAuto = 0x1,
+ FlashOff = 0x2,
+ FlashOn = 0x4,
+ FlashRedEyeReduction = 0x8,
+ FlashFill = 0x10,
+ FlashTorch = 0x20,
+ FlashSlowSyncFrontCurtain = 0x40,
+ FlashSlowSyncRearCurtain = 0x80,
+ FlashManual = 0x100
+ };
+
+ enum ExposureMode {
+ ExposureAuto = 0,
+ ExposureManual = 1,
+ ExposurePortrait = 2,
+ ExposureNight = 3,
+ ExposureBacklight = 4,
+ ExposureSpotlight = 5,
+ ExposureSports = 6,
+ ExposureSnow = 7,
+ ExposureBeach = 8,
+ ExposureLargeAperture = 9,
+ ExposureSmallAperture = 10,
+ ExposureModeVendor = 1000
+ };
+
+ enum WhiteBalanceMode {
+ WhiteBalanceAuto = 0,
+ WhiteBalanceManual = 1,
+ WhiteBalanceSunlight = 2,
+ WhiteBalanceCloudy = 3,
+ WhiteBalanceShade = 4,
+ WhiteBalanceTungsten = 5,
+ WhiteBalanceFluorescent = 6,
+ WhiteBalanceIncandescent = 7,
+ WhiteBalanceFlash = 8,
+ WhiteBalanceSunset = 9,
+ WhiteBalanceVendor = 1000
+ };
+
+ QDeclarativeCamera(QDeclarativeItem *parent = 0);
+ ~QDeclarativeCamera();
+
+ State cameraState() const;
+
+ Error error() const;
+ QString errorString() 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 maximumDigitalZoom() const;
+
+ qreal opticalZoom() const;
+ qreal digitalZoom() const;
+
+public Q_SLOTS:
+ void start();
+ void stop();
+
+ void setCameraState(State state);
+
+ void searchAndLock();
+ 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 setDigitalZoom(qreal);
+
+Q_SIGNALS:
+ void errorChanged();
+ void error(QDeclarativeCamera::Error error, const QString &errorString);
+
+ void cameraStateChanged(QDeclarativeCamera::State);
+
+ 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 digitalZoomChanged(qreal);
+ void maximumOpticalZoomChanged(qreal);
+ void maximumDigitalZoomChanged(qreal);
+
+protected:
+ void geometryChanged(const QRectF &geometry, const QRectF &);
+ void keyPressEvent(QKeyEvent * event);
+ void keyReleaseEvent(QKeyEvent * event);
+
+private Q_SLOTS:
+ void _q_updateState(QCamera::State);
+ void _q_nativeSizeChanged(const QSizeF &size);
+ void _q_error(int, const QString &);
+ void _q_imageCaptured(int, const QImage&);
+ void _q_imageSaved(int, const QString&);
+ void _q_captureFailed(int, QCameraImageCapture::Error, const QString&);
+ void _q_updateFocusZones();
+ void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason);
+ void _q_updateImageSettings();
+ void _q_applyPendingState();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeCamera)
+ QCamera *m_camera;
+ QGraphicsVideoItem *m_viewfinderItem;
+
+ QCameraExposure *m_exposure;
+ QCameraFocus *m_focus;
+ QCameraImageCapture *m_capture;
+
+ QImage m_capturedImagePreview;
+ QString m_capturedImagePath;
+ QList <QGraphicsItem*> m_focusZones;
+ QTime m_focusFailedTime;
+
+ QImageEncoderSettings m_imageSettings;
+ bool m_imageSettingsChanged;
+
+ State m_pendingState;
+ bool m_isStateSet;
+ bool m_isValid;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCamera))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp b/src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp
new file mode 100644
index 000000000..293120eda
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativecamerapreviewprovider_p.h"
+#include <QtCore/qmutex.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QDeclarativeCameraPreviewProviderPrivate
+{
+ QString id;
+ QImage image;
+ QMutex mutex;
+};
+
+Q_GLOBAL_STATIC(QDeclarativeCameraPreviewProviderPrivate, qDeclarativeCameraPreviewProviderPrivate)
+
+QDeclarativeCameraPreviewProvider::QDeclarativeCameraPreviewProvider()
+: QDeclarativeImageProvider(QDeclarativeImageProvider::Image)
+{
+}
+
+QDeclarativeCameraPreviewProvider::~QDeclarativeCameraPreviewProvider()
+{
+ QDeclarativeCameraPreviewProviderPrivate *d = qDeclarativeCameraPreviewProviderPrivate();
+ QMutexLocker lock(&d->mutex);
+ d->id.clear();
+ d->image = QImage();
+}
+
+QImage QDeclarativeCameraPreviewProvider::requestImage(const QString &id, QSize *size, const QSize& requestedSize)
+{
+ QDeclarativeCameraPreviewProviderPrivate *d = qDeclarativeCameraPreviewProviderPrivate();
+ QMutexLocker lock(&d->mutex);
+
+ if (d->id != id)
+ return QImage();
+
+ QImage res = d->image;
+ if (!requestedSize.isEmpty())
+ res = res.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+
+ if (size)
+ *size = res.size();
+
+ return res;
+}
+
+void QDeclarativeCameraPreviewProvider::registerPreview(const QString &id, const QImage &preview)
+{
+ //only the last preview is kept
+ QDeclarativeCameraPreviewProviderPrivate *d = qDeclarativeCameraPreviewProviderPrivate();
+ QMutexLocker lock(&d->mutex);
+ d->id = id;
+ d->image = preview;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h b/src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h
new file mode 100644
index 000000000..44a47e781
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVECAMERAPREVIEWPROVIDER_H
+#define QDECLARATIVECAMERAPREVIEWPROVIDER_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 <QtDeclarative/qdeclarativeimageprovider.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeCameraPreviewProvider : public QDeclarativeImageProvider
+{
+public:
+ QDeclarativeCameraPreviewProvider();
+ ~QDeclarativeCameraPreviewProvider();
+
+ virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize);
+ static void registerPreview(const QString &id, const QImage &preview);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativemediabase.cpp b/src/imports/multimedia/qdeclarativemediabase.cpp
new file mode 100644
index 000000000..68552ed6a
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativemediabase.cpp
@@ -0,0 +1,567 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativemediabase_p.h"
+
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qurl.h>
+#include <QtDeclarative/qdeclarativeinfo.h>
+
+#include <qmediaplayercontrol.h>
+#include <qmediaservice.h>
+#include <qmediaserviceprovider.h>
+#include <qmetadatareadercontrol.h>
+
+#include "qdeclarativemediametadata_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+class QDeclarativeMediaBaseObject : public QMediaObject
+{
+public:
+ QDeclarativeMediaBaseObject(QMediaService *service)
+ : QMediaObject(0, service)
+ {
+ }
+};
+
+class QDeclarativeMediaBasePlayerControl : public QMediaPlayerControl
+{
+public:
+ QDeclarativeMediaBasePlayerControl(QObject *parent)
+ : QMediaPlayerControl(parent)
+ {
+ }
+
+ QMediaPlayer::State state() const { return QMediaPlayer::StoppedState; }
+ QMediaPlayer::MediaStatus mediaStatus() const { return QMediaPlayer::NoMedia; }
+
+ qint64 duration() const { return 0; }
+ qint64 position() const { return 0; }
+ void setPosition(qint64) {}
+ int volume() const { return 0; }
+ void setVolume(int) {}
+ bool isMuted() const { return false; }
+ void setMuted(bool) {}
+ int bufferStatus() const { return 0; }
+ bool isAudioAvailable() const { return false; }
+ bool isVideoAvailable() const { return false; }
+ bool isSeekable() const { return false; }
+ QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
+ qreal playbackRate() const { return 1; }
+ void setPlaybackRate(qreal) {}
+ QMediaContent media() const { return QMediaContent(); }
+ const QIODevice *mediaStream() const { return 0; }
+ void setMedia(const QMediaContent &, QIODevice *) {}
+
+ void play() {}
+ void pause() {}
+ void stop() {}
+};
+
+
+class QDeclarativeMediaBaseMetaDataControl : public QMetaDataReaderControl
+{
+public:
+ QDeclarativeMediaBaseMetaDataControl(QObject *parent)
+ : QMetaDataReaderControl(parent)
+ {
+ }
+
+ bool isMetaDataAvailable() const { return false; }
+
+ QVariant metaData(QtMultimediaKit::MetaData) const { return QVariant(); }
+ QList<QtMultimediaKit::MetaData> availableMetaData() const {
+ return QList<QtMultimediaKit::MetaData>(); }
+
+ QVariant extendedMetaData(const QString &) const { return QVariant(); }
+ QStringList availableExtendedMetaData() const { return QStringList(); }
+};
+
+class QDeclarativeMediaBaseAnimation : public QObject
+{
+public:
+ QDeclarativeMediaBaseAnimation(QDeclarativeMediaBase *media)
+ : m_media(media)
+ {
+ }
+
+ void start() { if (!m_timer.isActive()) m_timer.start(500, this); }
+ void stop() { m_timer.stop(); }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() == m_timer.timerId()) {
+ event->accept();
+
+ if (m_media->m_playing && !m_media->m_paused)
+ emit m_media->positionChanged();
+ if (m_media->m_status == QMediaPlayer::BufferingMedia || QMediaPlayer::StalledMedia)
+ emit m_media->bufferProgressChanged();
+ } else {
+ QObject::timerEvent(event);
+ }
+ }
+
+private:
+ QDeclarativeMediaBase *m_media;
+ QBasicTimer m_timer;
+};
+
+void QDeclarativeMediaBase::_q_statusChanged()
+{
+ if (m_playerControl->mediaStatus() == QMediaPlayer::EndOfMedia && m_runningCount != 0) {
+ m_runningCount -= 1;
+ m_playerControl->play();
+ }
+
+ const QMediaPlayer::MediaStatus oldStatus = m_status;
+ const bool wasPlaying = m_playing;
+ const bool wasPaused = m_paused;
+
+ const QMediaPlayer::State state = m_playerControl->state();
+
+ m_status = m_playerControl->mediaStatus();
+
+ if (m_complete)
+ m_playing = state != QMediaPlayer::StoppedState;
+
+ if (state == QMediaPlayer::PausedState)
+ m_paused = true;
+ else if (state == QMediaPlayer::PlayingState)
+ m_paused = false;
+
+ if (m_status != oldStatus)
+ emit statusChanged();
+
+ switch (state) {
+ case QMediaPlayer::StoppedState:
+ if (wasPlaying) {
+ emit stopped();
+
+ if (!m_playing)
+ emit playingChanged();
+ }
+ break;
+ case QMediaPlayer::PausedState:
+ if (!wasPlaying) {
+ emit started();
+ if (m_playing)
+ emit playingChanged();
+ }
+ if ((!wasPaused || !wasPlaying) && m_paused)
+ emit paused();
+ if (!wasPaused && m_paused)
+ emit pausedChanged();
+
+ break;
+
+ case QMediaPlayer::PlayingState:
+ if (wasPaused && wasPlaying)
+ emit resumed();
+ else
+ emit started();
+
+ if (wasPaused && !m_paused)
+ emit pausedChanged();
+ if (!wasPlaying && m_playing)
+ emit playingChanged();
+ break;
+ }
+
+ // Check
+ if ((m_playing && !m_paused)
+ || m_status == QMediaPlayer::BufferingMedia
+ || m_status == QMediaPlayer::StalledMedia) {
+ m_animation->start();
+ }
+ else {
+ m_animation->stop();
+ }
+}
+
+QDeclarativeMediaBase::QDeclarativeMediaBase()
+ : m_paused(false)
+ , m_playing(false)
+ , m_autoLoad(true)
+ , m_loaded(false)
+ , m_muted(false)
+ , m_complete(false)
+ , m_loopCount(1)
+ , m_runningCount(0)
+ , m_position(0)
+ , m_vol(1.0)
+ , m_playbackRate(1.0)
+ , m_mediaService(0)
+ , m_playerControl(0)
+ , m_qmlObject(0)
+ , m_mediaObject(0)
+ , m_mediaProvider(0)
+ , m_metaDataControl(0)
+ , m_animation(0)
+ , m_status(QMediaPlayer::NoMedia)
+ , m_error(QMediaPlayer::ServiceMissingError)
+{
+}
+
+QDeclarativeMediaBase::~QDeclarativeMediaBase()
+{
+}
+
+void QDeclarativeMediaBase::shutdown()
+{
+ delete m_mediaObject;
+ m_metaData.reset();
+
+ if (m_mediaProvider)
+ m_mediaProvider->releaseService(m_mediaService);
+
+ delete m_animation;
+
+}
+
+void QDeclarativeMediaBase::setObject(QObject *object)
+{
+ m_qmlObject = object;
+
+ if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider()) != 0) {
+ if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER)) != 0) {
+ m_playerControl = qobject_cast<QMediaPlayerControl *>(
+ m_mediaService->requestControl(QMediaPlayerControl_iid));
+ m_metaDataControl = qobject_cast<QMetaDataReaderControl *>(
+ m_mediaService->requestControl(QMetaDataReaderControl_iid));
+ m_mediaObject = new QDeclarativeMediaBaseObject(m_mediaService);
+ }
+ }
+
+ if (m_playerControl) {
+ QObject::connect(m_playerControl, SIGNAL(stateChanged(QMediaPlayer::State)),
+ object, SLOT(_q_statusChanged()));
+ QObject::connect(m_playerControl, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
+ object, SLOT(_q_statusChanged()));
+ QObject::connect(m_playerControl, SIGNAL(mediaChanged(QMediaContent)),
+ object, SIGNAL(sourceChanged()));
+ QObject::connect(m_playerControl, SIGNAL(durationChanged(qint64)),
+ object, SIGNAL(durationChanged()));
+ QObject::connect(m_playerControl, SIGNAL(positionChanged(qint64)),
+ object, SIGNAL(positionChanged()));
+ QObject::connect(m_playerControl, SIGNAL(volumeChanged(int)),
+ object, SIGNAL(volumeChanged()));
+ QObject::connect(m_playerControl, SIGNAL(mutedChanged(bool)),
+ object, SIGNAL(mutedChanged()));
+ QObject::connect(m_playerControl, SIGNAL(bufferStatusChanged(int)),
+ object, SIGNAL(bufferProgressChanged()));
+ QObject::connect(m_playerControl, SIGNAL(seekableChanged(bool)),
+ object, SIGNAL(seekableChanged()));
+ QObject::connect(m_playerControl, SIGNAL(playbackRateChanged(qreal)),
+ object, SIGNAL(playbackRateChanged()));
+ QObject::connect(m_playerControl, SIGNAL(error(int,QString)),
+ object, SLOT(_q_error(int,QString)));
+
+ m_animation = new QDeclarativeMediaBaseAnimation(this);
+ m_error = QMediaPlayer::NoError;
+ } else {
+ m_playerControl = new QDeclarativeMediaBasePlayerControl(object);
+ }
+
+ if (!m_metaDataControl)
+ m_metaDataControl = new QDeclarativeMediaBaseMetaDataControl(object);
+
+ m_metaData.reset(new QDeclarativeMediaMetaData(m_metaDataControl));
+
+ QObject::connect(m_metaDataControl, SIGNAL(metaDataChanged()),
+ m_metaData.data(), SIGNAL(metaDataChanged()));
+}
+
+void QDeclarativeMediaBase::componentComplete()
+{
+ m_playerControl->setVolume(m_vol * 100);
+ m_playerControl->setMuted(m_muted);
+ m_playerControl->setPlaybackRate(m_playbackRate);
+
+ if (!m_source.isEmpty() && (m_autoLoad || m_playing)) // Override autoLoad if playing set
+ m_playerControl->setMedia(m_source, 0);
+
+ m_complete = true;
+
+ if (m_playing) {
+ if (m_position > 0)
+ m_playerControl->setPosition(m_position);
+
+ if (m_source.isEmpty()) {
+ m_playing = false;
+
+ emit playingChanged();
+ } else if (m_paused) {
+ m_playerControl->pause();
+ } else {
+ m_playerControl->play();
+ }
+ }
+}
+
+// Properties
+
+QUrl QDeclarativeMediaBase::source() const
+{
+ return m_source;
+}
+
+void QDeclarativeMediaBase::setSource(const QUrl &url)
+{
+ if (url == m_source)
+ return;
+
+ m_source = url;
+ m_loaded = false;
+ if (m_complete && (m_autoLoad || url.isEmpty())) {
+ if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
+ m_error = QMediaPlayer::NoError;
+ m_errorString = QString();
+
+ emit errorChanged();
+ }
+
+ m_playerControl->setMedia(m_source, 0);
+ m_loaded = true;
+ }
+ else
+ emit sourceChanged();
+}
+
+bool QDeclarativeMediaBase::isAutoLoad() const
+{
+ return m_autoLoad;
+}
+
+void QDeclarativeMediaBase::setAutoLoad(bool autoLoad)
+{
+ if (m_autoLoad == autoLoad)
+ return;
+
+ m_autoLoad = autoLoad;
+ emit autoLoadChanged();
+}
+
+int QDeclarativeMediaBase::loopCount() const
+{
+ return m_loopCount;
+}
+
+void QDeclarativeMediaBase::setLoopCount(int loopCount)
+{
+ if (loopCount == 0)
+ loopCount = 1;
+ else if (loopCount < -1)
+ loopCount = -1;
+
+ if (m_loopCount == loopCount) {
+ return;
+ }
+ m_loopCount = loopCount;
+ emit loopCountChanged();
+}
+
+bool QDeclarativeMediaBase::isPlaying() const
+{
+ return m_playing;
+}
+
+void QDeclarativeMediaBase::setPlaying(bool playing)
+{
+ if (playing == m_playing)
+ return;
+
+ if (m_complete) {
+ if (playing) {
+ if (!m_autoLoad && !m_loaded) {
+ m_playerControl->setMedia(m_source, 0);
+ m_playerControl->setPosition(m_position);
+ m_loaded = true;
+ }
+
+ m_runningCount = m_loopCount - 1;
+
+ if (!m_paused)
+ m_playerControl->play();
+ else
+ m_playerControl->pause();
+ } else {
+ m_playerControl->stop();
+ }
+ } else {
+ m_playing = playing;
+ emit playingChanged();
+ }
+}
+
+bool QDeclarativeMediaBase::isPaused() const
+{
+ return m_paused;
+}
+
+void QDeclarativeMediaBase::setPaused(bool paused)
+{
+ if (m_paused == paused)
+ return;
+
+ if (m_complete && m_playing) {
+ if (!m_autoLoad && !m_loaded) {
+ m_playerControl->setMedia(m_source, 0);
+ m_playerControl->setPosition(m_position);
+ m_loaded = true;
+ }
+
+ if (!paused)
+ m_playerControl->play();
+ else
+ m_playerControl->pause();
+ } else {
+ m_paused = paused;
+ emit pausedChanged();
+ }
+}
+
+int QDeclarativeMediaBase::duration() const
+{
+ return !m_complete ? 0 : m_playerControl->duration();
+}
+
+int QDeclarativeMediaBase::position() const
+{
+ return !m_complete ? m_position : m_playerControl->position();
+}
+
+void QDeclarativeMediaBase::setPosition(int position)
+{
+ if (this->position() == position)
+ return;
+
+ m_position = position;
+ if (m_complete)
+ m_playerControl->setPosition(m_position);
+ else
+ emit positionChanged();
+}
+
+qreal QDeclarativeMediaBase::volume() const
+{
+ return !m_complete ? m_vol : qreal(m_playerControl->volume()) / 100;
+}
+
+void QDeclarativeMediaBase::setVolume(qreal volume)
+{
+ if (volume < 0 || volume > 1) {
+ qmlInfo(m_qmlObject) << m_qmlObject->tr("volume should be between 0.0 and 1.0");
+ return;
+ }
+
+ if (m_vol == volume)
+ return;
+
+ m_vol = volume;
+
+ if (m_complete)
+ m_playerControl->setVolume(qRound(volume * 100));
+ else
+ emit volumeChanged();
+}
+
+bool QDeclarativeMediaBase::isMuted() const
+{
+ return !m_complete ? m_muted : m_playerControl->isMuted();
+}
+
+void QDeclarativeMediaBase::setMuted(bool muted)
+{
+ if (m_muted == muted)
+ return;
+
+ m_muted = muted;
+
+ if (m_complete)
+ m_playerControl->setMuted(muted);
+ else
+ emit mutedChanged();
+}
+
+qreal QDeclarativeMediaBase::bufferProgress() const
+{
+ return !m_complete ? 0 : qreal(m_playerControl->bufferStatus()) / 100;
+}
+
+bool QDeclarativeMediaBase::isSeekable() const
+{
+ return !m_complete ? false : m_playerControl->isSeekable();
+}
+
+qreal QDeclarativeMediaBase::playbackRate() const
+{
+ return m_playbackRate;
+}
+
+void QDeclarativeMediaBase::setPlaybackRate(qreal rate)
+{
+ if (m_playbackRate == rate)
+ return;
+
+ m_playbackRate = rate;
+
+ if (m_complete)
+ m_playerControl->setPlaybackRate(m_playbackRate);
+ else
+ emit playbackRateChanged();
+}
+
+QString QDeclarativeMediaBase::errorString() const
+{
+ return m_errorString;
+}
+
+QDeclarativeMediaMetaData *QDeclarativeMediaBase::metaData() const
+{
+ return m_metaData.data();
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/imports/multimedia/qdeclarativemediabase_p.h b/src/imports/multimedia/qdeclarativemediabase_p.h
new file mode 100644
index 000000000..ffe091614
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativemediabase_p.h
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMEDIABASE_P_H
+#define QDECLARATIVEMEDIABASE_P_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/qbasictimer.h>
+#include <qmediaplayer.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QMediaPlayerControl;
+class QMediaService;
+class QMediaServiceProvider;
+class QMetaDataReaderControl;
+class QDeclarativeMediaBaseAnimation;
+class QDeclarativeMediaMetaData;
+
+class QDeclarativeMediaBase
+{
+public:
+ enum Loop {
+ INFINITE = -1
+ };
+
+ QDeclarativeMediaBase();
+ virtual ~QDeclarativeMediaBase();
+
+ QUrl source() const;
+ void setSource(const QUrl &url);
+
+ bool isAutoLoad() const;
+ void setAutoLoad(bool autoLoad);
+
+ int loopCount() const;
+ void setLoopCount(int loopCount);
+
+ bool isPlaying() const;
+ void setPlaying(bool playing);
+
+ bool isPaused() const;
+ void setPaused(bool paused);
+
+ int duration() const;
+
+ int position() const;
+ void setPosition(int position);
+
+ qreal volume() const;
+ void setVolume(qreal volume);
+
+ bool isMuted() const;
+ void setMuted(bool muted);
+
+ qreal bufferProgress() const;
+
+ bool isSeekable() const;
+
+ qreal playbackRate() const;
+ void setPlaybackRate(qreal rate);
+
+ QString errorString() const;
+
+ QDeclarativeMediaMetaData *metaData() const;
+
+ void _q_statusChanged();
+
+ void _q_metaDataChanged();
+
+ void componentComplete();
+
+protected:
+ void shutdown();
+
+ void setObject(QObject *object);
+
+ virtual void sourceChanged() = 0;
+ virtual void autoLoadChanged() = 0;
+ virtual void playingChanged() = 0;
+ virtual void pausedChanged() = 0;
+ virtual void loopCountChanged() = 0;
+
+ virtual void started() = 0;
+ virtual void resumed() = 0;
+ virtual void paused() = 0;
+ virtual void stopped() = 0;
+
+ virtual void statusChanged() = 0;
+
+ virtual void durationChanged() = 0;
+ virtual void positionChanged() = 0;
+
+ virtual void volumeChanged() = 0;
+ virtual void mutedChanged() = 0;
+
+ virtual void bufferProgressChanged() = 0;
+
+ virtual void seekableChanged() = 0;
+ virtual void playbackRateChanged() = 0;
+
+ virtual void errorChanged() = 0;
+
+ bool m_paused;
+ bool m_playing;
+ bool m_autoLoad;
+ bool m_loaded;
+ bool m_muted;
+ bool m_complete;
+ int m_loopCount;
+ int m_runningCount;
+ int m_position;
+ qreal m_vol;
+ qreal m_playbackRate;
+ QMediaService *m_mediaService;
+ QMediaPlayerControl *m_playerControl;
+
+ QObject *m_qmlObject;
+ QMediaObject *m_mediaObject;
+ QMediaServiceProvider *m_mediaProvider;
+ QMetaDataReaderControl *m_metaDataControl;
+ QDeclarativeMediaBaseAnimation *m_animation;
+ QScopedPointer<QDeclarativeMediaMetaData> m_metaData;
+
+ QMediaPlayer::MediaStatus m_status;
+ QMediaPlayer::Error m_error;
+ QString m_errorString;
+ QUrl m_source;
+
+ friend class QDeclarativeMediaBaseAnimation;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativemediametadata_p.h b/src/imports/multimedia/qdeclarativemediametadata_p.h
new file mode 100644
index 000000000..ca28e6e07
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativemediametadata_p.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMEDIAMETADATA_P_H
+#define QDECLARATIVEMEDIAMETADATA_P_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 <qmetadatareadercontrol.h>
+
+#include <qdeclarative.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeMediaMetaData : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QVariant title READ title NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant subTitle READ subTitle NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant author READ author NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant comment READ comment NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant description READ description NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant category READ category NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant genre READ genre NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant year READ year NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant date READ date NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant userRating READ userRating NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant keywords READ keywords NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant language READ language NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant publisher READ publisher NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant copyright READ copyright NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant parentalRating READ parentalRating NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant ratingOrganisation READ ratingOrganisation NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant size READ size NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant mediaType READ mediaType NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant duration READ duration NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant audioBitRate READ audioBitRate NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant audioCodec READ audioCodec NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant averageLevel READ averageLevel NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant channelCount READ channelCount NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant peakValue READ peakValue NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant sampleRate READ sampleRate NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant albumTitle READ albumTitle NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant albumArtist READ albumArtist NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant contributingArtist READ contributingArtist NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant composer READ composer NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant conductor READ conductor NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant lyrics READ lyrics NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant mood READ mood NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant trackNumber READ trackNumber NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant trackCount READ trackCount NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant coverArtUrlSmall READ coverArtUrlSmall NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant coverArtUrlLarge READ coverArtUrlLarge NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant resolution READ resolution NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant pixelAspectRatio READ pixelAspectRatio NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant videoFrameRate READ videoFrameRate NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant videoBitRate READ videoBitRate NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant videoCodec READ videoCodec NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant posterUrl READ posterUrl NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant chapterNumber READ chapterNumber NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant director READ director NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant leadPerformer READ leadPerformer NOTIFY metaDataChanged)
+ Q_PROPERTY(QVariant writer READ writer NOTIFY metaDataChanged)
+public:
+ QDeclarativeMediaMetaData(QMetaDataReaderControl *control, QObject *parent = 0)
+ : QObject(parent)
+ , m_control(control)
+ {
+ }
+
+ QVariant title() const { return m_control->metaData(QtMultimediaKit::Title); }
+ QVariant subTitle() const { return m_control->metaData(QtMultimediaKit::SubTitle); }
+ QVariant author() const { return m_control->metaData(QtMultimediaKit::Author); }
+ QVariant comment() const { return m_control->metaData(QtMultimediaKit::Comment); }
+ QVariant description() const { return m_control->metaData(QtMultimediaKit::Description); }
+ QVariant category() const { return m_control->metaData(QtMultimediaKit::Category); }
+ QVariant genre() const { return m_control->metaData(QtMultimediaKit::Genre); }
+ QVariant year() const { return m_control->metaData(QtMultimediaKit::Year); }
+ QVariant date() const { return m_control->metaData(QtMultimediaKit::Date); }
+ QVariant userRating() const { return m_control->metaData(QtMultimediaKit::UserRating); }
+ QVariant keywords() const { return m_control->metaData(QtMultimediaKit::Keywords); }
+ QVariant language() const { return m_control->metaData(QtMultimediaKit::Language); }
+ QVariant publisher() const { return m_control->metaData(QtMultimediaKit::Publisher); }
+ QVariant copyright() const { return m_control->metaData(QtMultimediaKit::Copyright); }
+ QVariant parentalRating() const { return m_control->metaData(QtMultimediaKit::ParentalRating); }
+ QVariant ratingOrganisation() const {
+ return m_control->metaData(QtMultimediaKit::RatingOrganisation); }
+ QVariant size() const { return m_control->metaData(QtMultimediaKit::Size); }
+ QVariant mediaType() const { return m_control->metaData(QtMultimediaKit::MediaType); }
+ QVariant duration() const { return m_control->metaData(QtMultimediaKit::Duration); }
+ QVariant audioBitRate() const { return m_control->metaData(QtMultimediaKit::AudioBitRate); }
+ QVariant audioCodec() const { return m_control->metaData(QtMultimediaKit::AudioCodec); }
+ QVariant averageLevel() const { return m_control->metaData(QtMultimediaKit::AverageLevel); }
+ QVariant channelCount() const { return m_control->metaData(QtMultimediaKit::ChannelCount); }
+ QVariant peakValue() const { return m_control->metaData(QtMultimediaKit::PeakValue); }
+ QVariant sampleRate() const { return m_control->metaData(QtMultimediaKit::SampleRate); }
+ QVariant albumTitle() const { return m_control->metaData(QtMultimediaKit::AlbumTitle); }
+ QVariant albumArtist() const { return m_control->metaData(QtMultimediaKit::AlbumArtist); }
+ QVariant contributingArtist() const {
+ return m_control->metaData(QtMultimediaKit::ContributingArtist); }
+ QVariant composer() const { return m_control->metaData(QtMultimediaKit::Composer); }
+ QVariant conductor() const { return m_control->metaData(QtMultimediaKit::Conductor); }
+ QVariant lyrics() const { return m_control->metaData(QtMultimediaKit::Lyrics); }
+ QVariant mood() const { return m_control->metaData(QtMultimediaKit::Mood); }
+ QVariant trackNumber() const { return m_control->metaData(QtMultimediaKit::TrackNumber); }
+ QVariant trackCount() const { return m_control->metaData(QtMultimediaKit::TrackCount); }
+ QVariant coverArtUrlSmall() const {
+ return m_control->metaData(QtMultimediaKit::CoverArtUrlSmall); }
+ QVariant coverArtUrlLarge() const {
+ return m_control->metaData(QtMultimediaKit::CoverArtUrlLarge); }
+ QVariant resolution() const { return m_control->metaData(QtMultimediaKit::Resolution); }
+ QVariant pixelAspectRatio() const {
+ return m_control->metaData(QtMultimediaKit::PixelAspectRatio); }
+ QVariant videoFrameRate() const { return m_control->metaData(QtMultimediaKit::VideoFrameRate); }
+ QVariant videoBitRate() const { return m_control->metaData(QtMultimediaKit::VideoBitRate); }
+ QVariant videoCodec() const { return m_control->metaData(QtMultimediaKit::VideoCodec); }
+ QVariant posterUrl() const { return m_control->metaData(QtMultimediaKit::PosterUrl); }
+ QVariant chapterNumber() const { return m_control->metaData(QtMultimediaKit::ChapterNumber); }
+ QVariant director() const { return m_control->metaData(QtMultimediaKit::Director); }
+ QVariant leadPerformer() const { return m_control->metaData(QtMultimediaKit::LeadPerformer); }
+ QVariant writer() const { return m_control->metaData(QtMultimediaKit::Writer); }
+
+Q_SIGNALS:
+ void metaDataChanged();
+
+private:
+ QMetaDataReaderControl *m_control;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeMediaMetaData))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp
new file mode 100644
index 000000000..af87fe1bd
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativevideo.cpp
@@ -0,0 +1,951 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativevideo_p.h"
+
+#include <qmediaplayercontrol.h>
+#include <qmediaservice.h>
+#include <private/qpaintervideosurface_p.h>
+#include <qvideorenderercontrol.h>
+
+
+QT_BEGIN_NAMESPACE
+
+
+void QDeclarativeVideo::_q_nativeSizeChanged(const QSizeF &size)
+{
+ setImplicitWidth(size.width());
+ setImplicitHeight(size.height());
+}
+
+void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString)
+{
+ m_error = QMediaPlayer::Error(errorCode);
+ m_errorString = errorString;
+
+ emit error(Error(errorCode), errorString);
+ emit errorChanged();
+}
+
+
+/*!
+ \qmlclass Video QDeclarativeVideo
+ \brief The Video element allows you to add videos to a scene.
+ \inherits Item
+ \ingroup qml-multimedia
+
+ This element is part of the \bold{QtMultimediaKit 1.1} module.
+
+ \qml
+ import Qt 4.7
+ import QtMultimediaKit 1.1
+
+ Video {
+ id: video
+ width : 800
+ height : 600
+ source: "video.avi"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ video.play()
+ }
+ }
+
+ focus: true
+ Keys.onSpacePressed: video.paused = !video.paused
+ Keys.onLeftPressed: video.position -= 5000
+ Keys.onRightPressed: video.position += 5000
+ }
+ \endqml
+
+ The Video item supports untransformed, stretched, and uniformly scaled video presentation.
+ For a description of stretched uniformly scaled presentation, see the \l fillMode property
+ description.
+
+ The Video item is only visible when the \l hasVideo property is true and the video is playing.
+
+ \sa Audio
+*/
+
+/*!
+ \internal
+ \class QDeclarativeVideo
+ \brief The QDeclarativeVideo class provides a video item that you can add to a QDeclarativeView.
+*/
+
+QDeclarativeVideo::QDeclarativeVideo(QDeclarativeItem *parent)
+ : QDeclarativeItem(parent)
+ , m_graphicsItem(0)
+
+{
+}
+
+QDeclarativeVideo::~QDeclarativeVideo()
+{
+ shutdown();
+
+ delete m_graphicsItem;
+}
+
+/*!
+ \qmlproperty url Video::source
+
+ This property holds the source URL of the media.
+*/
+
+/*!
+ \qmlproperty url Video::autoLoad
+
+ This property indicates if loading of media should begin immediately.
+
+ Defaults to true, if false media will not be loaded until playback is started.
+*/
+
+/*!
+ \qmlproperty bool Video::playing
+
+ This property holds whether the media is playing.
+
+ Defaults to false, and can be set to true to start playback.
+*/
+
+/*!
+ \qmlproperty bool Video::paused
+
+ This property holds whether the media is paused.
+
+ Defaults to false, and can be set to true to pause playback.
+*/
+
+/*!
+ \qmlsignal Video::onStarted()
+
+ This handler is called when playback is started.
+*/
+
+/*!
+ \qmlsignal Video::onResumed()
+
+ This handler is called when playback is resumed from the paused state.
+*/
+
+/*!
+ \qmlsignal Video::onPaused()
+
+ This handler is called when playback is paused.
+*/
+
+/*!
+ \qmlsignal Video::onStopped()
+
+ This handler is called when playback is stopped.
+*/
+
+/*!
+ \qmlproperty enumeration Video::status
+
+ This property holds the status of media loading. It can be one of:
+
+ \list
+ \o NoMedia - no media has been set.
+ \o Loading - the media is currently being loaded.
+ \o Loaded - the media has been loaded.
+ \o Buffering - the media is buffering data.
+ \o Stalled - playback has been interrupted while the media is buffering data.
+ \o Buffered - the media has buffered data.
+ \o EndOfMedia - the media has played to the end.
+ \o InvalidMedia - the media cannot be played.
+ \o UnknownStatus - the status of the media is cannot be determined.
+ \endlist
+*/
+
+QDeclarativeVideo::Status QDeclarativeVideo::status() const
+{
+ return Status(m_status);
+}
+
+/*!
+ \qmlproperty int Video::duration
+
+ This property holds the duration of the media in milliseconds.
+
+ If the media doesn't have a fixed duration (a live stream for example) this will be 0.
+*/
+
+/*!
+ \qmlproperty int Video::position
+
+ This property holds the current playback position in milliseconds.
+*/
+
+/*!
+ \qmlproperty real Video::volume
+
+ This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
+*/
+
+/*!
+ \qmlproperty bool Video::muted
+
+ This property holds whether the audio output is muted.
+*/
+
+/*!
+ \qmlproperty bool Video::hasAudio
+
+ This property holds whether the media contains audio.
+*/
+
+bool QDeclarativeVideo::hasAudio() const
+{
+ return !m_complete ? false : m_playerControl->isAudioAvailable();
+}
+
+/*!
+ \qmlproperty bool Video::hasVideo
+
+ This property holds whether the media contains video.
+*/
+
+bool QDeclarativeVideo::hasVideo() const
+{
+ return !m_complete ? false : m_playerControl->isVideoAvailable();
+}
+
+/*!
+ \qmlproperty real Video::bufferProgress
+
+ This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0
+ (full).
+*/
+
+/*!
+ \qmlproperty bool Video::seekable
+
+ This property holds whether position of the video can be changed.
+*/
+
+/*!
+ \qmlproperty real Video::playbackRate
+
+ This property holds the rate at which video is played at as a multiple of the normal rate.
+*/
+
+/*!
+ \qmlproperty enumeration Video::error
+
+ This property holds the error state of the video. It can be one of:
+
+ \list
+ \o NoError - there is no current error.
+ \o ResourceError - the video cannot be played due to a problem allocating resources.
+ \o FormatError - the video format is not supported.
+ \o NetworkError - the video cannot be played due to network issues.
+ \o AccessDenied - the video cannot be played due to insufficient permissions.
+ \o ServiceMissing - the video cannot be played because the media service could not be
+ instantiated.
+ \endlist
+*/
+
+
+QDeclarativeVideo::Error QDeclarativeVideo::error() const
+{
+ return Error(m_error);
+}
+
+/*!
+ \qmlproperty string Video::errorString
+
+ This property holds a string describing the current error condition in more detail.
+*/
+
+/*!
+ \qmlsignal Video::onError(error, errorString)
+
+ This handler is called when an \l {QMediaPlayer::Error}{error} has
+ occurred. The errorString parameter may contain more detailed
+ information about the error.
+*/
+
+/*!
+ \qmlproperty enumeration Video::fillMode
+
+ Set this property to define how the video is scaled to fit the target area.
+
+ \list
+ \o Stretch - the video is scaled to fit.
+ \o PreserveAspectFit - the video is scaled uniformly to fit without cropping
+ \o PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary
+ \endlist
+
+ The default fill mode is PreserveAspectFit.
+*/
+
+QDeclarativeVideo::FillMode QDeclarativeVideo::fillMode() const
+{
+ return FillMode(m_graphicsItem->aspectRatioMode());
+}
+
+void QDeclarativeVideo::setFillMode(FillMode mode)
+{
+ m_graphicsItem->setAspectRatioMode(Qt::AspectRatioMode(mode));
+}
+
+/*!
+ \qmlmethod Video::play()
+
+ Starts playback of the media.
+
+ Sets the \l playing property to true, and the \l paused property to false.
+*/
+
+void QDeclarativeVideo::play()
+{
+ if (!m_complete)
+ return;
+
+ setPaused(false);
+ setPlaying(true);
+}
+
+/*!
+ \qmlmethod Video::pause()
+
+ Pauses playback of the media.
+
+ Sets the \l playing and \l paused properties to true.
+*/
+
+void QDeclarativeVideo::pause()
+{
+ if (!m_complete)
+ return;
+
+ setPaused(true);
+ setPlaying(true);
+}
+
+/*!
+ \qmlmethod Video::stop()
+
+ Stops playback of the media.
+
+ Sets the \l playing and \l paused properties to false.
+*/
+
+void QDeclarativeVideo::stop()
+{
+ if (!m_complete)
+ return;
+
+ setPlaying(false);
+ setPaused(false);
+}
+
+void QDeclarativeVideo::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+{
+}
+
+void QDeclarativeVideo::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ m_graphicsItem->setSize(newGeometry.size());
+
+ QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+void QDeclarativeVideo::classBegin()
+{
+ m_graphicsItem = new QGraphicsVideoItem(this);
+ connect(m_graphicsItem, SIGNAL(nativeSizeChanged(QSizeF)),
+ this, SLOT(_q_nativeSizeChanged(QSizeF)));
+
+ setObject(this);
+
+ if (m_mediaService) {
+ connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)),
+ this, SIGNAL(hasAudioChanged()));
+ connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)),
+ this, SIGNAL(hasVideoChanged()));
+
+ m_mediaObject->bind(m_graphicsItem);
+ }
+}
+
+void QDeclarativeVideo::componentComplete()
+{
+ QDeclarativeMediaBase::componentComplete();
+}
+
+QT_END_NAMESPACE
+
+// ***************************************
+// Documentation for meta-data properties.
+// ***************************************
+
+/*!
+ \qmlproperty variant Video::metaData.title
+
+ This property holds the tile of the media.
+
+ \sa {QtMultimediaKit::Title}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.subTitle
+
+ This property holds the sub-title of the media.
+
+ \sa {QtMultimediaKit::SubTitle}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.author
+
+ This property holds the author of the media.
+
+ \sa {QtMultimediaKit::Author}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.comment
+
+ This property holds a user comment about the media.
+
+ \sa {QtMultimediaKit::Comment}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.description
+
+ This property holds a description of the media.
+
+ \sa {QtMultimediaKit::Description}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.category
+
+ This property holds the category of the media
+
+ \sa {QtMultimediaKit::Category}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.genre
+
+ This property holds the genre of the media.
+
+ \sa {QtMultimediaKit::Genre}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.year
+
+ This property holds the year of release of the media.
+
+ \sa {QtMultimediaKit::Year}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.date
+
+ This property holds the date of the media.
+
+ \sa {QtMultimediaKit::Date}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.userRating
+
+ This property holds a user rating of the media in the range of 0 to 100.
+
+ \sa {QtMultimediaKit::UserRating}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.keywords
+
+ This property holds a list of keywords describing the media.
+
+ \sa {QtMultimediaKit::Keywords}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.language
+
+ This property holds the language of the media, as an ISO 639-2 code.
+
+ \sa {QtMultimediaKit::Language}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.publisher
+
+ This property holds the publisher of the media.
+
+ \sa {QtMultimediaKit::Publisher}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.copyright
+
+ This property holds the media's copyright notice.
+
+ \sa {QtMultimediaKit::Copyright}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.parentalRating
+
+ This property holds the parental rating of the media.
+
+ \sa {QtMultimediaKit::ParentalRating}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.ratingOrganisation
+
+ This property holds the name of the rating organisation responsible for the
+ parental rating of the media.
+
+ \sa {QtMultimediaKit::RatingOrganisation}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.size
+
+ This property property holds the size of the media in bytes.
+
+ \sa {QtMultimediaKit::Size}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.mediaType
+
+ This property holds the type of the media.
+
+ \sa {QtMultimediaKit::MediaType}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.audioBitRate
+
+ This property holds the bit rate of the media's audio stream ni bits per
+ second.
+
+ \sa {QtMultimediaKit::AudioBitRate}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.audioCodec
+
+ This property holds the encoding of the media audio stream.
+
+ \sa {QtMultimediaKit::AudioCodec}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.averageLevel
+
+ This property holds the average volume level of the media.
+
+ \sa {QtMultimediaKit::AverageLevel}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.channelCount
+
+ This property holds the number of channels in the media's audio stream.
+
+ \sa {QtMultimediaKit::ChannelCount}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.peakValue
+
+ This property holds the peak volume of media's audio stream.
+
+ \sa {QtMultimediaKit::PeakValue}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.sampleRate
+
+ This property holds the sample rate of the media's audio stream in hertz.
+
+ \sa {QtMultimediaKit::SampleRate}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.albumTitle
+
+ This property holds the title of the album the media belongs to.
+
+ \sa {QtMultimediaKit::AlbumTitle}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.albumArtist
+
+ This property holds the name of the principal artist of the album the media
+ belongs to.
+
+ \sa {QtMultimediaKit::AlbumArtist}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.contributingArtist
+
+ This property holds the names of artists contributing to the media.
+
+ \sa {QtMultimediaKit::ContributingArtist}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.composer
+
+ This property holds the composer of the media.
+
+ \sa {QtMultimediaKit::Composer}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.conductor
+
+ This property holds the conductor of the media.
+
+ \sa {QtMultimediaKit::Conductor}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.lyrics
+
+ This property holds the lyrics to the media.
+
+ \sa {QtMultimediaKit::Lyrics}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.mood
+
+ This property holds the mood of the media.
+
+ \sa {QtMultimediaKit::Mood}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.trackNumber
+
+ This property holds the track number of the media.
+
+ \sa {QtMultimediaKit::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.trackCount
+
+ This property holds the number of track on the album containing the media.
+
+ \sa {QtMultimediaKit::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.coverArtUrlSmall
+
+ This property holds the URL of a small cover art image.
+
+ \sa {QtMultimediaKit::CoverArtUrlSmall}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.coverArtUrlLarge
+
+ This property holds the URL of a large cover art image.
+
+ \sa {QtMultimediaKit::CoverArtUrlLarge}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.resolution
+
+ This property holds the dimension of an image or video.
+
+ \sa {QtMultimediaKit::Resolution}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.pixelAspectRatio
+
+ This property holds the pixel aspect ratio of an image or video.
+
+ \sa {QtMultimediaKit::PixelAspectRatio}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.videoFrameRate
+
+ This property holds the frame rate of the media's video stream.
+
+ \sa {QtMultimediaKit::VideoFrameRate}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.videoBitRate
+
+ This property holds the bit rate of the media's video stream in bits per
+ second.
+
+ \sa {QtMultimediaKit::VideoBitRate}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.videoCodec
+
+ This property holds the encoding of the media's video stream.
+
+ \sa {QtMultimediaKit::VideoCodec}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.posterUrl
+
+ This property holds the URL of a poster image.
+
+ \sa {QtMultimediaKit::PosterUrl}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.chapterNumber
+
+ This property holds the chapter number of the media.
+
+ \sa {QtMultimediaKit::ChapterNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.director
+
+ This property holds the director of the media.
+
+ \sa {QtMultimediaKit::Director}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.leadPerformer
+
+ This property holds the lead performer in the media.
+
+ \sa {QtMultimediaKit::LeadPerformer}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.writer
+
+ This property holds the writer of the media.
+
+ \sa {QtMultimediaKit::Writer}
+*/
+
+// The remaining properties are related to photos, and are technically
+// available but will certainly never have values.
+#ifndef Q_QDOC
+
+/*!
+ \qmlproperty variant Video::metaData.cameraManufacturer
+
+ \sa {QtMultimediaKit::CameraManufacturer}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.cameraModel
+
+ \sa {QtMultimediaKit::CameraModel}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.event
+
+ \sa {QtMultimediaKit::Event}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.subject
+
+ \sa {QtMultimediaKit::Subject}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.orientation
+
+ \sa {QtMultimediaKit::Orientation}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.exposureTime
+
+ \sa {QtMultimediaKit::ExposureTime}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.fNumber
+
+ \sa {QtMultimediaKit::FNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.exposureProgram
+
+ \sa {QtMultimediaKit::ExposureProgram}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.isoSpeedRatings
+
+ \sa {QtMultimediaKit::ISOSpeedRatings}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.exposureBiasValue
+
+ \sa {QtMultimediaKit::ExposureBiasValue}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.dateTimeDigitized
+
+ \sa {QtMultimediaKit::DateTimeDigitized}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.subjectDistance
+
+ \sa {QtMultimediaKit::SubjectDistance}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.meteringMode
+
+ \sa {QtMultimediaKit::MeteringMode}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.lightSource
+
+ \sa {QtMultimediaKit::LightSource}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.flash
+
+ \sa {QtMultimediaKit::Flash}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.focalLength
+
+ \sa {QtMultimediaKit::FocalLength}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.exposureMode
+
+ \sa {QtMultimediaKit::ExposureMode}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.whiteBalance
+
+ \sa {QtMultimediaKit::WhiteBalance}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.DigitalZoomRatio
+
+ \sa {QtMultimediaKit::DigitalZoomRatio}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.focalLengthIn35mmFilm
+
+ \sa {QtMultimediaKit::FocalLengthIn35mmFile}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.sceneCaptureType
+
+ \sa {QtMultimediaKit::SceneCaptureType}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.gainControl
+
+ \sa {QtMultimediaKit::GainControl}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.contrast
+
+ \sa {QtMultimediaKit::contrast}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.saturation
+
+ \sa {QtMultimediaKit::Saturation}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.sharpness
+
+ \sa {QtMultimediaKit::Sharpness}
+*/
+
+/*!
+ \qmlproperty variant Video::metaData.deviceSettingDescription
+
+ \sa {QtMultimediaKit::DeviceSettingDescription}
+*/
+
+#endif
+
+#include "moc_qdeclarativevideo_p.cpp"
diff --git a/src/imports/multimedia/qdeclarativevideo_p.h b/src/imports/multimedia/qdeclarativevideo_p.h
new file mode 100644
index 000000000..115ef9d10
--- /dev/null
+++ b/src/imports/multimedia/qdeclarativevideo_p.h
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEVIDEO_H
+#define QDECLARATIVEVIDEO_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 "qdeclarativemediabase_p.h"
+
+#include <qgraphicsvideoitem.h>
+
+#include <QtCore/qbasictimer.h>
+#include <QtDeclarative/qdeclarativeitem.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QTimerEvent;
+class QVideoSurfaceFormat;
+
+
+class QDeclarativeVideo : public QDeclarativeItem, public QDeclarativeMediaBase
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged)
+ Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
+ Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
+ Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
+ Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
+ Q_PROPERTY(bool hasAudio READ hasAudio NOTIFY hasAudioChanged)
+ Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
+ Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
+ Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
+ Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
+ Q_PROPERTY(Error error READ error NOTIFY errorChanged)
+ Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
+ Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode)
+ Q_PROPERTY(QDeclarativeMediaMetaData *metaData READ metaData CONSTANT)
+ Q_ENUMS(FillMode)
+ Q_ENUMS(Status)
+ Q_ENUMS(Error)
+public:
+ enum FillMode
+ {
+ Stretch = Qt::IgnoreAspectRatio,
+ PreserveAspectFit = Qt::KeepAspectRatio,
+ PreserveAspectCrop = Qt::KeepAspectRatioByExpanding
+ };
+
+ enum Status
+ {
+ UnknownStatus = QMediaPlayer::UnknownMediaStatus,
+ NoMedia = QMediaPlayer::NoMedia,
+ Loading = QMediaPlayer::LoadingMedia,
+ Loaded = QMediaPlayer::LoadedMedia,
+ Stalled = QMediaPlayer::StalledMedia,
+ Buffering = QMediaPlayer::BufferingMedia,
+ Buffered = QMediaPlayer::BufferedMedia,
+ EndOfMedia = QMediaPlayer::EndOfMedia,
+ InvalidMedia = QMediaPlayer::InvalidMedia
+ };
+
+ enum Error
+ {
+ NoError = QMediaPlayer::NoError,
+ ResourceError = QMediaPlayer::ResourceError,
+ FormatError = QMediaPlayer::FormatError,
+ NetworkError = QMediaPlayer::NetworkError,
+ AccessDenied = QMediaPlayer::AccessDeniedError,
+ ServiceMissing = QMediaPlayer::ServiceMissingError
+ };
+
+ QDeclarativeVideo(QDeclarativeItem *parent = 0);
+ ~QDeclarativeVideo();
+
+ bool hasAudio() const;
+ bool hasVideo() const;
+
+ FillMode fillMode() const;
+ void setFillMode(FillMode mode);
+
+ Status status() const;
+ Error error() const;
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+ void classBegin();
+ void componentComplete();
+
+public Q_SLOTS:
+ void play();
+ void pause();
+ void stop();
+
+Q_SIGNALS:
+ void sourceChanged();
+ void autoLoadChanged();
+ void playingChanged();
+ void pausedChanged();
+ void loopCountChanged();
+
+ void started();
+ void resumed();
+ void paused();
+ void stopped();
+
+ void statusChanged();
+
+ void durationChanged();
+ void positionChanged();
+
+ void volumeChanged();
+ void mutedChanged();
+ void hasAudioChanged();
+ void hasVideoChanged();
+
+ void bufferProgressChanged();
+
+ void seekableChanged();
+ void playbackRateChanged();
+
+ void errorChanged();
+ void error(QDeclarativeVideo::Error error, const QString &errorString);
+
+protected:
+ void geometryChanged(const QRectF &geometry, const QRectF &);
+
+private Q_SLOTS:
+ void _q_nativeSizeChanged(const QSizeF &size);
+ void _q_error(int, const QString &);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeVideo)
+
+ QGraphicsVideoItem *m_graphicsItem;
+
+ Q_PRIVATE_SLOT(mediaBase(), void _q_statusChanged())
+
+ inline QDeclarativeMediaBase *mediaBase() { return this; }
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeVideo))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir
new file mode 100644
index 000000000..91caabad1
--- /dev/null
+++ b/src/imports/multimedia/qmldir
@@ -0,0 +1 @@
+plugin declarative_multimedia
diff --git a/src/imports/qimportbase.pri b/src/imports/qimportbase.pri
new file mode 100644
index 000000000..405af24ec
--- /dev/null
+++ b/src/imports/qimportbase.pri
@@ -0,0 +1,38 @@
+load(qt_module)
+
+symbian:load(qt_plugin)
+TEMPLATE = lib
+CONFIG += qt plugin
+
+win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release
+
+isEmpty(TARGETPATH) {
+ error("qimportbase.pri: You must provide a TARGETPATH!")
+}
+isEmpty(TARGET) {
+ error("qimportbase.pri: You must provide a TARGET!")
+}
+
+QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir
+copy2build.input = QMLDIRFILE
+copy2build.output = $$QT.declarative.imports/$$TARGETPATH/qmldir
+!contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS
+copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
+copy2build.name = COPY ${QMAKE_FILE_IN}
+copy2build.CONFIG += no_link
+# `clean' should leave the build in a runnable state, which means it shouldn't delete qmldir
+copy2build.CONFIG += no_clean
+QMAKE_EXTRA_COMPILERS += copy2build
+
+TARGET = $$qtLibraryTarget($$TARGET)
+contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
+
+load(qt_targets)
+
+wince*:LIBS += $$QMAKE_LIBS_GUI
+
+symbian: {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY = All -Tcb
+ load(armcc_warnings)
+}