summaryrefslogtreecommitdiffstats
path: root/src/plugins/qdeclarativemodules
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qdeclarativemodules')
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/multimedia.cpp18
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/multimedia.pro13
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio.cpp327
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio_p.h173
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase.cpp413
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase_p.h168
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo.cpp945
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo_p.h204
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject.cpp362
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject_p.h92
10 files changed, 2710 insertions, 5 deletions
diff --git a/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp b/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp
index 8becbf3..a2e74f4 100644
--- a/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp
+++ b/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp
@@ -41,17 +41,27 @@
#include <QtDeclarative/qdeclarativeextensionplugin.h>
#include <QtDeclarative/qdeclarative.h>
-#include <QtMultimedia/multimediadeclarative.h>
+#include <QtMultimedia/private/qsoundeffect_p.h>
+
+#include "qdeclarativevideo_p.h"
+#include "qdeclarativeaudio_p.h"
+
+
+QML_DECLARE_TYPE(QSoundEffect)
QT_BEGIN_NAMESPACE
-class QMultimediaQmlModule : public QDeclarativeExtensionPlugin
+class QMultimediaDeclarativeModule : public QDeclarativeExtensionPlugin
{
Q_OBJECT
public:
virtual void registerTypes(const char *uri)
{
- QtMultimedia::qRegisterDeclarativeElements(uri);
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.multimedia"));
+
+ qmlRegisterType<QSoundEffect>(uri, 4, 7, "SoundEffect");
+ qmlRegisterType<QDeclarativeAudio>(uri, 4, 7, "Audio");
+ qmlRegisterType<QDeclarativeVideo>(uri, 4, 7, "Video");
}
};
@@ -59,5 +69,5 @@ QT_END_NAMESPACE
#include "multimedia.moc"
-Q_EXPORT_PLUGIN2(qmultimediaqmlmodule, QT_PREPEND_NAMESPACE(QMultimediaQmlModule));
+Q_EXPORT_PLUGIN2(qmultimediadeclarativemodule, QT_PREPEND_NAMESPACE(QMultimediaDeclarativeModule));
diff --git a/src/plugins/qdeclarativemodules/multimedia/multimedia.pro b/src/plugins/qdeclarativemodules/multimedia/multimedia.pro
index d8ad18e..7b63e7c 100644
--- a/src/plugins/qdeclarativemodules/multimedia/multimedia.pro
+++ b/src/plugins/qdeclarativemodules/multimedia/multimedia.pro
@@ -3,7 +3,18 @@ include(../../qpluginbase.pri)
QT += multimedia declarative
-SOURCES += multimedia.cpp
+HEADERS += \
+ qdeclarativeaudio_p.h \
+ qdeclarativemediabase_p.h \
+ qdeclarativevideo_p.h \
+ qmetadatacontrolmetaobject_p.h \
+
+SOURCES += \
+ multimedia.cpp \
+ qdeclarativeaudio.cpp \
+ qdeclarativemediabase.cpp \
+ qdeclarativevideo.cpp \
+ qmetadatacontrolmetaobject.cpp
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/Qt/multimedia
target.path = $$[QT_INSTALL_IMPORTS]/Qt/multimedia
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio.cpp b/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio.cpp
new file mode 100644
index 0000000..df2888c
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio.cpp
@@ -0,0 +1,327 @@
+/****************************************************************************
+**
+** 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 "qdeclarativeaudio_p.h"
+
+#include <QtMultimedia/qmediaplayercontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+
+/*!
+ \qmlclass Audio QDeclarativeAudio
+ \since 4.7
+ \brief The Audio element allows you to add audio playback to a scene.
+
+ \qml
+ Audio { source: "audio/song.mp3" }
+ \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)
+{
+ setObject(this);
+}
+
+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()
+{
+ m_playerControl->play();
+
+ if (m_paused) {
+ m_paused = false;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlmethod Audio::pause()
+
+ Pauses playback of the media.
+
+ Sets the \l playing and \l paused properties to true.
+*/
+
+void QDeclarativeAudio::pause()
+{
+ m_playerControl->pause();
+
+ if (!m_paused && m_state == QMediaPlayer::PausedState) {
+ m_paused = true;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlmethod Audio::stop()
+
+ Stops playback of the media.
+
+ Sets the \l playing and \l paused properties to false.
+*/
+
+void QDeclarativeAudio::stop()
+{
+ m_playerControl->stop();
+
+ if (m_paused) {
+ m_paused = false;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlproperty url Audio::source
+
+ This property holds the source URL of the media.
+*/
+
+/*!
+ \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 enum 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);
+}
+
+/*!
+ \qmlsignal Audio::onLoaded()
+
+ This handler is called when the media source has been loaded.
+*/
+
+/*!
+ \qmlsignal Audio::onBuffering()
+
+ This handler is called when the media starts buffering.
+*/
+
+/*!
+ \qmlsignal Audio::onStalled()
+
+ This handler is called when playback has stalled while the media buffers.
+*/
+
+/*!
+ \qmlsignal Audio::onBuffered()
+
+ This handler is called when the media has finished buffering.
+*/
+
+/*!
+ \qmlsignal Audio::onEndOfMedia()
+
+ This handler is called when playback stops because end of the media has been reached.
+*/
+/*!
+ \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 qreal 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 qreal 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 qreal Audio::playbackRate
+
+ This property holds the rate at which audio is played at as a multiple of the normal rate.
+*/
+
+/*!
+ \qmlproperty enum 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);
+}
+
+/*!
+ \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 {Error}{error} has occurred. The errorString parameter
+ may contain more detailed information about the error.
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativeaudio_p.cpp"
+
+
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio_p.h b/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio_p.h
new file mode 100644
index 0000000..9881dbc
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio_p.h
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** 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 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 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(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_ENUMS(Status)
+ Q_ENUMS(Error)
+ 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
+ };
+
+ QDeclarativeAudio(QObject *parent = 0);
+ ~QDeclarativeAudio();
+
+ Status status() const;
+ Error error() const;
+
+public Q_SLOTS:
+ void play();
+ void pause();
+ void stop();
+
+Q_SIGNALS:
+ void sourceChanged();
+
+ void playingChanged();
+ void pausedChanged();
+
+ void started();
+ void resumed();
+ void paused();
+ void stopped();
+
+ void statusChanged();
+
+ void loaded();
+ void buffering();
+ void stalled();
+ void buffered();
+ void endOfMedia();
+
+ 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_stateChanged(QMediaPlayer::State))
+ Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
+ Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged())
+
+ inline QDeclarativeMediaBase *mediaBase() { return this; }
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeAudio))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase.cpp b/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase.cpp
new file mode 100644
index 0000000..8e87e44
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase.cpp
@@ -0,0 +1,413 @@
+/****************************************************************************
+**
+** 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 "qdeclarativemediabase_p.h"
+
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qurl.h>
+
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qmediaserviceprovider.h>
+#include <QtMultimedia/qmetadatacontrol.h>
+#include "qmetadatacontrolmetaobject_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 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_state == QMediaPlayer::PlayingState)
+ 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_stateChanged(QMediaPlayer::State state)
+{
+ if (state != m_state) {
+ QMediaPlayer::State oldState = m_state;
+
+ m_state = state;
+
+ if (state == QMediaPlayer::StoppedState) {
+ emit stopped();
+ emit playingChanged();
+ } else if (oldState == QMediaPlayer::StoppedState) {
+ emit started();
+ emit playingChanged();
+ } else if (oldState == QMediaPlayer::PausedState) {
+ m_paused = false;
+
+ emit resumed();
+ emit pausedChanged();
+ }
+
+ if (state == m_state && state == QMediaPlayer::PausedState) {
+ bool wasPaused = m_paused;
+
+ m_paused = true;
+
+ emit paused();
+
+ if (!wasPaused)
+ emit pausedChanged();
+ }
+
+ if (m_state == QMediaPlayer::PlayingState
+ || m_status == QMediaPlayer::BufferingMedia
+ || m_status == QMediaPlayer::StalledMedia) {
+ m_animation->start();
+ } else {
+ m_animation->stop();
+ }
+ }
+}
+
+void QDeclarativeMediaBase::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status)
+{
+ if (status != m_status) {
+ m_status = status;
+
+ switch (status) {
+ case QMediaPlayer::LoadedMedia:
+ emit loaded();
+ break;
+ case QMediaPlayer::BufferingMedia:
+ emit buffering();
+ break;
+ case QMediaPlayer::BufferedMedia:
+ emit buffered();
+ break;
+ case QMediaPlayer::StalledMedia:
+ emit stalled();
+ break;
+ case QMediaPlayer::EndOfMedia:
+ emit endOfMedia();
+ break;
+ default:
+ break;
+ }
+
+ emit statusChanged();
+
+ if (m_state == QMediaPlayer::PlayingState
+ || m_status == QMediaPlayer::BufferingMedia
+ || m_status == QMediaPlayer::StalledMedia) {
+ m_animation->start();
+ } else {
+ m_animation->stop();
+ }
+ }
+}
+
+void QDeclarativeMediaBase::_q_metaDataChanged()
+{
+ m_metaObject->metaDataChanged();
+}
+
+QDeclarativeMediaBase::QDeclarativeMediaBase()
+ : m_mediaService(0)
+ , m_playerControl(0)
+ , m_mediaObject(0)
+ , m_mediaProvider(0)
+ , m_metaDataControl(0)
+ , m_metaObject(0)
+ , m_animation(0)
+ , m_state(QMediaPlayer::StoppedState)
+ , m_status(QMediaPlayer::NoMedia)
+ , m_error(QMediaPlayer::NoError)
+ , m_paused(false)
+{
+}
+
+QDeclarativeMediaBase::~QDeclarativeMediaBase()
+{
+}
+
+void QDeclarativeMediaBase::shutdown()
+{
+ delete m_metaObject;
+ delete m_mediaObject;
+
+ if (m_mediaProvider)
+ m_mediaProvider->releaseService(m_mediaService);
+
+ delete m_animation;
+
+}
+
+void QDeclarativeMediaBase::setObject(QObject *object)
+{
+ if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider())) {
+ if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER))) {
+ m_playerControl = qobject_cast<QMediaPlayerControl *>(
+ m_mediaService->control(QMediaPlayerControl_iid));
+ m_metaDataControl = qobject_cast<QMetaDataControl *>(
+ m_mediaService->control(QMetaDataControl_iid));
+ m_mediaObject = new QDeclarativeMediaBaseObject(m_mediaService);
+ }
+ }
+
+ if (m_playerControl) {
+ QObject::connect(m_playerControl, SIGNAL(stateChanged(QMediaPlayer::State)),
+ object, SLOT(_q_stateChanged(QMediaPlayer::State)));
+ QObject::connect(m_playerControl, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
+ object, SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus)));
+ 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);
+ } else {
+ m_error = QMediaPlayer::ServiceMissingError;
+
+ m_playerControl = new QDeclarativeMediaBasePlayerControl(object);
+ }
+
+ if (m_metaDataControl) {
+ m_metaObject = new QMetaDataControlMetaObject(m_metaDataControl, object);
+
+ QObject::connect(m_metaDataControl, SIGNAL(metaDataChanged()),
+ object, SLOT(_q_metaDataChanged()));
+ }
+}
+
+QUrl QDeclarativeMediaBase::source() const
+{
+ return m_playerControl->media().canonicalUrl();
+}
+
+void QDeclarativeMediaBase::setSource(const QUrl &url)
+{
+ if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
+ m_error = QMediaPlayer::NoError;
+ m_errorString = QString();
+
+ emit errorChanged();
+ }
+
+ m_playerControl->setMedia(QMediaContent(url), 0);
+}
+
+bool QDeclarativeMediaBase::isPlaying() const
+{
+ return m_state != QMediaPlayer::StoppedState;
+}
+
+void QDeclarativeMediaBase::setPlaying(bool playing)
+{
+ if (playing && m_state == QMediaPlayer::StoppedState) {
+ if (m_paused)
+ m_playerControl->pause();
+ else
+ m_playerControl->play();
+ } else if (!playing) {
+ m_playerControl->stop();
+ }
+}
+
+bool QDeclarativeMediaBase::isPaused() const
+{
+ return m_paused;
+}
+
+void QDeclarativeMediaBase::setPaused(bool paused)
+{
+ if (m_paused != paused) {
+ if (paused && m_state == QMediaPlayer::PlayingState) {
+ m_playerControl->pause();
+ } else if (!paused && m_state == QMediaPlayer::PausedState) {
+ m_playerControl->play();
+ } else {
+ m_paused = paused;
+
+ emit pausedChanged();
+ }
+ }
+}
+
+int QDeclarativeMediaBase::duration() const
+{
+ return m_playerControl->duration();
+}
+
+int QDeclarativeMediaBase::position() const
+{
+ return m_playerControl->position();
+
+}
+
+void QDeclarativeMediaBase::setPosition(int position)
+{
+ m_playerControl->setPosition(position);
+}
+
+qreal QDeclarativeMediaBase::volume() const
+{
+ return qreal(m_playerControl->volume()) / 100;
+}
+
+void QDeclarativeMediaBase::setVolume(qreal volume)
+{
+ m_playerControl->setVolume(qRound(volume * 100));
+}
+
+bool QDeclarativeMediaBase::isMuted() const
+{
+ return m_playerControl->isMuted();
+}
+
+void QDeclarativeMediaBase::setMuted(bool muted)
+{
+ m_playerControl->setMuted(muted);
+}
+
+qreal QDeclarativeMediaBase::bufferProgress() const
+{
+ return qreal(m_playerControl->bufferStatus()) / 100;
+}
+
+bool QDeclarativeMediaBase::isSeekable() const
+{
+ return m_playerControl->isSeekable();
+}
+
+qreal QDeclarativeMediaBase::playbackRate() const
+{
+ return m_playerControl->playbackRate();
+}
+
+void QDeclarativeMediaBase::setPlaybackRate(qreal rate)
+{
+ m_playerControl->setPlaybackRate(rate);
+}
+
+QString QDeclarativeMediaBase::errorString() const
+{
+ return m_errorString;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase_p.h b/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase_p.h
new file mode 100644
index 0000000..b40e84e
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase_p.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** 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 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 <QtMultimedia/qmediaplayer.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QMediaPlayerControl;
+class QMediaService;
+class QMediaServiceProvider;
+class QMetaDataControl;
+class QMetaDataControlMetaObject;
+class QDeclarativeMediaBaseAnimation;
+
+class QDeclarativeMediaBase
+{
+public:
+ QDeclarativeMediaBase();
+ virtual ~QDeclarativeMediaBase();
+
+ QUrl source() const;
+ void setSource(const QUrl &url);
+
+ 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;
+
+ void _q_stateChanged(QMediaPlayer::State state);
+ void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status);
+
+ void _q_metaDataChanged();
+
+protected:
+ void shutdown();
+
+ void setObject(QObject *object);
+
+ virtual void sourceChanged() = 0;
+
+ virtual void playingChanged() = 0;
+ virtual void pausedChanged() = 0;
+
+ virtual void started() = 0;
+ virtual void resumed() = 0;
+ virtual void paused() = 0;
+ virtual void stopped() = 0;
+
+ virtual void statusChanged() = 0;
+
+ virtual void loaded() = 0;
+ virtual void buffering() = 0;
+ virtual void stalled() = 0;
+ virtual void buffered() = 0;
+ virtual void endOfMedia() = 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;
+
+ QMediaService *m_mediaService;
+ QMediaPlayerControl *m_playerControl;
+
+ QMediaObject *m_mediaObject;
+ QMediaServiceProvider *m_mediaProvider;
+ QMetaDataControl *m_metaDataControl;
+ QMetaDataControlMetaObject *m_metaObject;
+ QDeclarativeMediaBaseAnimation *m_animation;
+
+ QMediaPlayer::State m_state;
+ QMediaPlayer::MediaStatus m_status;
+ QMediaPlayer::Error m_error;
+ bool m_paused;
+ QString m_errorString;
+
+ friend class QDeclarativeMediaBaseAnimation;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo.cpp b/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo.cpp
new file mode 100644
index 0000000..064f242
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo.cpp
@@ -0,0 +1,945 @@
+/****************************************************************************
+**
+** 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 "qdeclarativevideo_p.h"
+
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/private/qpaintervideosurface_p.h>
+#include <QtMultimedia/qvideooutputcontrol.h>
+#include <QtMultimedia/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
+ \since 4.7
+ \brief The Video element allows you to add videos to a scene.
+ \inherits Item
+
+ \qml
+ Video { source: "video/movie.mpg" }
+ \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)
+
+{
+ 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_graphicsItem->setMediaObject(m_mediaObject);
+ }
+}
+
+QDeclarativeVideo::~QDeclarativeVideo()
+{
+ shutdown();
+
+ delete m_graphicsItem;
+}
+
+/*!
+ \qmlproperty url Video::source
+
+ This property holds the source URL of the media.
+*/
+
+/*!
+ \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 enum 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);
+}
+
+/*!
+ \qmlsignal Video::onLoaded()
+
+ This handler is called when the media source has been loaded.
+*/
+
+/*!
+ \qmlsignal Video::onBuffering()
+
+ This handler is called when the media starts buffering.
+*/
+
+/*!
+ \qmlsignal Video::onStalled()
+
+ This handler is called when playback has stalled while the media buffers.
+*/
+
+/*!
+ \qmlsignal Video::onBuffered()
+
+ This handler is called when the media has finished buffering.
+*/
+
+/*!
+ \qmlsignal Video::onEndOfMedia()
+
+ This handler is called when playback stops because end of the media has been reached.
+*/
+
+/*!
+ \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 qreal 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_playerControl->isAudioAvailable();
+}
+
+/*!
+ \qmlproperty bool Video::hasVideo
+
+ This property holds whether the media contains video.
+*/
+
+bool QDeclarativeVideo::hasVideo() const
+{
+ return m_playerControl->isVideoAvailable();
+}
+
+/*!
+ \qmlproperty qreal 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 qreal Video::playbackRate
+
+ This property holds the rate at which video is played at as a multiple of the normal rate.
+*/
+
+/*!
+ \qmlproperty enum 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 {Error}{error} has occurred. The errorString parameter
+ may contain more detailed information about the error.
+*/
+
+/*!
+ \qmlproperty enum 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()
+{
+ m_playerControl->play();
+
+ if (m_paused) {
+ m_paused = false;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlmethod Video::pause()
+
+ Pauses playback of the media.
+
+ Sets the \l playing and \l paused properties to true.
+*/
+
+void QDeclarativeVideo::pause()
+{
+ m_playerControl->pause();
+
+ if (!m_paused && m_state == QMediaPlayer::PausedState) {
+ m_paused = true;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlmethod Video::stop()
+
+ Stops playback of the media.
+
+ Sets the \l playing and \l paused properties to false.
+*/
+
+void QDeclarativeVideo::stop()
+{
+ m_playerControl->stop();
+
+ if (m_paused) {
+ m_paused = false;
+ emit pausedChanged();
+ }
+}
+
+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);
+}
+
+QT_END_NAMESPACE
+
+// ***************************************
+// Documentation for meta-data properties.
+// ***************************************
+
+/*!
+ \qmlproperty variant Video::title
+
+ This property holds the tile of the media.
+
+ \sa {QtMultimedia::Title}
+*/
+
+/*!
+ \qmlproperty variant Video::subTitle
+
+ This property holds the sub-title of the media.
+
+ \sa {QtMultimedia::SubTitle}
+*/
+
+/*!
+ \qmlproperty variant Video::author
+
+ This property holds the author of the media.
+
+ \sa {QtMultimedia::Author}
+*/
+
+/*!
+ \qmlproperty variant Video::comment
+
+ This property holds a user comment about the media.
+
+ \sa {QtMultimedia::Comment}
+*/
+
+/*!
+ \qmlproperty variant Video::description
+
+ This property holds a description of the media.
+
+ \sa {QtMultimedia::Description}
+*/
+
+/*!
+ \qmlproperty variant Video::category
+
+ This property holds the category of the media
+
+ \sa {QtMultimedia::Category}
+*/
+
+/*!
+ \qmlproperty variant Video::genre
+
+ This property holds the genre of the media.
+
+ \sa {QtMultimedia::Genre}
+*/
+
+/*!
+ \qmlproperty variant Video::year
+
+ This property holds the year of release of the media.
+
+ \sa {QtMultimedia::Year}
+*/
+
+/*!
+ \qmlproperty variant Video::date
+
+ This property holds the date of the media.
+
+ \sa {QtMultimedia::Date}
+*/
+
+/*!
+ \qmlproperty variant Video::userRating
+
+ This property holds a user rating of the media in the range of 0 to 100.
+
+ \sa {QtMultimedia::UserRating}
+*/
+
+/*!
+ \qmlproperty variant Video::keywords
+
+ This property holds a list of keywords describing the media.
+
+ \sa {QtMultimedia::Keywords}
+*/
+
+/*!
+ \qmlproperty variant Video::language
+
+ This property holds the language of the media, as an ISO 639-2 code.
+
+ \sa {QtMultimedia::Language}
+*/
+
+/*!
+ \qmlproperty variant Video::publisher
+
+ This property holds the publisher of the media.
+
+ \sa {QtMultimedia::Publisher}
+*/
+
+/*!
+ \qmlproperty variant Video::copyright
+
+ This property holds the media's copyright notice.
+
+ \sa {QtMultimedia::Copyright}
+*/
+
+/*!
+ \qmlproperty variant Video::parentalRating
+
+ This property holds the parental rating of the media.
+
+ \sa {QtMultimedia::ParentalRating}
+*/
+
+/*!
+ \qmlproperty variant Video::ratingOrganisation
+
+ This property holds the name of the rating organisation responsible for the
+ parental rating of the media.
+
+ \sa {QtMultimedia::RatingOrganisation}
+*/
+
+/*!
+ \qmlproperty variant Video::size
+
+ This property property holds the size of the media in bytes.
+
+ \sa {QtMultimedia::Size}
+*/
+
+/*!
+ \qmlproperty variant Video::mediaType
+
+ This property holds the type of the media.
+
+ \sa {QtMultimedia::MediaType}
+*/
+
+/*!
+ \qmlproperty variant Video::audioBitRate
+
+ This property holds the bit rate of the media's audio stream ni bits per
+ second.
+
+ \sa {QtMultimedia::AudioBitRate}
+*/
+
+/*!
+ \qmlproperty variant Video::audioCodec
+
+ This property holds the encoding of the media audio stream.
+
+ \sa {QtMultimedia::AudioCodec}
+*/
+
+/*!
+ \qmlproperty variant Video::averageLevel
+
+ This property holds the average volume level of the media.
+
+ \sa {QtMultimedia::AverageLevel}
+*/
+
+/*!
+ \qmlproperty variant Video::channelCount
+
+ This property holds the number of channels in the media's audio stream.
+
+ \sa {QtMultimedia::ChannelCount}
+*/
+
+/*!
+ \qmlproperty variant Video::peakValue
+
+ This property holds the peak volume of media's audio stream.
+
+ \sa {QtMultimedia::PeakValue}
+*/
+
+/*!
+ \qmlproperty variant Video::sampleRate
+
+ This property holds the sample rate of the media's audio stream in hertz.
+
+ \sa {QtMultimedia::SampleRate}
+*/
+
+/*!
+ \qmlproperty variant Video::albumTitle
+
+ This property holds the title of the album the media belongs to.
+
+ \sa {QtMultimedia::AlbumTitle}
+*/
+
+/*!
+ \qmlproperty variant Video::albumArtist
+
+ This property holds the name of the principal artist of the album the media
+ belongs to.
+
+ \sa {QtMultimedia::AlbumArtist}
+*/
+
+/*!
+ \qmlproperty variant Video::contributingArtist
+
+ This property holds the names of artists contributing to the media.
+
+ \sa {QtMultimedia::ContributingArtist}
+*/
+
+/*!
+ \qmlproperty variant Video::composer
+
+ This property holds the composer of the media.
+
+ \sa {QtMultimedia::Composer}
+*/
+
+/*!
+ \qmlproperty variant Video::conductor
+
+ This property holds the conductor of the media.
+
+ \sa {QtMultimedia::Conductor}
+*/
+
+/*!
+ \qmlproperty variant Video::lyrics
+
+ This property holds the lyrics to the media.
+
+ \sa {QtMultimedia::Lyrics}
+*/
+
+/*!
+ \qmlproperty variant Video::mood
+
+ This property holds the mood of the media.
+
+ \sa {QtMultimedia::Mood}
+*/
+
+/*!
+ \qmlproperty variant Video::trackNumber
+
+ This property holds the track number of the media.
+
+ \sa {QtMultimedia::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::trackCount
+
+ This property holds the number of track on the album containing the media.
+
+ \sa {QtMultimedia::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::coverArtUrlSmall
+
+ This property holds the URL of a small cover art image.
+
+ \sa {QtMultimedia::CoverArtUrlSmall}
+*/
+
+/*!
+ \qmlproperty variant Video::coverArtUrlLarge
+
+ This property holds the URL of a large cover art image.
+
+ \sa {QtMultimedia::CoverArtUrlLarge}
+*/
+
+/*!
+ \qmlproperty variant Video::resolution
+
+ This property holds the dimension of an image or video.
+
+ \sa {QtMultimedia::Resolution}
+*/
+
+/*!
+ \qmlproperty variant Video::pixelAspectRatio
+
+ This property holds the pixel aspect ratio of an image or video.
+
+ \sa {QtMultimedia::PixelAspectRatio}
+*/
+
+/*!
+ \qmlproperty variant Video::videoFrameRate
+
+ This property holds the frame rate of the media's video stream.
+
+ \sa {QtMultimedia::VideoFrameRate}
+*/
+
+/*!
+ \qmlproperty variant Video::videoBitRate
+
+ This property holds the bit rate of the media's video stream in bits per
+ second.
+
+ \sa {QtMultimedia::VideoBitRate}
+*/
+
+/*!
+ \qmlproperty variant Video::videoCodec
+
+ This property holds the encoding of the media's video stream.
+
+ \sa {QtMultimedia::VideoCodec}
+*/
+
+/*!
+ \qmlproperty variant Video::posterUrl
+
+ This property holds the URL of a poster image.
+
+ \sa {QtMultimedia::PosterUrl}
+*/
+
+/*!
+ \qmlproperty variant Video::chapterNumber
+
+ This property holds the chapter number of the media.
+
+ \sa {QtMultimedia::ChapterNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::director
+
+ This property holds the director of the media.
+
+ \sa {QtMultimedia::Director}
+*/
+
+/*!
+ \qmlproperty variant Video::leadPerformer
+
+ This property holds the lead performer in the media.
+
+ \sa {QtMultimedia::LeadPerformer}
+*/
+
+/*!
+ \qmlproperty variant Video::writer
+
+ This property holds the writer of the media.
+
+ \sa {QtMultimedia::Writer}
+*/
+
+// The remaining properties are related to photos, and are technically
+// available but will certainly never have values.
+#ifndef Q_QDOC
+
+/*!
+ \qmlproperty variant Video::cameraManufacturer
+
+ \sa {QtMultimedia::CameraManufacturer}
+*/
+
+/*!
+ \qmlproperty variant Video::cameraModel
+
+ \sa {QtMultimedia::CameraModel}
+*/
+
+/*!
+ \qmlproperty variant Video::event
+
+ \sa {QtMultimedia::Event}
+*/
+
+/*!
+ \qmlproperty variant Video::subject
+
+ \sa {QtMultimedia::Subject}
+*/
+
+/*!
+ \qmlproperty variant Video::orientation
+
+ \sa {QtMultimedia::Orientation}
+*/
+
+/*!
+ \qmlproperty variant Video::exposureTime
+
+ \sa {QtMultimedia::ExposureTime}
+*/
+
+/*!
+ \qmlproperty variant Video::fNumber
+
+ \sa {QtMultimedia::FNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::exposureProgram
+
+ \sa {QtMultimedia::ExposureProgram}
+*/
+
+/*!
+ \qmlproperty variant Video::isoSpeedRatings
+
+ \sa {QtMultimedia::ISOSpeedRatings}
+*/
+
+/*!
+ \qmlproperty variant Video::exposureBiasValue
+
+ \sa {QtMultimedia::ExposureBiasValue}
+*/
+
+/*!
+ \qmlproperty variant Video::dateTimeDigitized
+
+ \sa {QtMultimedia::DateTimeDigitized}
+*/
+
+/*!
+ \qmlproperty variant Video::subjectDistance
+
+ \sa {QtMultimedia::SubjectDistance}
+*/
+
+/*!
+ \qmlproperty variant Video::meteringMode
+
+ \sa {QtMultimedia::MeteringMode}
+*/
+
+/*!
+ \qmlproperty variant Video::lightSource
+
+ \sa {QtMultimedia::LightSource}
+*/
+
+/*!
+ \qmlproperty variant Video::flash
+
+ \sa {QtMultimedia::Flash}
+*/
+
+/*!
+ \qmlproperty variant Video::focalLength
+
+ \sa {QtMultimedia::FocalLength}
+*/
+
+/*!
+ \qmlproperty variant Video::exposureMode
+
+ \sa {QtMultimedia::ExposureMode}
+*/
+
+/*!
+ \qmlproperty variant Video::whiteBalance
+
+ \sa {QtMultimedia::WhiteBalance}
+*/
+
+/*!
+ \qmlproperty variant Video::DigitalZoomRatio
+
+ \sa {QtMultimedia::DigitalZoomRatio}
+*/
+
+/*!
+ \qmlproperty variant Video::focalLengthIn35mmFilm
+
+ \sa {QtMultimedia::FocalLengthIn35mmFile}
+*/
+
+/*!
+ \qmlproperty variant Video::sceneCaptureType
+
+ \sa {QtMultimedia::SceneCaptureType}
+*/
+
+/*!
+ \qmlproperty variant Video::gainControl
+
+ \sa {QtMultimedia::GainControl}
+*/
+
+/*!
+ \qmlproperty variant Video::contrast
+
+ \sa {QtMultimedia::contrast}
+*/
+
+/*!
+ \qmlproperty variant Video::saturation
+
+ \sa {QtMultimedia::Saturation}
+*/
+
+/*!
+ \qmlproperty variant Video::sharpness
+
+ \sa {QtMultimedia::Sharpness}
+*/
+
+/*!
+ \qmlproperty variant Video::deviceSettingDescription
+
+ \sa {QtMultimedia::DeviceSettingDescription}
+*/
+
+#endif
+
+#include "moc_qdeclarativevideo_p.cpp"
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo_p.h b/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo_p.h
new file mode 100644
index 0000000..fb13519
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo_p.h
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** 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 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 <QtMultimedia/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 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_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 *);
+
+public Q_SLOTS:
+ void play();
+ void pause();
+ void stop();
+
+Q_SIGNALS:
+ void sourceChanged();
+
+ void playingChanged();
+ void pausedChanged();
+
+ void started();
+ void resumed();
+ void paused();
+ void stopped();
+
+ void statusChanged();
+
+ void loaded();
+ void buffering();
+ void stalled();
+ void buffered();
+ void endOfMedia();
+
+ 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_stateChanged(QMediaPlayer::State))
+ Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
+ Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged())
+
+ inline QDeclarativeMediaBase *mediaBase() { return this; }
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeVideo))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject.cpp b/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject.cpp
new file mode 100644
index 0000000..e90cbd6
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject.cpp
@@ -0,0 +1,362 @@
+/****************************************************************************
+**
+** 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 "qmetadatacontrolmetaobject_p.h"
+#include <QtMultimedia/qmetadatacontrol.h>
+
+
+QT_BEGIN_NAMESPACE
+
+// copied from qmetaobject.cpp
+// do not touch without touching the moc as well
+enum PropertyFlags {
+ Invalid = 0x00000000,
+ Readable = 0x00000001,
+ Writable = 0x00000002,
+ Resettable = 0x00000004,
+ EnumOrFlag = 0x00000008,
+ StdCppSet = 0x00000100,
+// Override = 0x00000200,
+ Designable = 0x00001000,
+ ResolveDesignable = 0x00002000,
+ Scriptable = 0x00004000,
+ ResolveScriptable = 0x00008000,
+ Stored = 0x00010000,
+ ResolveStored = 0x00020000,
+ Editable = 0x00040000,
+ ResolveEditable = 0x00080000,
+ User = 0x00100000,
+ ResolveUser = 0x00200000,
+ Notify = 0x00400000,
+ Dynamic = 0x00800000
+};
+
+enum MethodFlags {
+ AccessPrivate = 0x00,
+ AccessProtected = 0x01,
+ AccessPublic = 0x02,
+ AccessMask = 0x03, //mask
+
+ MethodMethod = 0x00,
+ MethodSignal = 0x04,
+ MethodSlot = 0x08,
+ MethodConstructor = 0x0c,
+ MethodTypeMask = 0x0c,
+
+ MethodCompatibility = 0x10,
+ MethodCloned = 0x20,
+ MethodScriptable = 0x40
+};
+
+struct QMetaObjectPrivate
+{
+ int revision;
+ int className;
+ int classInfoCount, classInfoData;
+ int methodCount, methodData;
+ int propertyCount, propertyData;
+ int enumeratorCount, enumeratorData;
+ int constructorCount, constructorData;
+ int flags;
+};
+
+static inline const QMetaObjectPrivate *priv(const uint* m_data)
+{ return reinterpret_cast<const QMetaObjectPrivate*>(m_data); }
+// end of copied lines from qmetaobject.cpp
+
+namespace
+{
+ struct MetaDataKey
+ {
+ QtMultimedia::MetaData key;
+ const char *name;
+ };
+
+ const MetaDataKey qt_metaDataKeys[] =
+ {
+ { QtMultimedia::Title, "title" },
+ { QtMultimedia::SubTitle, "subTitle" },
+ { QtMultimedia::Author, "author" },
+ { QtMultimedia::Comment, "comment" },
+ { QtMultimedia::Description, "description" },
+ { QtMultimedia::Category, "category" },
+ { QtMultimedia::Genre, "genre" },
+ { QtMultimedia::Year, "year" },
+ { QtMultimedia::Date, "date" },
+ { QtMultimedia::UserRating, "userRating" },
+ { QtMultimedia::Keywords, "keywords" },
+ { QtMultimedia::Language, "language" },
+ { QtMultimedia::Publisher, "publisher" },
+ { QtMultimedia::Copyright, "copyright" },
+ { QtMultimedia::ParentalRating, "parentalRating" },
+ { QtMultimedia::RatingOrganisation, "ratingOrganisation" },
+
+ // Media
+ { QtMultimedia::Size, "size" },
+ { QtMultimedia::MediaType, "mediaType" },
+// { QtMultimedia::Duration, "duration" },
+
+ // Audio
+ { QtMultimedia::AudioBitRate, "audioBitRate" },
+ { QtMultimedia::AudioCodec, "audioCodec" },
+ { QtMultimedia::AverageLevel, "averageLevel" },
+ { QtMultimedia::ChannelCount, "channelCount" },
+ { QtMultimedia::PeakValue, "peakValue" },
+ { QtMultimedia::SampleRate, "sampleRate" },
+
+ // Music
+ { QtMultimedia::AlbumTitle, "albumTitle" },
+ { QtMultimedia::AlbumArtist, "albumArtist" },
+ { QtMultimedia::ContributingArtist, "contributingArtist" },
+ { QtMultimedia::Composer, "composer" },
+ { QtMultimedia::Conductor, "conductor" },
+ { QtMultimedia::Lyrics, "lyrics" },
+ { QtMultimedia::Mood, "mood" },
+ { QtMultimedia::TrackNumber, "trackNumber" },
+ { QtMultimedia::TrackCount, "trackCount" },
+
+ { QtMultimedia::CoverArtUrlSmall, "coverArtUrlSmall" },
+ { QtMultimedia::CoverArtUrlLarge, "coverArtUrlLarge" },
+
+ // Image/Video
+ { QtMultimedia::Resolution, "resolution" },
+ { QtMultimedia::PixelAspectRatio, "pixelAspectRatio" },
+
+ // Video
+ { QtMultimedia::VideoFrameRate, "videoFrameRate" },
+ { QtMultimedia::VideoBitRate, "videoBitRate" },
+ { QtMultimedia::VideoCodec, "videoCodec" },
+
+ { QtMultimedia::PosterUrl, "posterUrl" },
+
+ // Movie
+ { QtMultimedia::ChapterNumber, "chapterNumber" },
+ { QtMultimedia::Director, "director" },
+ { QtMultimedia::LeadPerformer, "leadPerformer" },
+ { QtMultimedia::Writer, "writer" },
+
+ // Photos
+ { QtMultimedia::CameraManufacturer, "cameraManufacturer" },
+ { QtMultimedia::CameraModel, "cameraModel" },
+ { QtMultimedia::Event, "event" },
+ { QtMultimedia::Subject, "subject" },
+ { QtMultimedia::Orientation, "orientation" },
+ { QtMultimedia::ExposureTime, "exposureTime" },
+ { QtMultimedia::FNumber, "fNumber" },
+ { QtMultimedia::ExposureProgram, "exposureProgram" },
+ { QtMultimedia::ISOSpeedRatings, "isoSpeedRatings" },
+ { QtMultimedia::ExposureBiasValue, "exposureBiasValue" },
+ { QtMultimedia::DateTimeOriginal, "dateTimeOriginal" },
+ { QtMultimedia::DateTimeDigitized, "dateTimeDigitized" },
+ { QtMultimedia::SubjectDistance, "subjectDistance" },
+ { QtMultimedia::MeteringMode, "meteringMode" },
+ { QtMultimedia::LightSource, "lightSource" },
+ { QtMultimedia::Flash, "flash" },
+ { QtMultimedia::FocalLength, "focalLength" },
+ { QtMultimedia::ExposureMode, "exposureMode" },
+ { QtMultimedia::WhiteBalance, "whiteBalance" },
+ { QtMultimedia::DigitalZoomRatio, "digitalZoomRatio" },
+ { QtMultimedia::FocalLengthIn35mmFilm, "focalLengthIn35mmFilm" },
+ { QtMultimedia::SceneCaptureType, "sceneCaptureType" },
+ { QtMultimedia::GainControl, "gainControl" },
+ { QtMultimedia::Contrast, "contrast" },
+ { QtMultimedia::Saturation, "saturation" },
+ { QtMultimedia::Sharpness, "sharpness" },
+ { QtMultimedia::DeviceSettingDescription, "deviceSettingDescription" }
+ };
+
+ class QMetaDataControlObject : public QObject
+ {
+ public:
+ inline QObjectData *data() { return d_ptr.data(); }
+ };
+}
+
+QMetaDataControlMetaObject::QMetaDataControlMetaObject(QMetaDataControl *control, QObject *object)
+ : m_control(control)
+ , m_object(object)
+ , m_string(0)
+ , m_data(0)
+ , m_propertyOffset(0)
+ , m_signalOffset(0)
+{
+ const QMetaObject *superClass = m_object->metaObject();
+
+ const int propertyCount = sizeof(qt_metaDataKeys) / sizeof(MetaDataKey);
+ const int dataSize = sizeof(uint)
+ * (13 // QMetaObjectPrivate members.
+ + 5 // 5 members per signal.
+ + 4 * propertyCount // 3 members per property + 1 notify signal per property.
+ + 1); // Terminating value.
+
+ m_data = reinterpret_cast<uint *>(qMalloc(dataSize));
+
+ QMetaObjectPrivate *pMeta = reinterpret_cast<QMetaObjectPrivate *>(m_data);
+
+ pMeta->revision = 3;
+ pMeta->className = 0;
+ pMeta->classInfoCount = 0;
+ pMeta->classInfoData = 0;
+ pMeta->methodCount = 1;
+ pMeta->methodData = 13;
+ pMeta->propertyCount = propertyCount;
+ pMeta->propertyData = 18;
+ pMeta->enumeratorCount = 0;
+ pMeta->enumeratorData = 0;
+ pMeta->constructorCount = 0;
+ pMeta->constructorData = 0;
+ pMeta->flags = 0x01; // Dynamic meta object flag.
+
+ const int classNameSize = qstrlen(superClass->className()) + 1;
+
+ int stringIndex = classNameSize + 1;
+
+ // __metaDataChanged() signal.
+ static const char *changeSignal = "__metaDataChanged()";
+ const int changeSignalSize = qstrlen(changeSignal) + 1;
+
+ m_data[13] = stringIndex; // Signature.
+ m_data[14] = classNameSize; // Parameters.
+ m_data[15] = classNameSize; // Type.
+ m_data[16] = classNameSize; // Tag.
+ m_data[17] = MethodSignal | AccessProtected; // Flags.
+
+ stringIndex += changeSignalSize;
+
+ const char *qvariantName = "QVariant";
+ const int qvariantSize = qstrlen(qvariantName) + 1;
+ const int qvariantIndex = stringIndex;
+
+ stringIndex += qvariantSize;
+
+ // Properties.
+ for (int i = 0; i < propertyCount; ++i) {
+ m_data[18 + 3 * i] = stringIndex; // Name.
+ m_data[19 + 3 * i] = qvariantIndex; // Type.
+ m_data[20 + 3 * i]
+ = Readable | Writable | Notify | Dynamic | (0xffffffff << 24); // Flags.
+ m_data[18 + propertyCount * 3 + i] = 0; // Notify signal.
+
+ stringIndex += qstrlen(qt_metaDataKeys[i].name) + 1;
+ }
+
+ // Terminating value.
+ m_data[18 + propertyCount * 4] = 0;
+
+ // Build string.
+ m_string = reinterpret_cast<char *>(qMalloc(stringIndex + 1));
+
+ // Class name.
+ qMemCopy(m_string, superClass->className(), classNameSize);
+
+ stringIndex = classNameSize;
+
+ // Null m_string.
+ m_string[stringIndex] = '\0';
+ stringIndex += 1;
+
+ // __metaDataChanged() signal.
+ qMemCopy(m_string + stringIndex, changeSignal, changeSignalSize);
+ stringIndex += changeSignalSize;
+
+ qMemCopy(m_string + stringIndex, qvariantName, qvariantSize);
+ stringIndex += qvariantSize;
+
+ // Properties.
+ for (int i = 0; i < propertyCount; ++i) {
+ const int propertyNameSize = qstrlen(qt_metaDataKeys[i].name) + 1;
+
+ qMemCopy(m_string + stringIndex, qt_metaDataKeys[i].name, propertyNameSize);
+ stringIndex += propertyNameSize;
+ }
+
+ // Terminating character.
+ m_string[stringIndex] = '\0';
+
+ d.superdata = superClass;
+ d.stringdata = m_string;
+ d.data = m_data;
+ d.extradata = 0;
+
+ static_cast<QMetaDataControlObject *>(m_object)->data()->metaObject = this;
+
+ m_propertyOffset = propertyOffset();
+ m_signalOffset = methodOffset();
+}
+
+QMetaDataControlMetaObject::~QMetaDataControlMetaObject()
+{
+ static_cast<QMetaDataControlObject *>(m_object)->data()->metaObject = 0;
+
+ qFree(m_data);
+ qFree(m_string);
+}
+
+int QMetaDataControlMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
+{
+ if (c == QMetaObject::ReadProperty && id >= m_propertyOffset) {
+ int propId = id - m_propertyOffset;
+
+ *reinterpret_cast<QVariant *>(a[0]) = m_control->metaData(qt_metaDataKeys[propId].key);
+
+ return -1;
+ } else if (c == QMetaObject::WriteProperty && id >= m_propertyOffset) {
+ int propId = id - m_propertyOffset;
+
+ m_control->setMetaData(qt_metaDataKeys[propId].key, *reinterpret_cast<QVariant *>(a[0]));
+
+ return -1;
+ } else {
+ return m_object->qt_metacall(c, id, a);
+ }
+}
+
+int QMetaDataControlMetaObject::createProperty(const char *, const char *)
+{
+ return -1;
+}
+
+void QMetaDataControlMetaObject::metaDataChanged()
+{
+ activate(m_object, m_signalOffset, 0);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject_p.h b/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject_p.h
new file mode 100644
index 0000000..c381f2d
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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 QMETADATACONTROLMETAOBJECT_P_H
+#define QMETADATACONTROLMETAOJBECT_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/qmetaobject.h>
+#include <QtMultimedia/qtmedianamespace.h>
+
+#include <QtCore/private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QMetaDataControl;
+
+class QMetaDataControlMetaObject : public QAbstractDynamicMetaObject
+{
+public:
+ QMetaDataControlMetaObject(QMetaDataControl *control, QObject *object);
+ ~QMetaDataControlMetaObject();
+
+ int metaCall(QMetaObject::Call call, int _id, void **arguments);
+ int createProperty(const char *, const char *);
+
+ void metaDataChanged();
+
+private:
+ QMetaDataControl *m_control;
+ QObject *m_object;
+ char *m_string;
+ uint *m_data;
+
+ int m_propertyOffset;
+ int m_signalOffset;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif