From 937fb55d35373fd2701078251840b6be0465a6e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Sat, 28 Jul 2018 07:01:24 -0300 Subject: bpo-5978: Document that profiling needs cmd/function to return (GH-7938) https://bugs.python.org/issue5978 --- Doc/library/profile.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst index 5e33efe..1a772fb 100644 --- a/Doc/library/profile.rst +++ b/Doc/library/profile.rst @@ -310,6 +310,11 @@ functions: Profile ``func(*args, **kwargs)`` +Note that profiling will only work if the called command/function actually +returns. If the interpreter is terminated (e.g. via a :func:`sys.exit` call +during the called command/function execution) no profiling results will be +printed. + .. _profile-stats: The :class:`Stats` Class -- cgit v0.12 $$PHONON_MMF_DIR/effect.h \ + $$PHONON_MMF_DIR/fakesource.h \ + $$PHONON_MMF_DIR/iodevicereader.h \ + $$PHONON_MMF_DIR/mediagraph.h \ + $$PHONON_MMF_DIR/mediaobject.h \ + $$PHONON_MMF_DIR/videowidget.h \ + $$PHONON_MMF_DIR/videorenderer_soft.h \ + $$PHONON_MMF_DIR/videorenderer_vmr9.h \ + $$PHONON_MMF_DIR/volumeeffect.h \ + $$PHONON_MMF_DIR/qbasefilter.h \ + $$PHONON_MMF_DIR/qpin.h \ + $$PHONON_MMF_DIR/qasyncreader.h \ + $$PHONON_MMF_DIR/qaudiocdreader.h \ + $$PHONON_MMF_DIR/qmeminputpin.h \ + $$PHONON_MMF_DIR/compointer.h \ + $$PHONON_MMF_DIR/phononds9_namespace.h + + +SOURCES += \ + $$PHONON_MMF_DIR/abstractvideorenderer.cpp \ + $$PHONON_MMF_DIR/audiooutput.cpp \ + $$PHONON_MMF_DIR/backend.cpp \ + $$PHONON_MMF_DIR/backendnode.cpp \ + $$PHONON_MMF_DIR/effect.cpp \ + $$PHONON_MMF_DIR/fakesource.cpp \ + $$PHONON_MMF_DIR/iodevicereader.cpp \ + $$PHONON_MMF_DIR/mediagraph.cpp \ + $$PHONON_MMF_DIR/mediaobject.cpp \ + $$PHONON_MMF_DIR/videowidget.cpp \ + $$PHONON_MMF_DIR/videorenderer_soft.cpp \ + $$PHONON_MMF_DIR/videorenderer_vmr9.cpp \ + $$PHONON_MMF_DIR/volumeeffect.cpp \ + $$PHONON_MMF_DIR/qbasefilter.cpp \ + $$PHONON_MMF_DIR/qpin.cpp \ + $$PHONON_MMF_DIR/qasyncreader.cpp \ + $$PHONON_MMF_DIR/qaudiocdreader.cpp \ + $$PHONON_MMF_DIR/qmeminputpin.cpp + + +target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend +INSTALLS += target + +include(../../qpluginbase.pri) -- cgit v0.12 From a27d314863d38821f5122973be3fe5306ed82ef1 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 2 Jul 2009 15:51:37 +0200 Subject: Pouring. --- src/3rdparty/phonon/mmf/audiooutput.cpp | 52 +++++++++ src/3rdparty/phonon/mmf/audiooutput.h | 46 ++++++++ src/3rdparty/phonon/mmf/backend.cpp | 101 ++++++++++++++++++ src/3rdparty/phonon/mmf/backend.h | 49 +++++++++ src/3rdparty/phonon/mmf/mediaobject.cpp | 184 ++++++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/mediaobject.h | 87 +++++++++++++++ src/plugins/phonon/mmf/mmf.pro | 54 +++------- src/plugins/phonon/phonon.pro | 1 + 8 files changed, 532 insertions(+), 42 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/audiooutput.cpp create mode 100644 src/3rdparty/phonon/mmf/audiooutput.h create mode 100644 src/3rdparty/phonon/mmf/backend.cpp create mode 100644 src/3rdparty/phonon/mmf/backend.h create mode 100644 src/3rdparty/phonon/mmf/mediaobject.cpp create mode 100644 src/3rdparty/phonon/mmf/mediaobject.h diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp new file mode 100644 index 0000000..a66e079 --- /dev/null +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -0,0 +1,52 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "audiooutput.h" + +using namespace Phonon; +using namespace Phonon::MMF; + +AudioOutput::AudioOutput(Backend *, QObject *parent) +{ + setParent(parent); +} + +qreal AudioOutput::volume() const +{ + return 0; +} + +void AudioOutput::setVolume(qreal) +{ +} + +int AudioOutput::outputDevice() const +{ + return 0; +} + +bool AudioOutput::setOutputDevice(int) +{ + return true; +} + +bool AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) +{ + return true; +} + diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h new file mode 100644 index 0000000..4072756 --- /dev/null +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -0,0 +1,46 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_AUDIOOUTPUT_H +#define PHONON_MMF_AUDIOOUTPUT_H + +#include + +namespace Phonon +{ + namespace MMF + { + class Backend; + + class AudioOutput : public QObject + , public AudioOutputInterface42 + { + Q_OBJECT + public: + AudioOutput(Backend *backend, QObject *parent); + virtual qreal volume() const; + virtual void setVolume(qreal); + + virtual int outputDevice() const; + virtual bool setOutputDevice(int); + virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); + }; + } +} + +#endif diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp new file mode 100644 index 0000000..5b78158 --- /dev/null +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -0,0 +1,101 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include + +#include "backend.h" +#include "audiooutput.h" +#include "mediaobject.h" + +using namespace Phonon; +using namespace Phonon::MMF; + +Backend::Backend(QObject *parent) +{ + setParent(parent); + + setProperty("identifier", QLatin1String("mmf")); + setProperty("backendName", QLatin1String("MMF")); + setProperty("backendComment", QLatin1String("MMF Backend")); + setProperty("backendVersion", QLatin1String("0.1")); + setProperty("backendWebsite", QLatin1String("http://www.qtsoftware.com/")); +} + +QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &) +{ + switch(c) + { + case AudioOutputClass: + return new AudioOutput(this, parent); + case MediaObjectClass: + return new MediaObject(parent); + case VolumeFaderEffectClass: + /* Fallthrough. */ + case VisualizationClass: + /* Fallthrough. */ + case VideoDataOutputClass: + /* Fallthrough. */ + case EffectClass: + /* Fallthrough. */ + case VideoWidgetClass: + return 0; + } + + Q_ASSERT_X(false, Q_FUNC_INFO, + "This line should never be reached."); + return 0; +} + +QList Backend::objectDescriptionIndexes(ObjectDescriptionType) const +{ + return QList(); +} + +QHash Backend::objectDescriptionProperties(ObjectDescriptionType, int) const +{ + return QHash(); +} + +bool Backend::startConnectionChange(QSet) +{ + return false; +} + +bool Backend::connectNodes(QObject *, QObject *) +{ + return false; +} + +bool Backend::disconnectNodes(QObject *, QObject *) +{ + return false; +} + +bool Backend::endConnectionChange(QSet) +{ + return false; +} + +QStringList Backend::availableMimeTypes() const +{ + return QStringList(); +} + +Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend); + diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h new file mode 100644 index 0000000..cb03859 --- /dev/null +++ b/src/3rdparty/phonon/mmf/backend.h @@ -0,0 +1,49 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_BACKEND_H +#define PHONON_MMF_BACKEND_H + +#include +#include + +namespace Phonon +{ + namespace MMF + { + class Backend : public QObject + , public BackendInterface + { + Q_OBJECT + Q_INTERFACES(Phonon::BackendInterface) + public: + Backend(QObject *parent = 0); + + virtual QObject *createObject(BackendInterface::Class c, QObject *parent, const QList &args); + virtual QList objectDescriptionIndexes(ObjectDescriptionType type) const; + virtual QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const; + virtual bool startConnectionChange(QSet); + virtual bool connectNodes(QObject *, QObject *); + virtual bool disconnectNodes(QObject *, QObject *); + virtual bool endConnectionChange(QSet); + virtual QStringList availableMimeTypes() const; + }; + } +} + +#endif diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp new file mode 100644 index 0000000..2db56d6 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -0,0 +1,184 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "mediaobject.h" + +using namespace Phonon; +using namespace Phonon::MMF; + +MediaObject::MediaObject(QObject *parent) : m_player(0) + , m_error(NoError) + , m_state(StoppedState) +{ + Q_UNUSED(parent); + m_player = CDrmPlayerUtility::NewL(*this, 0, EMdaPriorityPreferenceNone); +} + +MediaObject::~MediaObject() +{ + delete m_player; +} + +void MediaObject::play() +{ + m_state = PlayingState; + m_player->Play(); +} + +void MediaObject::pause() +{ + m_state = PausedState; + m_player->Pause(); +} + +void MediaObject::stop() +{ + m_state = StoppedState; + m_player->Stop(); +} + +void MediaObject::seek(qint64 milliseconds) +{ + m_player->SetPosition(toMicroSeconds(milliseconds)); +} + +qint32 MediaObject::tickInterval() const +{ + return 0; +} + +void MediaObject::setTickInterval(qint32 interval) +{ + Q_UNUSED(interval); +} + +bool MediaObject::hasVideo() const +{ + return false; +} + +bool MediaObject::isSeekable() const +{ + return false; +} + +qint64 MediaObject::currentTime() const +{ + TTimeIntervalMicroSeconds mss; + const TInt retcode = m_player->GetPosition(mss); + + if(retcode == KErrNone) + return toMilliSeconds(m_player->Duration()); + else { + m_state = ErrorState; + m_error = NormalError; + return -1; + } +} + +Phonon::State MediaObject::state() const +{ + return m_state; +} + +QString MediaObject::errorString() const +{ + return QString(); +} + +Phonon::ErrorType MediaObject::errorType() const +{ + return m_error; +} + +qint64 MediaObject::toMilliSeconds(const TTimeIntervalMicroSeconds &in) +{ + return in.Int64() / 1000; +} + +TTimeIntervalMicroSeconds MediaObject::toMicroSeconds(qint64 ms) +{ + return TTimeIntervalMicroSeconds(TInt64(ms)); +} + +qint64 MediaObject::totalTime() const +{ + return toMilliSeconds(m_player->Duration()); +} + +MediaSource MediaObject::source() const +{ + return MediaSource(); +} + +void MediaObject::setSource(const MediaSource &source) +{ + stop(); + m_state = LoadingState; + + Q_UNUSED(source); + // TODO + + emit totalTimeChanged(); +} + +void MediaObject::setNextSource(const MediaSource &source) +{ + Q_UNUSED(source); +} + +qint32 MediaObject::prefinishMark() const +{ + return 0; +} + +void MediaObject::setPrefinishMark(qint32) +{ +} + +qint32 MediaObject::transitionTime() const +{ + return 0; +} + +void MediaObject::setTransitionTime(qint32) +{ +} + +void MediaObject::MaloLoadingComplete() +{ + m_state = StoppedState; +} + +void MediaObject::MaloLoadingStarted() +{ + m_state = LoadingState; +} + +void MediaObject::MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration) +{ + Q_UNUSED(aError); + Q_UNUSED(aDuration); +} + +void MediaObject::MdapcPlayComplete(TInt aError) +{ + Q_UNUSED(aError); +} + diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h new file mode 100644 index 0000000..80a774d --- /dev/null +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -0,0 +1,87 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_MEDIAOBJECT_H +#define PHONON_MMF_MEDIAOBJECT_H + +#include + +#include +#include + +class CDrmPlayerUtility; +class TTimeIntervalMicroSeconds; + +namespace Phonon +{ + namespace MMF + { + class MediaObject : public QObject + , public MediaObjectInterface + , public MDrmAudioPlayerCallback + { + Q_OBJECT + Q_INTERFACES(Phonon::MediaObjectInterface) + public: + MediaObject(QObject *parent); + virtual ~MediaObject(); + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual qint32 tickInterval() const; + virtual void setTickInterval(qint32 interval); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + virtual void setSource(const MediaSource &); + virtual void setNextSource(const MediaSource &source); + virtual qint32 prefinishMark() const; + virtual void setPrefinishMark(qint32); + virtual qint32 transitionTime() const; + virtual void setTransitionTime(qint32); + + // MAudioLoadingObserver + virtual void MaloLoadingComplete(); + virtual void MaloLoadingStarted(); + + // MDrmAudioPlayerCallback + virtual void MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MdapcPlayComplete(TInt aError); + + Q_SIGNALS: + void totalTimeChanged(); + + private: + static inline qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + static inline TTimeIntervalMicroSeconds toMicroSeconds(qint64 ms); + + CDrmPlayerUtility * m_player; + mutable ErrorType m_error; + mutable State m_state; + }; + } +} + +#endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 0c4bff7..381f119 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -2,53 +2,23 @@ DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend QT += phonon TARGET = phonon_mmf PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf +LIBS += -lDrmAudioPlayUtility.lib -# Input -HEADERS += \ - $$PHONON_MMF_DIR/abstractvideorenderer.h \ - $$PHONON_MMF_DIR/audiooutput.h \ - $$PHONON_MMF_DIR/backend.h \ - $$PHONON_MMF_DIR/backendnode.h \ - $$PHONON_MMF_DIR/effect.h \ - $$PHONON_MMF_DIR/fakesource.h \ - $$PHONON_MMF_DIR/iodevicereader.h \ - $$PHONON_MMF_DIR/mediagraph.h \ - $$PHONON_MMF_DIR/mediaobject.h \ - $$PHONON_MMF_DIR/videowidget.h \ - $$PHONON_MMF_DIR/videorenderer_soft.h \ - $$PHONON_MMF_DIR/videorenderer_vmr9.h \ - $$PHONON_MMF_DIR/volumeeffect.h \ - $$PHONON_MMF_DIR/qbasefilter.h \ - $$PHONON_MMF_DIR/qpin.h \ - $$PHONON_MMF_DIR/qasyncreader.h \ - $$PHONON_MMF_DIR/qaudiocdreader.h \ - $$PHONON_MMF_DIR/qmeminputpin.h \ - $$PHONON_MMF_DIR/compointer.h \ - $$PHONON_MMF_DIR/phononds9_namespace.h +HEADERS += \ + $$PHONON_MMF_DIR/audiooutput.h \ + $$PHONON_MMF_DIR/backend.h \ + $$PHONON_MMF_DIR/mediaobject.h - -SOURCES += \ - $$PHONON_MMF_DIR/abstractvideorenderer.cpp \ +SOURCES += \ $$PHONON_MMF_DIR/audiooutput.cpp \ - $$PHONON_MMF_DIR/backend.cpp \ - $$PHONON_MMF_DIR/backendnode.cpp \ - $$PHONON_MMF_DIR/effect.cpp \ - $$PHONON_MMF_DIR/fakesource.cpp \ - $$PHONON_MMF_DIR/iodevicereader.cpp \ - $$PHONON_MMF_DIR/mediagraph.cpp \ - $$PHONON_MMF_DIR/mediaobject.cpp \ - $$PHONON_MMF_DIR/videowidget.cpp \ - $$PHONON_MMF_DIR/videorenderer_soft.cpp \ - $$PHONON_MMF_DIR/videorenderer_vmr9.cpp \ - $$PHONON_MMF_DIR/volumeeffect.cpp \ - $$PHONON_MMF_DIR/qbasefilter.cpp \ - $$PHONON_MMF_DIR/qpin.cpp \ - $$PHONON_MMF_DIR/qasyncreader.cpp \ - $$PHONON_MMF_DIR/qaudiocdreader.cpp \ - $$PHONON_MMF_DIR/qmeminputpin.cpp - + $$PHONON_MMF_DIR/backend.cpp \ + $$PHONON_MMF_DIR/mediaobject.cpp target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend INSTALLS += target include(../../qpluginbase.pri) + +# In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this folder, as +# opposed to the public, where it is placed in epoc32/include. +INCLUDEPATH *= /epoc32/include/osextensions diff --git a/src/plugins/phonon/phonon.pro b/src/plugins/phonon/phonon.pro index e43a4c2..814a062 100644 --- a/src/plugins/phonon/phonon.pro +++ b/src/plugins/phonon/phonon.pro @@ -7,3 +7,4 @@ mac:contains(QT_CONFIG, phonon-backend): SUBDIRS *= qt7 win32:!wince*:contains(QT_CONFIG, phonon-backend): SUBDIRS *= ds9 wince*:contains(QT_CONFIG, phonon-backend): SUBDIRS *= waveout wince*:contains(QT_CONFIG, directshow): SUBDIRS *= ds9 +symbian:contains(QT_CONFIG, phonon-backend): SUBDIRS *= mmf -- cgit v0.12 From 0089269b13244e0a906443e30f39275bb0cc01f0 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 3 Jul 2009 15:52:24 +0200 Subject: Pouring. --- src/3rdparty/phonon/mmf/audiooutput.cpp | 38 ++++++++++++- src/3rdparty/phonon/mmf/audiooutput.h | 37 +++++++++++++ src/3rdparty/phonon/mmf/backend.cpp | 16 ++++-- src/3rdparty/phonon/mmf/mediaobject.cpp | 98 +++++++++++++++++++++++++-------- src/3rdparty/phonon/mmf/mediaobject.h | 27 +++++++-- 5 files changed, 184 insertions(+), 32 deletions(-) diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index a66e079..ddc48b0 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -16,12 +16,17 @@ along with this library. If not, see . */ +#include + +#include "mediaobject.h" #include "audiooutput.h" using namespace Phonon; using namespace Phonon::MMF; -AudioOutput::AudioOutput(Backend *, QObject *parent) +AudioOutput::AudioOutput(Backend *, QObject *parent) : m_mediaObject(0) + , m_volume(0) + , m_maxVolume(-1) { setParent(parent); } @@ -31,8 +36,19 @@ qreal AudioOutput::volume() const return 0; } -void AudioOutput::setVolume(qreal) +void AudioOutput::setVolume(qreal newVolume) { + if(!m_mediaObject) + return; + + Q_ASSERT(m_mediaObject->m_player); + + if (newVolume == m_volume) + return; + + m_volume = newVolume; + m_mediaObject->m_player->SetVolume(newVolume * m_maxVolume); + emit volumeChanged(m_volume); } int AudioOutput::outputDevice() const @@ -50,3 +66,21 @@ bool AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) return true; } +void AudioOutput::setMediaObject(MediaObject *mo) +{ + Q_ASSERT(m_mediaObject); + m_mediaObject = mo; + + Q_ASSERT(m_mediaObject->m_player); + m_maxVolume = m_mediaObject->m_player->MaxVolume(); + + TInt mmfVolume = 0; + const TInt errorCode = m_mediaObject->m_player->GetVolume(mmfVolume); + + if(errorCode == KErrNone) + return; + + m_volume = mmfVolume / m_maxVolume; + emit volumeChanged(m_volume); +} + diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 4072756..02dd046 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -26,7 +26,26 @@ namespace Phonon namespace MMF { class Backend; + class MediaObject; + /** + * @short AudioOutputInterface42 implementation for MMF. + * + * Implements the AudioOutputInterface42 for Symbian/S60's MMF + * framework. + * + * This class has a very small role, we simply access CDrmPlayerUtility + * in MediaObject::m_player and forward everything there. + * + * \section volume Volume + * + * Phonon's concept on volume is from 0.0 to 1.0, and from 1< it does + * voltage multiplication. CDrmPlayerUtility goes from 1 to + * CDrmPlayerUtility::MaxVolume(). We apply some basic math to convert + * between the two. + * + * @author Frans Englich + */ class AudioOutput : public QObject , public AudioOutputInterface42 { @@ -37,8 +56,26 @@ namespace Phonon virtual void setVolume(qreal); virtual int outputDevice() const; + + /** + * Has no effect. + */ virtual bool setOutputDevice(int); + + /** + * Has no effect. + */ virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); + + void setMediaObject(MediaObject *mo); + + Q_SIGNALS: + void volumeChanged(qreal newVolume); + + private: + MediaObject * m_mediaObject; + qreal m_volume; + TInt m_maxVolume; }; } } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 5b78158..9419fb8 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -77,19 +77,27 @@ bool Backend::startConnectionChange(QSet) return false; } -bool Backend::connectNodes(QObject *, QObject *) +bool Backend::connectNodes(QObject *source, QObject *target) { - return false; + MediaObject *const mo = qobject_cast(source); + AudioOutput *const ao = qobject_cast(target); + + if(!mo || !ao) + return false; + + ao->setMediaObject(mo); + + return true; } bool Backend::disconnectNodes(QObject *, QObject *) { - return false; + return true; } bool Backend::endConnectionChange(QSet) { - return false; + return true; } QStringList Backend::availableMimeTypes() const diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 2db56d6..79b7558 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -16,6 +16,9 @@ along with this library. If not, see . */ +#include +#include + #include "mediaobject.h" using namespace Phonon; @@ -27,6 +30,8 @@ MediaObject::MediaObject(QObject *parent) : m_player(0) { Q_UNUSED(parent); m_player = CDrmPlayerUtility::NewL(*this, 0, EMdaPriorityPreferenceNone); + + m_player->RegisterForAudioLoadingNotification(*this); } MediaObject::~MediaObject() @@ -36,19 +41,19 @@ MediaObject::~MediaObject() void MediaObject::play() { - m_state = PlayingState; + transitTo(PlayingState); m_player->Play(); } void MediaObject::pause() { - m_state = PausedState; + transitTo(PausedState); m_player->Pause(); } void MediaObject::stop() { - m_state = StoppedState; + transitTo(StoppedState); m_player->Stop(); } @@ -85,17 +90,12 @@ qint64 MediaObject::currentTime() const if(retcode == KErrNone) return toMilliSeconds(m_player->Duration()); else { - m_state = ErrorState; - m_error = NormalError; + // TODO Should we enter/emit error state? Tricky + // since we're in a const function. return -1; } } -Phonon::State MediaObject::state() const -{ - return m_state; -} - QString MediaObject::errorString() const { return QString(); @@ -123,22 +123,47 @@ qint64 MediaObject::totalTime() const MediaSource MediaObject::source() const { - return MediaSource(); + return m_mediaSource; } void MediaObject::setSource(const MediaSource &source) { stop(); - m_state = LoadingState; - - Q_UNUSED(source); - // TODO + m_mediaSource = source; + + switch(m_mediaSource.type()) + { + case MediaSource::LocalFile: + { + const QHBufC filename(source.fileName()); + m_player->OpenFileL(*filename); + break; + } + case MediaSource::Url: + { + const QHBufC filename(source.url().toString()); + m_player->OpenUrlL(*filename); + break; + } + case MediaSource::Invalid: + /* Fallthrough. */ + case MediaSource::Disc: + /* Fallthrough. */ + case MediaSource::Stream: + /* Fallthrough. */ + case MediaSource::Empty: + { + transitTo(ErrorState); + return; + } + } - emit totalTimeChanged(); + transitTo(LoadingState); } void MediaObject::setNextSource(const MediaSource &source) { + m_nextSource = source; Q_UNUSED(source); } @@ -162,23 +187,52 @@ void MediaObject::setTransitionTime(qint32) void MediaObject::MaloLoadingComplete() { - m_state = StoppedState; + transitTo(StoppedState); } void MediaObject::MaloLoadingStarted() { - m_state = LoadingState; + transitTo(LoadingState); } void MediaObject::MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration) + const TTimeIntervalMicroSeconds &) { - Q_UNUSED(aError); - Q_UNUSED(aDuration); + if(aError == KErrNone) { + m_error = NormalError; + m_state = ErrorState; + } + + emit totalTimeChanged(); + transitTo(StoppedState); } void MediaObject::MdapcPlayComplete(TInt aError) { - Q_UNUSED(aError); + if(aError == KErrNone) { + if(m_nextSource.type() == MediaSource::Empty) { + emit finished(); + } else { + setSource(m_nextSource); + m_nextSource = MediaSource(); + } + + transitTo(StoppedState); + } + else { + m_error = NormalError; + transitTo(ErrorState); + } +} + +void MediaObject::transitTo(Phonon::State newState) +{ + emit stateChanged(m_state, newState); + m_state = newState; +} + +Phonon::State MediaObject::state() const +{ + return m_state; } diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 80a774d..1512919 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -31,9 +31,12 @@ namespace Phonon { namespace MMF { + class AudioOutput; + class MediaObject : public QObject , public MediaObjectInterface , public MDrmAudioPlayerCallback + , public MAudioLoadingObserver { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface) @@ -64,22 +67,38 @@ namespace Phonon // MAudioLoadingObserver virtual void MaloLoadingComplete(); virtual void MaloLoadingStarted(); - + // MDrmAudioPlayerCallback virtual void MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); + const TTimeIntervalMicroSeconds &aDuration); virtual void MdapcPlayComplete(TInt aError); Q_SIGNALS: void totalTimeChanged(); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + + void finished(); private: + friend class AudioOutput; static inline qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); static inline TTimeIntervalMicroSeconds toMicroSeconds(qint64 ms); + /** + * Changes state() to \a newState, and emits stateChanged(). + */ + inline void transitTo(Phonon::State newState); + CDrmPlayerUtility * m_player; - mutable ErrorType m_error; - mutable State m_state; + ErrorType m_error; + + /** + * Never update this state by assigning to it. Call transitTo(). + */ + State m_state; + MediaSource m_mediaSource; + MediaSource m_nextSource; }; } } -- cgit v0.12 From 0e54042f2d339ecf85a89f8603317c32da265a90 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 3 Jul 2009 16:33:19 +0200 Subject: Load Helix backend before loading the Phonon backend. --- src/3rdparty/phonon/phonon/factory.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index 43c45ee..1026bb3 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -131,7 +131,23 @@ bool FactoryPrivate::createBackend() pDebug() << Q_FUNC_INFO << dir.absolutePath() << "does not exist"; continue; } - foreach (const QString &pluginName, dir.entryList(QDir::Files)) { + + QStringList plugins(dir.entryList(QDir::Files)); + +#ifdef Q_OS_SYMBIAN + /* On Symbian OS we might have two plugins, one which uses Symbian + * MMF framework("mmf"), and one which uses Real Networks's + * Helix("hxphonon"). We prefer the latter because it's more + * sophisticated, so we make sure the Helix backend is attempted + * to be loaded first, and the MMF backend is used for backup. */ + { + const int helix = plugins.indexof(QLatin1String("hxphonon")); + if (helix != -1) + plugins.move(helix, 0); + } +#endif + + foreach (const QString &pluginName, plugins) { QPluginLoader pluginLoader(libPath + pluginName); if (!pluginLoader.load()) { pDebug() << Q_FUNC_INFO << " load failed:" -- cgit v0.12 From 7ead0ff857d8f164e9cfa3f756a1b234a76eedc6 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 3 Jul 2009 16:38:27 +0200 Subject: Adjust comment field. --- src/3rdparty/phonon/mmf/backend.cpp | 2 +- src/3rdparty/phonon/phonon/factory.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 9419fb8..86d329b 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -32,7 +32,7 @@ Backend::Backend(QObject *parent) setProperty("identifier", QLatin1String("mmf")); setProperty("backendName", QLatin1String("MMF")); - setProperty("backendComment", QLatin1String("MMF Backend")); + setProperty("backendComment", QLatin1String("Backend using Nokia's S60 Multimedia Framework Architecture (MMF).")); setProperty("backendVersion", QLatin1String("0.1")); setProperty("backendWebsite", QLatin1String("http://www.qtsoftware.com/")); } diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index 1026bb3..34d04fa 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -141,9 +141,15 @@ bool FactoryPrivate::createBackend() * sophisticated, so we make sure the Helix backend is attempted * to be loaded first, and the MMF backend is used for backup. */ { - const int helix = plugins.indexof(QLatin1String("hxphonon")); + const int helix = plugins.indexOf(QLatin1String("hxphonon")); if (helix != -1) plugins.move(helix, 0); + + // Code for debugging the MMF backend. + if(helix != -1) { + qDebug() << "Found helix, and removed it from the lookup list."; + plugins.removeAll(QLatin1String("hxphonon")); + } } #endif -- cgit v0.12 From 975af6c3c81788e39422c55f67ffabfebd31d9be Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 13 Jul 2009 11:44:55 +0200 Subject: Build fixes, debug code. --- src/3rdparty/phonon/mmf/audiooutput.cpp | 18 +++++----- src/3rdparty/phonon/mmf/mediaobject.cpp | 64 ++++++++++++++++----------------- src/3rdparty/phonon/mmf/mediaobject.h | 10 ++++++ src/3rdparty/phonon/phonon/factory.cpp | 13 +++---- 4 files changed, 58 insertions(+), 47 deletions(-) diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index ddc48b0..9d1ff02 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -24,19 +24,19 @@ along with this library. If not, see . using namespace Phonon; using namespace Phonon::MMF; -AudioOutput::AudioOutput(Backend *, QObject *parent) : m_mediaObject(0) - , m_volume(0) - , m_maxVolume(-1) +MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : m_mediaObject(0) + , m_volume(0) + , m_maxVolume(-1) { setParent(parent); } -qreal AudioOutput::volume() const +qreal MMF::AudioOutput::volume() const { return 0; } -void AudioOutput::setVolume(qreal newVolume) +void MMF::AudioOutput::setVolume(qreal newVolume) { if(!m_mediaObject) return; @@ -51,22 +51,22 @@ void AudioOutput::setVolume(qreal newVolume) emit volumeChanged(m_volume); } -int AudioOutput::outputDevice() const +int MMF::AudioOutput::outputDevice() const { return 0; } -bool AudioOutput::setOutputDevice(int) +bool MMF::AudioOutput::setOutputDevice(int) { return true; } -bool AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) +bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) { return true; } -void AudioOutput::setMediaObject(MediaObject *mo) +void MMF::AudioOutput::setMediaObject(MediaObject *mo) { Q_ASSERT(m_mediaObject); m_mediaObject = mo; diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 79b7558..605fe24 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -24,9 +24,9 @@ along with this library. If not, see . using namespace Phonon; using namespace Phonon::MMF; -MediaObject::MediaObject(QObject *parent) : m_player(0) - , m_error(NoError) - , m_state(StoppedState) +MMF::MediaObject::MediaObject(QObject *parent) : m_player(0) + , m_error(NoError) + , m_state(StoppedState) { Q_UNUSED(parent); m_player = CDrmPlayerUtility::NewL(*this, 0, EMdaPriorityPreferenceNone); @@ -34,55 +34,55 @@ MediaObject::MediaObject(QObject *parent) : m_player(0) m_player->RegisterForAudioLoadingNotification(*this); } -MediaObject::~MediaObject() +MMF::MediaObject::~MediaObject() { delete m_player; } -void MediaObject::play() +void MMF::MediaObject::play() { transitTo(PlayingState); m_player->Play(); } -void MediaObject::pause() +void MMF::MediaObject::pause() { transitTo(PausedState); m_player->Pause(); } -void MediaObject::stop() +void MMF::MediaObject::stop() { transitTo(StoppedState); m_player->Stop(); } -void MediaObject::seek(qint64 milliseconds) +void MMF::MediaObject::seek(qint64 milliseconds) { m_player->SetPosition(toMicroSeconds(milliseconds)); } -qint32 MediaObject::tickInterval() const +qint32 MMF::MediaObject::tickInterval() const { return 0; } -void MediaObject::setTickInterval(qint32 interval) +void MMF::MediaObject::setTickInterval(qint32 interval) { Q_UNUSED(interval); } -bool MediaObject::hasVideo() const +bool MMF::MediaObject::hasVideo() const { return false; } -bool MediaObject::isSeekable() const +bool MMF::MediaObject::isSeekable() const { return false; } -qint64 MediaObject::currentTime() const +qint64 MMF::MediaObject::currentTime() const { TTimeIntervalMicroSeconds mss; const TInt retcode = m_player->GetPosition(mss); @@ -96,37 +96,37 @@ qint64 MediaObject::currentTime() const } } -QString MediaObject::errorString() const +QString MMF::MediaObject::errorString() const { return QString(); } -Phonon::ErrorType MediaObject::errorType() const +Phonon::ErrorType MMF::MediaObject::errorType() const { return m_error; } -qint64 MediaObject::toMilliSeconds(const TTimeIntervalMicroSeconds &in) +qint64 MMF::MediaObject::toMilliSeconds(const TTimeIntervalMicroSeconds &in) { return in.Int64() / 1000; } -TTimeIntervalMicroSeconds MediaObject::toMicroSeconds(qint64 ms) +TTimeIntervalMicroSeconds MMF::MediaObject::toMicroSeconds(qint64 ms) { return TTimeIntervalMicroSeconds(TInt64(ms)); } -qint64 MediaObject::totalTime() const +qint64 MMF::MediaObject::totalTime() const { return toMilliSeconds(m_player->Duration()); } -MediaSource MediaObject::source() const +MediaSource MMF::MediaObject::source() const { return m_mediaSource; } -void MediaObject::setSource(const MediaSource &source) +void MMF::MediaObject::setSource(const MediaSource &source) { stop(); m_mediaSource = source; @@ -161,42 +161,42 @@ void MediaObject::setSource(const MediaSource &source) transitTo(LoadingState); } -void MediaObject::setNextSource(const MediaSource &source) +void MMF::MediaObject::setNextSource(const MediaSource &source) { m_nextSource = source; Q_UNUSED(source); } -qint32 MediaObject::prefinishMark() const +qint32 MMF::MediaObject::prefinishMark() const { return 0; } -void MediaObject::setPrefinishMark(qint32) +void MMF::MediaObject::setPrefinishMark(qint32) { } -qint32 MediaObject::transitionTime() const +qint32 MMF::MediaObject::transitionTime() const { return 0; } -void MediaObject::setTransitionTime(qint32) +void MMF::MediaObject::setTransitionTime(qint32) { } -void MediaObject::MaloLoadingComplete() +void MMF::MediaObject::MaloLoadingComplete() { transitTo(StoppedState); } -void MediaObject::MaloLoadingStarted() +void MMF::MediaObject::MaloLoadingStarted() { transitTo(LoadingState); } -void MediaObject::MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &) +void MMF::MediaObject::MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &) { if(aError == KErrNone) { m_error = NormalError; @@ -207,7 +207,7 @@ void MediaObject::MdapcInitComplete(TInt aError, transitTo(StoppedState); } -void MediaObject::MdapcPlayComplete(TInt aError) +void MMF::MediaObject::MdapcPlayComplete(TInt aError) { if(aError == KErrNone) { if(m_nextSource.type() == MediaSource::Empty) { @@ -225,13 +225,13 @@ void MediaObject::MdapcPlayComplete(TInt aError) } } -void MediaObject::transitTo(Phonon::State newState) +void MMF::MediaObject::transitTo(Phonon::State newState) { emit stateChanged(m_state, newState); m_state = newState; } -Phonon::State MediaObject::state() const +Phonon::State MMF::MediaObject::state() const { return m_state; } diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 1512919..3afa3b4 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -20,6 +20,7 @@ along with this library. If not, see . #define PHONON_MMF_MEDIAOBJECT_H #include +#include #include #include @@ -33,16 +34,25 @@ namespace Phonon { class AudioOutput; + /** + * + * See + * How to + * play a video file using CVideoPlayerUtility + */ class MediaObject : public QObject , public MediaObjectInterface , public MDrmAudioPlayerCallback , public MAudioLoadingObserver + //, public MVideoPlayerUtilityObserver { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface) public: MediaObject(QObject *parent); virtual ~MediaObject(); + + // MediaObjectInterface virtual void play(); virtual void pause(); virtual void stop(); diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index 34d04fa..d828756 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -125,6 +125,7 @@ bool FactoryPrivate::createBackend() // (finding the first loadable backend). const QLatin1String suffix("/phonon_backend/"); foreach (QString libPath, QCoreApplication::libraryPaths()) { + qDebug() << Q_FUNC_INFO << "Lookinng in" << libPath; libPath += suffix; const QDir dir(libPath); if (!dir.exists()) { @@ -136,18 +137,18 @@ bool FactoryPrivate::createBackend() #ifdef Q_OS_SYMBIAN /* On Symbian OS we might have two plugins, one which uses Symbian - * MMF framework("mmf"), and one which uses Real Networks's + * MMF framework("phonon_mmf"), and one which uses Real Networks's * Helix("hxphonon"). We prefer the latter because it's more * sophisticated, so we make sure the Helix backend is attempted * to be loaded first, and the MMF backend is used for backup. */ { - const int helix = plugins.indexOf(QLatin1String("hxphonon")); - if (helix != -1) - plugins.move(helix, 0); + const int hxphonon = plugins.indexOf(QLatin1String("hxphonon")); + if (hxphonon != -1) + plugins.move(hxphonon, 0); // Code for debugging the MMF backend. - if(helix != -1) { - qDebug() << "Found helix, and removed it from the lookup list."; + if(hxphonon != -1) { + qDebug() << "Found hxphonon backend and removed it from the lookup list."; plugins.removeAll(QLatin1String("hxphonon")); } } -- cgit v0.12 From 17c74f4f49f5cb7c62dc4d2300293f2e93b16a90 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Sat, 18 Jul 2009 06:02:32 +0200 Subject: Work. --- src/3rdparty/phonon/mmf/backend.cpp | 3 ++- src/3rdparty/phonon/mmf/backend.h | 3 +++ src/3rdparty/phonon/mmf/mediaobject.h | 6 +++++- src/plugins/phonon/mmf/mmf.pro | 10 +++++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 86d329b..4324409 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -28,9 +28,10 @@ using namespace Phonon::MMF; Backend::Backend(QObject *parent) { + qDebug() << Q_FUNC_INFO; setParent(parent); - setProperty("identifier", QLatin1String("mmf")); + setProperty("identifier", QLatin1String("phonon_mmf")); setProperty("backendName", QLatin1String("MMF")); setProperty("backendComment", QLatin1String("Backend using Nokia's S60 Multimedia Framework Architecture (MMF).")); setProperty("backendVersion", QLatin1String("0.1")); diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index cb03859..4fff204 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -42,6 +42,9 @@ namespace Phonon virtual bool disconnectNodes(QObject *, QObject *); virtual bool endConnectionChange(QSet); virtual QStringList availableMimeTypes() const; + + Q_SIGNALS: + void objectDescriptionChanged(ObjectDescriptionType); }; } } diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 3afa3b4..207cb91 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -19,8 +19,11 @@ along with this library. If not, see . #ifndef PHONON_MMF_MEDIAOBJECT_H #define PHONON_MMF_MEDIAOBJECT_H +/* We use the extra qualification include/ to avoid picking up the include + * Phonon has. */ +#include + #include -#include #include #include @@ -44,6 +47,7 @@ namespace Phonon , public MediaObjectInterface , public MDrmAudioPlayerCallback , public MAudioLoadingObserver + , public MVideoLoadingObserver //, public MVideoPlayerUtilityObserver { Q_OBJECT diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 381f119..1a1d435 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -2,7 +2,7 @@ DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend QT += phonon TARGET = phonon_mmf PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf -LIBS += -lDrmAudioPlayUtility.lib +LIBS += -lDrmAudioPlayUtility.lib HEADERS += \ $$PHONON_MMF_DIR/audiooutput.h \ @@ -22,3 +22,11 @@ include(../../qpluginbase.pri) # In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this folder, as # opposed to the public, where it is placed in epoc32/include. INCLUDEPATH *= /epoc32/include/osextensions + +# We need this to be able to resolve ambiguity for VideoPlayer.h. Phonon has +# it, and the SDK has it. +INCLUDEPATH *= /epoc32/include/osextensions /epoc32 + +# Temporary steal one of the reserved, until we know that this MMF plugin is +# turning into something at all. +symbian:TARGET.UID3=0x2001E627 -- cgit v0.12 From 3b08ceebd0c944f6d60bfced9b263371eb6379bc Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 21 Jul 2009 02:16:05 +0200 Subject: Include Phonon plugins for Symbian. --- src/plugins/plugins.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index c08056e..7fb1886 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -9,5 +9,5 @@ unix { !embedded:SUBDIRS *= graphicssystems embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers !win32:!embedded:!mac:SUBDIRS *= inputmethods -contains(QT_CONFIG, phonon): SUBDIRS *= phonon symbian:SUBDIRS = imageformats codecs iconengines s60 sqldrivers +contains(QT_CONFIG, phonon): SUBDIRS *= phonon -- cgit v0.12 From 127c93b8ab606740fa9c59de9ce6d10de91af412 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 21 Jul 2009 05:35:01 +0200 Subject: Add the Phonon MMF backend. --- src/s60installs/qt.iby | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby index 79edc56..edd0ab2 100644 --- a/src/s60installs/qt.iby +++ b/src/s60installs/qt.iby @@ -70,6 +70,9 @@ file=ABI_DIR\BUILD_DIR\qtwcodecs.dll SHARED_LIB_DIR\qtwcodecs.dll PAG // iconengines file=ABI_DIR\BUILD_DIR\qsvgicon.dll SHARED_LIB_DIR\qsvgicon.dll PAGED +// Phonon MMF backend +file=ABI_DIR\BUILD_DIR\phonon_mmf.dll SHARED_LIB_DIR\phonon_mmf.dll PAGED + S60_APP_RESOURCE(s60main) // imageformats stubs @@ -89,6 +92,9 @@ data=\epoc32\winscw\c\resource\qt\plugins\codecs\qtwcodecs.qtplugin res // iconengines stubs data=\epoc32\winscw\c\resource\qt\plugins\iconengines\qsvgicon.qtplugin resource\qt\plugins\iconengines\qsvgicon.qtplugin +// Phonon MMF backend +data=\epoc32\winscw\c\resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin + // Stub sis file data=ZSYSTEM\install\qt.sis System\Install\qt.sis -- cgit v0.12 From 287b6fbddde1e61776676996471256a3b487e4fd Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 21 Jul 2009 11:58:13 +0200 Subject: Deploy the Phonon MMF Plugin. --- src/s60installs/qt_libs.pro | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/qt_libs.pro index bd5c67f..376007e 100644 --- a/src/s60installs/qt_libs.pro +++ b/src/s60installs/qt_libs.pro @@ -54,7 +54,13 @@ symbian: { codecs_plugins.sources = qcncodecs.dll qjpcodecs.dll qtwcodecs.dll qkrcodecs.dll codecs_plugins.path = $$QT_PLUGINS_BASE_DIR/codecs - + + contains(QT_CONFIG, phonon_backend) { + phonon_backend_plugins.sources += phonon_mmf.dll + phonon_backend_plugins.path = $$QT_PLUGINS_BASE_DIR/phonon_backend + DEPLOYMENT += phonon_backend_plugins + } + DEPLOYMENT += qtresources qtlibraries imageformats_plugins codecs_plugins graphicssystems_plugins contains(QT_CONFIG, svg): { -- cgit v0.12 From 7bd7c88d4e555131af035cb7262a5b0b663f63f0 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 21 Jul 2009 13:29:39 +0200 Subject: Work. --- src/3rdparty/phonon/mmf/mediaobject.cpp | 30 ++++++++++++++++++++---------- src/3rdparty/phonon/mmf/mediaobject.h | 12 ++++++++---- src/plugins/phonon/mmf/mmf.pro | 10 ++++++---- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 605fe24..0763c42 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -185,16 +185,6 @@ void MMF::MediaObject::setTransitionTime(qint32) { } -void MMF::MediaObject::MaloLoadingComplete() -{ - transitTo(StoppedState); -} - -void MMF::MediaObject::MaloLoadingStarted() -{ - transitTo(LoadingState); -} - void MMF::MediaObject::MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &) { @@ -236,3 +226,23 @@ Phonon::State MMF::MediaObject::state() const return m_state; } +void MMF::MediaObject::MaloLoadingComplete() +{ + transitTo(StoppedState); +} + +void MMF::MediaObject::MaloLoadingStarted() +{ + transitTo(LoadingState); +} + +void MMF::MediaObject::MvloLoadingComplete() +{ + transitTo(StoppedState); +} + +void MMF::MediaObject::MvloLoadingStarted() +{ + transitTo(LoadingState); +} + diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 207cb91..ae3cbeb 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -78,15 +78,19 @@ namespace Phonon virtual qint32 transitionTime() const; virtual void setTransitionTime(qint32); - // MAudioLoadingObserver - virtual void MaloLoadingComplete(); - virtual void MaloLoadingStarted(); - // MDrmAudioPlayerCallback virtual void MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration); virtual void MdapcPlayComplete(TInt aError); + // MAudioLoadingObserver + virtual void MaloLoadingComplete(); + virtual void MaloLoadingStarted(); + + // MVideoLoadingObserver + virtual void MvloLoadingComplete(); + virtual void MvloLoadingStarted(); + Q_SIGNALS: void totalTimeChanged(); void stateChanged(Phonon::State oldState, diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 1a1d435..6d404f2 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -1,4 +1,3 @@ -DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend QT += phonon TARGET = phonon_mmf PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf @@ -14,6 +13,9 @@ SOURCES += \ $$PHONON_MMF_DIR/backend.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp +# This is needed for having the .qtplugin file properly created on Symbian. +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend + target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend INSTALLS += target @@ -23,9 +25,9 @@ include(../../qpluginbase.pri) # opposed to the public, where it is placed in epoc32/include. INCLUDEPATH *= /epoc32/include/osextensions -# We need this to be able to resolve ambiguity for VideoPlayer.h. Phonon has -# it, and the SDK has it. -INCLUDEPATH *= /epoc32/include/osextensions /epoc32 +# We need this to be able to resolve ambiguity for VideoPlayer.h. Phonon and +# the SDK has the header. +INCLUDEPATH *= /epoc32 # Temporary steal one of the reserved, until we know that this MMF plugin is # turning into something at all. -- cgit v0.12 From 1e08ccc646e4f07fd560c901ff7b56626ed98d1e Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 21 Jul 2009 16:09:27 +0200 Subject: Crash fixes. --- src/3rdparty/phonon/mmf/audiooutput.h | 8 +++++--- src/3rdparty/phonon/mmf/mediaobject.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 02dd046..8c0de1f 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -29,9 +29,9 @@ namespace Phonon class MediaObject; /** - * @short AudioOutputInterface42 implementation for MMF. + * @short AudioOutputInterface implementation for MMF. * - * Implements the AudioOutputInterface42 for Symbian/S60's MMF + * Implements the AudioOutputInterface for Symbian/S60's MMF * framework. * * This class has a very small role, we simply access CDrmPlayerUtility @@ -47,9 +47,11 @@ namespace Phonon * @author Frans Englich */ class AudioOutput : public QObject - , public AudioOutputInterface42 + , public AudioOutputInterface { Q_OBJECT + Q_INTERFACES(Phonon::AudioOutputInterface) + public: AudioOutput(Backend *backend, QObject *parent); virtual qreal volume() const; diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index ae3cbeb..0631e4a 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -52,6 +52,7 @@ namespace Phonon { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface) + public: MediaObject(QObject *parent); virtual ~MediaObject(); -- cgit v0.12 From 598ee0994a7ca14ef0bc4265dab99d716ba6f189 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 11 Aug 2009 17:19:51 +0200 Subject: Revert "QItemSelectionModel did not send selectionChanged signal when deleting an item" This reverts commit d13418effc5f00474541ae513a30c9a42c2a1cb3. --- src/gui/itemviews/qitemselectionmodel.cpp | 22 +------------------- src/gui/itemviews/qitemselectionmodel_p.h | 2 -- .../tst_qitemselectionmodel.cpp | 24 ---------------------- 3 files changed, 1 insertion(+), 47 deletions(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index 0f35ac1..9dad95f 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -593,30 +593,10 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare // update selectionsx QModelIndex tl = model->index(start, 0, parent); QModelIndex br = model->index(end, model->columnCount(parent) - 1, parent); - recursiveDeselect(QItemSelectionRange(tl, br)); + q->select(QItemSelection(tl, br), QItemSelectionModel::Deselect); finalize(); } -void QItemSelectionModelPrivate::recursiveDeselect(const QItemSelectionRange &range) -{ - Q_Q(QItemSelectionModel); - - QItemSelection sel(range.topLeft(), range.bottomRight()); - q->select(sel, QItemSelectionModel::Deselect); - - QModelIndexList idxList = range.indexes(); - QModelIndexList::const_iterator it = idxList.begin(); - for (; it != idxList.end(); ++it) - { - if (!model->hasChildren(*it)) - continue; - - const QModelIndex &firstChild = it->child(0,0); - const QModelIndex &lastChild = it->child(model->rowCount(*it) - 1, model->columnCount(*it) - 1); - recursiveDeselect(QItemSelectionRange(firstChild, lastChild)); - } -} - /*! \internal */ diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/gui/itemviews/qitemselectionmodel_p.h index 8176d4c..18ad506 100644 --- a/src/gui/itemviews/qitemselectionmodel_p.h +++ b/src/gui/itemviews/qitemselectionmodel_p.h @@ -77,8 +77,6 @@ public: void _q_layoutAboutToBeChanged(); void _q_layoutChanged(); - void recursiveDeselect(const QItemSelectionRange &range); - inline void remove(QList &r) { QList::const_iterator it = r.constBegin(); diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 05e23f1..0541b46 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -90,7 +90,6 @@ private slots: void merge(); void task119433_isRowSelected(); void task252069_rowIntersectsSelection(); - void task232634_childrenDeselectionSignal(); private: QAbstractItemModel *model; @@ -2188,28 +2187,5 @@ void tst_QItemSelectionModel::task252069_rowIntersectsSelection() QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); } -void tst_QItemSelectionModel::task232634_childrenDeselectionSignal() -{ - QStandardItemModel model; - - QStandardItem *parentItem = model.invisibleRootItem(); - for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); - parentItem->appendRow(item); - parentItem = item; - } - - QModelIndex root = model.index(0,0); - QModelIndex par = root.child(0,0); - QModelIndex sel = par.child(0,0); - - QItemSelectionModel selectionModel(&model); - selectionModel.select(sel, QItemSelectionModel::SelectCurrent); - - QSignalSpy deselectSpy(&selectionModel, SIGNAL(selectionChanged(const QItemSelection& , const QItemSelection&))); - model.removeRows(0, 1, root); - QVERIFY(deselectSpy.count() == 1); -} - QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" -- cgit v0.12 From 44265f30fb40baaecd4cda1b5aca0efeed6abc20 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 12 Aug 2009 16:11:00 +0200 Subject: Commit patch by Gareth. The patch originally contained all changed done to MMF Phonon, but this commit contains the changes only Gareth did. --- src/3rdparty/phonon/mmf/audiooutput.cpp | 50 ++- src/3rdparty/phonon/mmf/audiooutput.h | 13 +- src/3rdparty/phonon/mmf/backend.cpp | 3 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 523 +++++++++++++++++++++++++++----- src/3rdparty/phonon/mmf/mediaobject.h | 95 ++++-- src/3rdparty/phonon/mmf/utils.cpp | 46 +++ src/3rdparty/phonon/mmf/utils.h | 134 ++++++++ src/plugins/phonon/mmf/mmf.pro | 30 +- src/plugins/plugins.pro | 1 + 9 files changed, 765 insertions(+), 130 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/utils.cpp create mode 100644 src/3rdparty/phonon/mmf/utils.h diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 9d1ff02..9c8cb6b 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -16,39 +16,45 @@ along with this library. If not, see . */ -#include - #include "mediaobject.h" #include "audiooutput.h" +#include "utils.h" using namespace Phonon; using namespace Phonon::MMF; -MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : m_mediaObject(0) - , m_volume(0) - , m_maxVolume(-1) +MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : m_mediaObject(NULL) { setParent(parent); } qreal MMF::AudioOutput::volume() const { - return 0; + TRACE_CONTEXT(AudioOutput::volume, EAudioApi); + TRACE_ENTRY("m_mediaObject 0x%08x", m_mediaObject); + + const qreal result = m_mediaObject ? m_mediaObject->volume() : 0.0; + + TRACE_RETURN("%f", result); } -void MMF::AudioOutput::setVolume(qreal newVolume) +void MMF::AudioOutput::setVolume(qreal volume) { - if(!m_mediaObject) - return; + TRACE_CONTEXT(AudioOutput::setVolume, EAudioApi); + TRACE_ENTRY("volume %f", volume); - Q_ASSERT(m_mediaObject->m_player); + if(m_mediaObject and m_mediaObject->setVolume(volume)) + { + TRACE("emit volumeChanged(%f)", volume) + emit volumeChanged(volume); + } - if (newVolume == m_volume) - return; + TRACE_EXIT_0(); +} - m_volume = newVolume; - m_mediaObject->m_player->SetVolume(newVolume * m_maxVolume); - emit volumeChanged(m_volume); +void MMF::AudioOutput::triggerVolumeChanged(qreal volume) +{ + emit volumeChanged(volume); } int MMF::AudioOutput::outputDevice() const @@ -68,19 +74,7 @@ bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) void MMF::AudioOutput::setMediaObject(MediaObject *mo) { - Q_ASSERT(m_mediaObject); + Q_ASSERT(!m_mediaObject); m_mediaObject = mo; - - Q_ASSERT(m_mediaObject->m_player); - m_maxVolume = m_mediaObject->m_player->MaxVolume(); - - TInt mmfVolume = 0; - const TInt errorCode = m_mediaObject->m_player->GetVolume(mmfVolume); - - if(errorCode == KErrNone) - return; - - m_volume = mmfVolume / m_maxVolume; - emit volumeChanged(m_volume); } diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 8c0de1f..5e4fef2 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -55,7 +55,7 @@ namespace Phonon public: AudioOutput(Backend *backend, QObject *parent); virtual qreal volume() const; - virtual void setVolume(qreal); + virtual void setVolume(qreal volume); virtual int outputDevice() const; @@ -71,13 +71,18 @@ namespace Phonon void setMediaObject(MediaObject *mo); + /** + * Called by MediaObject to pass initial volume when clip has been + * successfully opened + */ + void triggerVolumeChanged(qreal volume); + Q_SIGNALS: - void volumeChanged(qreal newVolume); + void volumeChanged(qreal volume); + void audioDeviceFailed(); private: MediaObject * m_mediaObject; - qreal m_volume; - TInt m_maxVolume; }; } } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 4324409..3152603 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -75,7 +75,7 @@ QHash Backend::objectDescriptionProperties(ObjectDescripti bool Backend::startConnectionChange(QSet) { - return false; + return true; } bool Backend::connectNodes(QObject *source, QObject *target) @@ -87,6 +87,7 @@ bool Backend::connectNodes(QObject *source, QObject *target) return false; ao->setMediaObject(mo); + mo->setAudioOutput(ao); return true; } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 0763c42..8a4b76e 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -17,188 +17,473 @@ along with this library. If not, see . */ #include +#include #include #include "mediaobject.h" +#include "audiooutput.h" +#include "utils.h" using namespace Phonon; using namespace Phonon::MMF; -MMF::MediaObject::MediaObject(QObject *parent) : m_player(0) +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const qint32 DefaultTickInterval = 20; +const int NullMaxVolume = -1; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::MediaObject::MediaObject(QObject *parent) : m_player(NULL) + , m_audioOutput(NULL) , m_error(NoError) - , m_state(StoppedState) + , m_state(GroundState) + , m_tickInterval(DefaultTickInterval) + , m_tickTimer(NULL) + , m_volume(0.0) + , m_maxVolume(NullMaxVolume) { + TRACE_CONTEXT(MediaObject::MediaObject, EAudioApi); + TRACE_ENTRY_0(); + Q_UNUSED(parent); - m_player = CDrmPlayerUtility::NewL(*this, 0, EMdaPriorityPreferenceNone); - m_player->RegisterForAudioLoadingNotification(*this); + // TODO: should leaves be trapped in the constructor? + m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); + + m_tickTimer = new QTimer(this); + connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); + + TRACE_EXIT_0(); } MMF::MediaObject::~MediaObject() { + TRACE_CONTEXT(MediaObject::~MediaObject, EAudioApi); + TRACE_ENTRY_0(); + + delete m_tickTimer; delete m_player; + + TRACE_EXIT_0(); } +//----------------------------------------------------------------------------- +// MediaObjectInterface +//----------------------------------------------------------------------------- + void MMF::MediaObject::play() { - transitTo(PlayingState); - m_player->Play(); + TRACE_CONTEXT(MediaObject::play, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + // Is this the correct error? Really we want 'NotReadyError' + m_error = NormalError; + changeState(ErrorState); + break; + + case StoppedState: + case PausedState: + m_player->Play(); + m_tickTimer->start(m_tickInterval); + changeState(PlayingState); + break; + + case PlayingState: + case BufferingState: + case ErrorState: + // Do nothing + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); } void MMF::MediaObject::pause() { - transitTo(PausedState); - m_player->Pause(); + TRACE_CONTEXT(MediaObject::pause, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case PausedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + m_player->Pause(); + m_tickTimer->stop(); + changeState(PausedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); } void MMF::MediaObject::stop() { - transitTo(StoppedState); - m_player->Stop(); + TRACE_CONTEXT(MediaObject::stop, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + case PausedState: + m_player->Stop(); + m_tickTimer->stop(); + changeState(StoppedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); } -void MMF::MediaObject::seek(qint64 milliseconds) +void MMF::MediaObject::seek(qint64 ms) { - m_player->SetPosition(toMicroSeconds(milliseconds)); + TRACE_CONTEXT(MediaObject::seek, EAudioApi); + TRACE_ENTRY("state %d pos %Ld", m_state, ms); + + m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); + + TRACE_EXIT_0(); } qint32 MMF::MediaObject::tickInterval() const { - return 0; + TRACE_CONTEXT(MediaObject::tickInterval, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_RETURN("%d", m_tickInterval); } void MMF::MediaObject::setTickInterval(qint32 interval) { - Q_UNUSED(interval); + TRACE_CONTEXT(MediaObject::setTickInterval, EAudioApi); + TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); + + m_tickInterval = interval; + m_tickTimer->setInterval(interval); + + TRACE_EXIT_0(); } bool MMF::MediaObject::hasVideo() const { - return false; + TRACE_CONTEXT(MediaObject::hasVideo, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: re-factor this class so that audio playback and video playback are + // delegated to separate classes, which internally hoat a + // CMdaAudioPlayerUtility / CVideoPlayerUtility instance as appropriate. + + TRACE_RETURN("%d", false); } bool MMF::MediaObject::isSeekable() const { - return false; + TRACE_CONTEXT(MediaObject::isSeekable, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_RETURN("%d", true); +} + +Phonon::State MMF::MediaObject::state() const +{ + TRACE_CONTEXT(MediaObject::state, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const Phonon::State result = phononState(m_state); + + TRACE_RETURN("%d", result); } qint64 MMF::MediaObject::currentTime() const { - TTimeIntervalMicroSeconds mss; - const TInt retcode = m_player->GetPosition(mss); + TRACE_CONTEXT(MediaObject::currentTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); - if(retcode == KErrNone) - return toMilliSeconds(m_player->Duration()); - else { - // TODO Should we enter/emit error state? Tricky - // since we're in a const function. - return -1; + TTimeIntervalMicroSeconds us; + const TInt err = m_player->GetPosition(us); + + qint64 result = -1; + + if(KErrNone == err) { + result = toMilliSeconds(us); } + + TRACE_RETURN("%Ld", result); } QString MMF::MediaObject::errorString() const { - return QString(); + TRACE_CONTEXT(MediaObject::errorString, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_EXIT_0(); + // TODO: put in proper error strings + QString result; + return result; } Phonon::ErrorType MMF::MediaObject::errorType() const { - return m_error; -} + TRACE_CONTEXT(MediaObject::errorType, EAudioApi); + TRACE_ENTRY("state %d", m_state); -qint64 MMF::MediaObject::toMilliSeconds(const TTimeIntervalMicroSeconds &in) -{ - return in.Int64() / 1000; -} + const Phonon::ErrorType result = (ErrorState == m_state) + ? m_error : NoError; -TTimeIntervalMicroSeconds MMF::MediaObject::toMicroSeconds(qint64 ms) -{ - return TTimeIntervalMicroSeconds(TInt64(ms)); + TRACE_RETURN("%d", result); } qint64 MMF::MediaObject::totalTime() const { - return toMilliSeconds(m_player->Duration()); + TRACE_CONTEXT(MediaObject::totalTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const qint64 result = toMilliSeconds(m_player->Duration()); + + TRACE_RETURN("%Ld", result); } MediaSource MMF::MediaObject::source() const { + TRACE_CONTEXT(MediaObject::source, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_EXIT_0(); return m_mediaSource; } void MMF::MediaObject::setSource(const MediaSource &source) { - stop(); + TRACE_CONTEXT(MediaObject::setSource, EAudioApi); + TRACE_ENTRY("state %d source.type %d", m_state, source.type()); + + m_player->Close(); + changeState(GroundState); + + // TODO: is it correct to assign even if the media type is not supported in + // the switch statement below? m_mediaSource = source; + TInt symbianErr = KErrNone; + switch(m_mediaSource.type()) { case MediaSource::LocalFile: { - const QHBufC filename(source.fileName()); - m_player->OpenFileL(*filename); + // TODO: work out whose responsibility it is to ensure that paths + // are Symbian-style, i.e. have backslashes for path delimiters. + // Until then, use this utility function... + const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName()); + TRAP(symbianErr, m_player->OpenFileL(*filename)); break; } + case MediaSource::Url: { - const QHBufC filename(source.url().toString()); - m_player->OpenUrlL(*filename); + const QHBufC filename(m_mediaSource.url().toString()); + TRAP(symbianErr, m_player->OpenUrlL(*filename)); break; } + case MediaSource::Invalid: - /* Fallthrough. */ case MediaSource::Disc: - /* Fallthrough. */ case MediaSource::Stream: - /* Fallthrough. */ + symbianErr = KErrNotSupported; + break; + case MediaSource::Empty: - { - transitTo(ErrorState); + TRACE_EXIT_0(); return; - } + + // Protection against adding new media types and forgetting to update this switch + default: + TRACE_PANIC(InvalidMediaTypePanic); + } + + if(KErrNone == symbianErr) + { +#ifdef QT_PHONON_MMF_AUDIO_DRM + // There appears to be a bug in the CDrmPlayerUtility implementation (at least + // in S60 5.x) whereby the player does not check whether the loading observer + // pointer is null before dereferencing it. Therefore we must register for + // loading notification, even though we do nothing in the callback functions. + m_player->RegisterForAudioLoadingNotification(*this); +#endif + changeState(LoadingState); + } + else + { + // TODO: do something with the value of symbianErr? + m_error = NormalError; + changeState(ErrorState); } - transitTo(LoadingState); + TRACE_EXIT_0(); } void MMF::MediaObject::setNextSource(const MediaSource &source) { + TRACE_CONTEXT(MediaObject::setNextSource, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: handle 'next source' + m_nextSource = source; Q_UNUSED(source); + + TRACE_EXIT_0(); } qint32 MMF::MediaObject::prefinishMark() const { - return 0; + TRACE_CONTEXT(MediaObject::prefinishMark, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement prefinish mark + const qint32 result = 0; + TRACE_RETURN("%d", result); } -void MMF::MediaObject::setPrefinishMark(qint32) +void MMF::MediaObject::setPrefinishMark(qint32 mark) { + TRACE_CONTEXT(MediaObject::setPrefinishMark, EAudioApi); + TRACE_ENTRY("state %d mark %d", m_state, mark); + Q_UNUSED(mark); // to silence warnings in release builds + + // TODO: implement prefinish mark + + TRACE_EXIT_0(); } qint32 MMF::MediaObject::transitionTime() const { - return 0; + TRACE_CONTEXT(MediaObject::transitionTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement transition time + const qint32 result = 0; + TRACE_RETURN("%d", result); } -void MMF::MediaObject::setTransitionTime(qint32) +void MMF::MediaObject::setTransitionTime(qint32 time) { + TRACE_CONTEXT(MediaObject::setTransitionTime, EAudioApi); + TRACE_ENTRY("state %d time %d", m_state, time); + Q_UNUSED(time); // to silence warnings in release builds + + // TODO: implement transition time + + TRACE_EXIT_0(); } + +//----------------------------------------------------------------------------- +// Symbian multimedia client observer callbacks +//----------------------------------------------------------------------------- + +#ifdef QT_PHONON_MMF_AUDIO_DRM void MMF::MediaObject::MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &) +#else +void MMF::MediaObject::MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &) +#endif { - if(aError == KErrNone) { + TRACE_CONTEXT(MediaObject::MapcInitComplete, EAudioInternal); + TRACE_ENTRY("state %d error %d", m_state, aError); + + __ASSERT_ALWAYS(LoadingState == m_state, Utils::panic(InvalidStatePanic)); + + if(KErrNone == aError) + { + TInt volume = 0; + aError = m_player->GetVolume(volume); + if(KErrNone == aError) + { + m_maxVolume = m_player->MaxVolume(); + m_volume = static_cast(volume) / m_maxVolume; + + if(m_audioOutput) + { + // Trigger AudioOutput signal + m_audioOutput->triggerVolumeChanged(m_volume); + } + + emit totalTimeChanged(); + changeState(StoppedState); + } + } + else + { + // TODO: set different error states according to value of aError? m_error = NormalError; - m_state = ErrorState; + changeState(ErrorState); } - emit totalTimeChanged(); - transitTo(StoppedState); + TRACE_EXIT_0(); } +#ifdef QT_PHONON_MMF_AUDIO_DRM void MMF::MediaObject::MdapcPlayComplete(TInt aError) +#else +void MMF::MediaObject::MapcPlayComplete(TInt aError) +#endif { + TRACE_CONTEXT(MediaObject::MapcPlayComplete, EAudioInternal); + TRACE_ENTRY("state %d error %d", m_state, aError); + + m_tickTimer->stop(); + + if(KErrNone == aError) + { + changeState(StoppedState); + // TODO: move on to m_nextSource + } + else + { + // TODO: do something with aError? + m_error = NormalError; + changeState(ErrorState); + } + +/* if(aError == KErrNone) { if(m_nextSource.type() == MediaSource::Empty) { emit finished(); @@ -207,42 +492,140 @@ void MMF::MediaObject::MdapcPlayComplete(TInt aError) m_nextSource = MediaSource(); } - transitTo(StoppedState); + changeState(StoppedState); } else { m_error = NormalError; - transitTo(ErrorState); + changeState(ErrorState); } +*/ + + TRACE_EXIT_0(); } -void MMF::MediaObject::transitTo(Phonon::State newState) +#ifdef QT_PHONON_MMF_AUDIO_DRM +void MMF::MediaObject::MaloLoadingStarted() { - emit stateChanged(m_state, newState); - m_state = newState; + } -Phonon::State MMF::MediaObject::state() const +void MMF::MediaObject::MaloLoadingComplete() { - return m_state; + } +#endif // QT_PHONON_MMF_AUDIO_DRM -void MMF::MediaObject::MaloLoadingComplete() + +//----------------------------------------------------------------------------- +// Volume +//----------------------------------------------------------------------------- + +qreal MMF::MediaObject::volume() const { - transitTo(StoppedState); + return m_volume; } -void MMF::MediaObject::MaloLoadingStarted() +bool MMF::MediaObject::setVolume(qreal volume) { - transitTo(LoadingState); + TRACE_CONTEXT(MediaObject::setVolume, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + bool volumeChanged = false; + + switch(m_state) + { + case GroundState: + case LoadingState: + case ErrorState: + // Do nothing + break; + + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: + { + if(volume != m_volume) + { + const int err = m_player->SetVolume(volume * m_maxVolume); + if(KErrNone == err) + { + m_volume = volume; + volumeChanged = true; + } + else + { + m_error = NormalError; + changeState(ErrorState); + } + } + break; + } + + // Protection against adding new states and forgetting to update this + // switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_RETURN("%d", volumeChanged); } -void MMF::MediaObject::MvloLoadingComplete() +void MMF::MediaObject::setAudioOutput(AudioOutput* audioOutput) { - transitTo(StoppedState); + m_audioOutput = audioOutput; } -void MMF::MediaObject::MvloLoadingStarted() + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +qint64 MMF::MediaObject::toMilliSeconds(const TTimeIntervalMicroSeconds &in) { - transitTo(LoadingState); + return in.Int64() / 1000; } +Phonon::State MMF::MediaObject::phononState(PrivateState state) +{ + const Phonon::State phononState = + GroundState == state + ? Phonon::StoppedState + : static_cast(state); + + return phononState; +} + +void MMF::MediaObject::changeState(PrivateState newState) +{ + TRACE_CONTEXT(MediaObject::changeState, EAudioInternal); + TRACE_ENTRY("state %d newState %d", m_state, newState); + + // TODO: add some invariants to check that the transition is valid + + const Phonon::State currentPhononState = phononState(m_state); + const Phonon::State newPhononState = phononState(newState); + if(currentPhononState != newPhononState) + { + TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); + emit stateChanged(newPhononState, currentPhononState); + } + + m_state = newState; + + TRACE_EXIT_0(); +} + +void MMF::MediaObject::tick() +{ + TRACE_CONTEXT(MediaObject::tick, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + emit tick(currentTime()); + + TRACE_EXIT_0(); +} + + + + diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 0631e4a..f17580e 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -21,15 +21,24 @@ along with this library. If not, see . /* We use the extra qualification include/ to avoid picking up the include * Phonon has. */ -#include - -#include +#include #include #include class CDrmPlayerUtility; class TTimeIntervalMicroSeconds; +class QTimer; + +#ifdef QT_PHONON_MMF_AUDIO_DRM +#include +typedef CDrmPlayerUtility CPlayerType; +typedef MDrmAudioPlayerCallback MPlayerObserverType; +#else +#include +typedef CMdaAudioPlayerUtility CPlayerType; +typedef MMdaAudioPlayerCallback MPlayerObserverType; +#endif namespace Phonon { @@ -45,10 +54,10 @@ namespace Phonon */ class MediaObject : public QObject , public MediaObjectInterface - , public MDrmAudioPlayerCallback - , public MAudioLoadingObserver - , public MVideoLoadingObserver - //, public MVideoPlayerUtilityObserver + , public MPlayerObserverType // typedef +#ifdef QT_PHONON_MMF_AUDIO_DRM + , public MAudioLoadingObserver +#endif { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface) @@ -79,45 +88,91 @@ namespace Phonon virtual qint32 transitionTime() const; virtual void setTransitionTime(qint32); +#ifdef QT_PHONON_MMF_AUDIO_DRM // MDrmAudioPlayerCallback virtual void MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration); virtual void MdapcPlayComplete(TInt aError); // MAudioLoadingObserver - virtual void MaloLoadingComplete(); virtual void MaloLoadingStarted(); + virtual void MaloLoadingComplete(); +#else + // MMdaAudioPlayerCallback + virtual void MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MapcPlayComplete(TInt aError); +#endif + + qreal volume() const; + bool setVolume(qreal volume); - // MVideoLoadingObserver - virtual void MvloLoadingComplete(); - virtual void MvloLoadingStarted(); + void setAudioOutput(AudioOutput* audioOutput); Q_SIGNALS: void totalTimeChanged(); void stateChanged(Phonon::State oldState, Phonon::State newState); - void finished(); + void tick(qint64 time); + + private Q_SLOTS: + /** + * Receives signal from m_tickTimer + */ + void tick(); private: - friend class AudioOutput; - static inline qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - static inline TTimeIntervalMicroSeconds toMicroSeconds(qint64 ms); + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); /** - * Changes state() to \a newState, and emits stateChanged(). + * Defined private state enumeration in order to add GroundState */ - inline void transitTo(Phonon::State newState); + enum PrivateState + { + LoadingState = Phonon::LoadingState, + StoppedState = Phonon::StoppedState, + PlayingState = Phonon::PlayingState, + BufferingState = Phonon::BufferingState, + PausedState = Phonon::PausedState, + ErrorState = Phonon::ErrorState, + GroundState + }; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + static Phonon::State phononState(PrivateState state); + + /** + * Changes state and emits stateChanged() + */ + void changeState(PrivateState newState); + + /** + * Using CPlayerType typedef in order to be able to easily switch between + * CMdaAudioPlayerUtility and CDrmPlayerUtility + */ + CPlayerType* m_player; + + AudioOutput* m_audioOutput; - CDrmPlayerUtility * m_player; ErrorType m_error; /** - * Never update this state by assigning to it. Call transitTo(). + * Do not set this directly - call changeState() instead. */ - State m_state; + PrivateState m_state; + + qint32 m_tickInterval; + + QTimer* m_tickTimer; + MediaSource m_mediaSource; MediaSource m_nextSource; + + qreal m_volume; + int m_maxVolume; }; } } diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp new file mode 100644 index 0000000..aa87310 --- /dev/null +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -0,0 +1,46 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "utils.h" +#include + +using namespace Phonon; +using namespace Phonon::MMF; + +_LIT(PanicCategory, "Phonon::MMF"); + +void MMF::Utils::panic(PanicCode code) + { + User::Panic(PanicCategory, code); + } + +QHBufC MMF::Utils::symbianFilename(const QString& qtFilename) +{ + _LIT(ForwardSlash, "/"); + _LIT(BackwardSlash, "\\"); + + QHBufC result(qtFilename); + TInt pos = result->Find(ForwardSlash); + while(pos != KErrNotFound) + { + result->Des().Replace(pos, 1, BackwardSlash); + pos = result->Find(ForwardSlash); + } + + return result; +} diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h new file mode 100644 index 0000000..4b967fc --- /dev/null +++ b/src/3rdparty/phonon/mmf/utils.h @@ -0,0 +1,134 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_UTILS_H +#define PHONON_MMF_UTILS_H + +#include + +namespace Phonon +{ + namespace MMF + { + /** + * Panic codes for fatal errors + */ + enum PanicCode + { + InvalidStatePanic, + InvalidMediaTypePanic + }; + + namespace Utils + { + /** + * Raise a fatal exception + */ + void panic(PanicCode code); + + /** + * Translate forward slashes to backslashes + * + * \note This function is a temporary measure, for use until the + * responsibility for constructing valid file paths is + * determined. + */ + QHBufC symbianFilename(const QString& qtFilename); + } + + /** + * Available trace categories; + */ + enum TTraceCategory + { + /** + * Functions which map directly to the public Phonon audio API + */ + EAudioApi = 0x00000001, + + /** + * Internal functions in the audio implementation + */ + EAudioInternal = 0x00000002 + }; + + /** + * Mask indicating which trace categories are enabled + * + * Note that, at the moment, this is a compiled static constant. For + * runtime control over enabled trace categories, this could be replaced + * by a per-thread singleton object which owns the trace mask, and which + * exposes an API allowing it to be modified. + */ + static const TUint KTraceMask = 0xffffffff; + + /** + * Data structure used by tracing macros + */ + class TTraceContext + { + public: + TTraceContext(const TText* aFunction, const TUint aAddr, + const TUint aCategory=0) + : iFunction(aFunction), + iAddr(aAddr), + iCategory(aCategory) + { } + + /** + * Check whether iCategory appears in the trace mask + */ + TBool Enabled() const + { + return (iCategory == 0) or (iCategory & KTraceMask); + } + + const TText* iFunction; // Name of function + const TUint iAddr; // 'this' pointer + const TUint iCategory; + }; + + // Macros used internally by the trace system + #define _TRACE_PRINT RDebug::Print + #define _TRACE_TEXT(x) (TPtrC((const TText *)(x))) + #define _TRACE_MODULE Phonon::MMF + + // Macros available for use by implementation code +#ifdef _DEBUG + #define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat); + #define TRACE_ENTRY_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } + #define TRACE_ENTRY(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } + #define TRACE_EXIT_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } + #define TRACE_EXIT(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } + #define TRACE_RETURN(string, result) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "r Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, result); } return result; + #define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code); + #define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#else + #define TRACE_CONTEXT(_fn, _cat) + #define TRACE_ENTRY_0() + #define TRACE_ENTRY(string, args...) + #define TRACE_EXIT_0() + #define TRACE_EXIT(string, args...) + #define TRACE_RETURN(string, result) return result; + #define TRACE_PANIC(code) Utils::panic(code); + #define TRACE(string, args...) +#endif + } +} + +#endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 6d404f2..ee2d3f9 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -1,17 +1,37 @@ +# MMF Phonon backend + QT += phonon TARGET = phonon_mmf PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf -LIBS += -lDrmAudioPlayUtility.lib + +# Uncomment the following line in order to use the CDrmPlayerUtility client +# API for audio playback, rather than CMdaAudioPlayerUtility. +#CONFIG += phonon_mmf_audio_drm + +phonon_mmf_audio_drm { + LIBS += -lDrmAudioPlayUtility.lib + + # In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this + # folder, as opposed to the public, where it is placed in + # epoc32/include. + INCLUDEPATH *= /epoc32/include/osextensions + + DEFINES += QT_PHONON_MMF_AUDIO_DRM +} else { + LIBS += -lmediaclientaudio.lib +} HEADERS += \ $$PHONON_MMF_DIR/audiooutput.h \ $$PHONON_MMF_DIR/backend.h \ - $$PHONON_MMF_DIR/mediaobject.h + $$PHONON_MMF_DIR/mediaobject.h \ + $$PHONON_MMF_DIR/utils.h SOURCES += \ $$PHONON_MMF_DIR/audiooutput.cpp \ $$PHONON_MMF_DIR/backend.cpp \ - $$PHONON_MMF_DIR/mediaobject.cpp + $$PHONON_MMF_DIR/mediaobject.cpp \ + $$PHONON_MMF_DIR/utils.cpp # This is needed for having the .qtplugin file properly created on Symbian. QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend @@ -21,10 +41,6 @@ INSTALLS += target include(../../qpluginbase.pri) -# In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this folder, as -# opposed to the public, where it is placed in epoc32/include. -INCLUDEPATH *= /epoc32/include/osextensions - # We need this to be able to resolve ambiguity for VideoPlayer.h. Phonon and # the SDK has the header. INCLUDEPATH *= /epoc32 diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index db2e534..004b816 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -8,6 +8,7 @@ unix:!symbian { } !embedded:SUBDIRS *= graphicssystems embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers +!win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods symbian:SUBDIRS += s60 contains(QT_CONFIG, phonon): SUBDIRS *= phonon contains(QT_CONFIG, multimedia): SUBDIRS *= audio -- cgit v0.12 From c82bcc8a3bf2ab64db9ccbe7b8ec7ca1208e2edc Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 14 Aug 2009 13:42:39 +0100 Subject: Fixed a bug which prevented phonon from compiling --- src/3rdparty/phonon/phonon/factory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index e0b245e..f6e1a5b 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -133,6 +133,8 @@ bool FactoryPrivate::createBackend() continue; } + QStringList plugins(dir.entryList(QDir::Files)); + #ifdef Q_OS_SYMBIAN /* On Symbian OS we might have two plugins, one which uses Symbian * MMF framework("phonon_mmf"), and one which uses Real Networks's -- cgit v0.12 From 1ef8ddc53d3d2512bbe5afbd2e6fb26cae206944 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 14 Aug 2009 15:23:24 +0200 Subject: Pushing compile fix from Gareth, modified by me. Seems this code path was broken. --- src/3rdparty/phonon/phonon/factory.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index e0b245e..b14c2b9 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -133,6 +133,8 @@ bool FactoryPrivate::createBackend() continue; } + QStringList plugins(dir.entryList(QDir::Files)); + #ifdef Q_OS_SYMBIAN /* On Symbian OS we might have two plugins, one which uses Symbian * MMF framework("phonon_mmf"), and one which uses Real Networks's @@ -140,6 +142,7 @@ bool FactoryPrivate::createBackend() * sophisticated, so we make sure the Helix backend is attempted * to be loaded first, and the MMF backend is used for backup. */ { + const int hxphonon = plugins.indexOf(QLatin1String("hxphonon")); if (hxphonon != -1) plugins.move(hxphonon, 0); @@ -152,9 +155,8 @@ bool FactoryPrivate::createBackend() } #endif - const QStringList files = dir.entryList(QDir::Files); - for (int i = 0; i < files.count(); ++i) { - QPluginLoader pluginLoader(libPath + files.at(i)); + for (int i = 0; i < plugins.count(); ++i) { + QPluginLoader pluginLoader(libPath + plugins.at(i)); if (!pluginLoader.load()) { pDebug() << Q_FUNC_INFO << " load failed:" << pluginLoader.errorString(); -- cgit v0.12 From d10291404e189e3a57cda7fac6f69aa5f9629cae Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 17 Aug 2009 15:40:04 +0200 Subject: Refactor the media object such that we can do both video and sound. As per discussions with Gareth. --- src/3rdparty/phonon/mmf/abstractplayer.h | 53 +++ src/3rdparty/phonon/mmf/audiooutput.cpp | 2 + src/3rdparty/phonon/mmf/audioplayer.cpp | 631 ++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/audioplayer.h | 173 ++++++++ src/3rdparty/phonon/mmf/mediaobject.cpp | 499 +--------------------- src/3rdparty/phonon/mmf/mediaobject.h | 102 +---- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 577 +++++++++++++++++++++++++ src/3rdparty/phonon/mmf/mmf_videoplayer.h | 163 +++++++ src/plugins/phonon/mmf/mmf.pro | 27 +- 9 files changed, 1618 insertions(+), 609 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/abstractplayer.h create mode 100644 src/3rdparty/phonon/mmf/audioplayer.cpp create mode 100644 src/3rdparty/phonon/mmf/audioplayer.h create mode 100644 src/3rdparty/phonon/mmf/mmf_videoplayer.cpp create mode 100644 src/3rdparty/phonon/mmf/mmf_videoplayer.h diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h new file mode 100644 index 0000000..6452090 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -0,0 +1,53 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_ABSTRACTPLAYER_H +#define PHONON_MMF_ABSTRACTPLAYER_H + +#include +#include +#include + +namespace Phonon +{ + namespace MMF + { + class AbstractPlayer : public QObject + { + public: + virtual void play() = 0; + virtual void pause() = 0; + virtual void stop() = 0; + virtual void seek(qint64 milliseconds) = 0; + virtual qint32 tickInterval() const = 0; + virtual void setTickInterval() const = 0; + virtual bool hasVideo() const = 0; + virtual bool isSeekable() const = 0; + virtual qint64 currentTime() const = 0; + virtual Phonon::State state() const = 0; + virtual QString errorString() const = 0; + virtual Phonon::ErrorType errorType() const = 0; + virtual Phonon::MediaSource source() const = 0; + virtual void setSource(const Phonon::MediaSource &) = 0; + virtual void setNextSource(const Phonon::MediaSource &) = 0; + }; + } +} + +#endif + diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 9c8cb6b..d8758fd 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -16,6 +16,8 @@ along with this library. If not, see . */ +#include + #include "mediaobject.h" #include "audiooutput.h" #include "utils.h" diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp new file mode 100644 index 0000000..4dd2eb8 --- /dev/null +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -0,0 +1,631 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include +#include + +#include "audioplayer.h" +#include "audiooutput.h" +#include "utils.h" + +using namespace Phonon; +using namespace Phonon::MMF; + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const qint32 DefaultTickInterval = 20; +const int NullMaxVolume = -1; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AudioPlayer::AudioPlayer(QObject *parent) : m_player(NULL) + , m_audioOutput(NULL) + , m_error(NoError) + , m_state(GroundState) + , m_tickInterval(DefaultTickInterval) + , m_tickTimer(NULL) + , m_volume(0.0) + , m_maxVolume(NullMaxVolume) +{ + TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); + TRACE_ENTRY_0(); + + Q_UNUSED(parent); + + // TODO: should leaves be trapped in the constructor? + m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); + + m_tickTimer = new QTimer(this); + connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); + + TRACE_EXIT_0(); +} + +MMF::AudioPlayer::~AudioPlayer() +{ + TRACE_CONTEXT(AudioPlayer::~AudioPlayer, EAudioApi); + TRACE_ENTRY_0(); + + delete m_tickTimer; + delete m_player; + + TRACE_EXIT_0(); +} + +//----------------------------------------------------------------------------- +// AudioPlayerInterface +//----------------------------------------------------------------------------- + +void MMF::AudioPlayer::play() +{ + TRACE_CONTEXT(AudioPlayer::play, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + // Is this the correct error? Really we want 'NotReadyError' + m_error = NormalError; + changeState(ErrorState); + break; + + case StoppedState: + case PausedState: + m_player->Play(); + m_tickTimer->start(m_tickInterval); + changeState(PlayingState); + break; + + case PlayingState: + case BufferingState: + case ErrorState: + // Do nothing + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +} + +void MMF::AudioPlayer::pause() +{ + TRACE_CONTEXT(AudioPlayer::pause, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case PausedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + m_player->Pause(); + m_tickTimer->stop(); + changeState(PausedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +} + +void MMF::AudioPlayer::stop() +{ + TRACE_CONTEXT(AudioPlayer::stop, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + case PausedState: + m_player->Stop(); + m_tickTimer->stop(); + changeState(StoppedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +} + +void MMF::AudioPlayer::seek(qint64 ms) +{ + TRACE_CONTEXT(AudioPlayer::seek, EAudioApi); + TRACE_ENTRY("state %d pos %Ld", m_state, ms); + + m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); + + TRACE_EXIT_0(); +} + +qint32 MMF::AudioPlayer::tickInterval() const +{ + TRACE_CONTEXT(AudioPlayer::tickInterval, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_RETURN("%d", m_tickInterval); +} + +void MMF::AudioPlayer::setTickInterval(qint32 interval) +{ + TRACE_CONTEXT(AudioPlayer::setTickInterval, EAudioApi); + TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); + + m_tickInterval = interval; + m_tickTimer->setInterval(interval); + + TRACE_EXIT_0(); +} + +bool MMF::AudioPlayer::hasVideo() const +{ + TRACE_CONTEXT(AudioPlayer::hasVideo, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: re-factor this class so that audio playback and video playback are + // delegated to separate classes, which internally hoat a + // CMdaAudioPlayerUtility / CVideoPlayerUtility instance as appropriate. + + TRACE_RETURN("%d", false); +} + +bool MMF::AudioPlayer::isSeekable() const +{ + TRACE_CONTEXT(AudioPlayer::isSeekable, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_RETURN("%d", true); +} + +Phonon::State MMF::AudioPlayer::state() const +{ + TRACE_CONTEXT(AudioPlayer::state, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const Phonon::State result = phononState(m_state); + + TRACE_RETURN("%d", result); +} + +qint64 MMF::AudioPlayer::currentTime() const +{ + TRACE_CONTEXT(AudioPlayer::currentTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TTimeIntervalMicroSeconds us; + const TInt err = m_player->GetPosition(us); + + qint64 result = -1; + + if(KErrNone == err) { + result = toMilliSeconds(us); + } + + TRACE_RETURN("%Ld", result); +} + +QString MMF::AudioPlayer::errorString() const +{ + TRACE_CONTEXT(AudioPlayer::errorString, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_EXIT_0(); + // TODO: put in proper error strings + QString result; + return result; +} + +Phonon::ErrorType MMF::AudioPlayer::errorType() const +{ + TRACE_CONTEXT(AudioPlayer::errorType, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const Phonon::ErrorType result = (ErrorState == m_state) + ? m_error : NoError; + + TRACE_RETURN("%d", result); +} + +qint64 MMF::AudioPlayer::totalTime() const +{ + TRACE_CONTEXT(AudioPlayer::totalTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const qint64 result = toMilliSeconds(m_player->Duration()); + + TRACE_RETURN("%Ld", result); +} + +MediaSource MMF::AudioPlayer::source() const +{ + TRACE_CONTEXT(AudioPlayer::source, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_EXIT_0(); + return m_mediaSource; +} + +void MMF::AudioPlayer::setSource(const MediaSource &source) +{ + TRACE_CONTEXT(AudioPlayer::setSource, EAudioApi); + TRACE_ENTRY("state %d source.type %d", m_state, source.type()); + + m_player->Close(); + changeState(GroundState); + + // TODO: is it correct to assign even if the media type is not supported in + // the switch statement below? + m_mediaSource = source; + + TInt symbianErr = KErrNone; + + switch(m_mediaSource.type()) + { + case MediaSource::LocalFile: + { + // TODO: work out whose responsibility it is to ensure that paths + // are Symbian-style, i.e. have backslashes for path delimiters. + // Until then, use this utility function... + const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName()); + TRAP(symbianErr, m_player->OpenFileL(*filename)); + break; + } + + case MediaSource::Url: + { + const QHBufC filename(m_mediaSource.url().toString()); + TRAP(symbianErr, m_player->OpenUrlL(*filename)); + break; + } + + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + symbianErr = KErrNotSupported; + break; + + case MediaSource::Empty: + TRACE_EXIT_0(); + return; + + // Protection against adding new media types and forgetting to update this switch + default: + TRACE_PANIC(InvalidMediaTypePanic); + } + + if(KErrNone == symbianErr) + { +#ifdef QT_PHONON_MMF_AUDIO_DRM + // There appears to be a bug in the CDrmPlayerUtility implementation (at least + // in S60 5.x) whereby the player does not check whether the loading observer + // pointer is null before dereferencing it. Therefore we must register for + // loading notification, even though we do nothing in the callback functions. + m_player->RegisterForAudioLoadingNotification(*this); +#endif + changeState(LoadingState); + } + else + { + // TODO: do something with the value of symbianErr? + m_error = NormalError; + changeState(ErrorState); + } + + TRACE_EXIT_0(); +} + +void MMF::AudioPlayer::setNextSource(const MediaSource &source) +{ + TRACE_CONTEXT(AudioPlayer::setNextSource, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: handle 'next source' + + m_nextSource = source; + Q_UNUSED(source); + + TRACE_EXIT_0(); +} + +qint32 MMF::AudioPlayer::prefinishMark() const +{ + TRACE_CONTEXT(AudioPlayer::prefinishMark, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement prefinish mark + const qint32 result = 0; + TRACE_RETURN("%d", result); +} + +void MMF::AudioPlayer::setPrefinishMark(qint32 mark) +{ + TRACE_CONTEXT(AudioPlayer::setPrefinishMark, EAudioApi); + TRACE_ENTRY("state %d mark %d", m_state, mark); + Q_UNUSED(mark); // to silence warnings in release builds + + // TODO: implement prefinish mark + + TRACE_EXIT_0(); +} + +qint32 MMF::AudioPlayer::transitionTime() const +{ + TRACE_CONTEXT(AudioPlayer::transitionTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement transition time + const qint32 result = 0; + TRACE_RETURN("%d", result); +} + +void MMF::AudioPlayer::setTransitionTime(qint32 time) +{ + TRACE_CONTEXT(AudioPlayer::setTransitionTime, EAudioApi); + TRACE_ENTRY("state %d time %d", m_state, time); + Q_UNUSED(time); // to silence warnings in release builds + + // TODO: implement transition time + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- +// Symbian multimedia client observer callbacks +//----------------------------------------------------------------------------- + +#ifdef QT_PHONON_MMF_AUDIO_DRM +void MMF::AudioPlayer::MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &) +#else +void MMF::AudioPlayer::MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &) +#endif +{ + TRACE_CONTEXT(AudioPlayer::MapcInitComplete, EAudioInternal); + TRACE_ENTRY("state %d error %d", m_state, aError); + + __ASSERT_ALWAYS(LoadingState == m_state, Utils::panic(InvalidStatePanic)); + + if(KErrNone == aError) + { + TInt volume = 0; + aError = m_player->GetVolume(volume); + if(KErrNone == aError) + { + m_maxVolume = m_player->MaxVolume(); + m_volume = static_cast(volume) / m_maxVolume; + + if(m_audioOutput) + { + // Trigger AudioOutput signal + m_audioOutput->triggerVolumeChanged(m_volume); + } + + emit totalTimeChanged(); + changeState(StoppedState); + } + } + else + { + // TODO: set different error states according to value of aError? + m_error = NormalError; + changeState(ErrorState); + } + + TRACE_EXIT_0(); +} + +#ifdef QT_PHONON_MMF_AUDIO_DRM +void MMF::AudioPlayer::MdapcPlayComplete(TInt aError) +#else +void MMF::AudioPlayer::MapcPlayComplete(TInt aError) +#endif +{ + TRACE_CONTEXT(AudioPlayer::MapcPlayComplete, EAudioInternal); + TRACE_ENTRY("state %d error %d", m_state, aError); + + m_tickTimer->stop(); + + if(KErrNone == aError) + { + changeState(StoppedState); + // TODO: move on to m_nextSource + } + else + { + // TODO: do something with aError? + m_error = NormalError; + changeState(ErrorState); + } + +/* + if(aError == KErrNone) { + if(m_nextSource.type() == MediaSource::Empty) { + emit finished(); + } else { + setSource(m_nextSource); + m_nextSource = MediaSource(); + } + + changeState(StoppedState); + } + else { + m_error = NormalError; + changeState(ErrorState); + } +*/ + + TRACE_EXIT_0(); +} + +#ifdef QT_PHONON_MMF_AUDIO_DRM +void MMF::AudioPlayer::MaloLoadingStarted() +{ + +} + +void MMF::AudioPlayer::MaloLoadingComplete() +{ + +} +#endif // QT_PHONON_MMF_AUDIO_DRM + + +//----------------------------------------------------------------------------- +// Volume +//----------------------------------------------------------------------------- + +qreal MMF::AudioPlayer::volume() const +{ + return m_volume; +} + +bool MMF::AudioPlayer::setVolume(qreal volume) +{ + TRACE_CONTEXT(AudioPlayer::setVolume, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + bool volumeChanged = false; + + switch(m_state) + { + case GroundState: + case LoadingState: + case ErrorState: + // Do nothing + break; + + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: + { + if(volume != m_volume) + { + const int err = m_player->SetVolume(volume * m_maxVolume); + if(KErrNone == err) + { + m_volume = volume; + volumeChanged = true; + } + else + { + m_error = NormalError; + changeState(ErrorState); + } + } + break; + } + + // Protection against adding new states and forgetting to update this + // switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_RETURN("%d", volumeChanged); +} + +void MMF::AudioPlayer::setAudioOutput(AudioOutput* audioOutput) +{ + m_audioOutput = audioOutput; +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +qint64 MMF::AudioPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) +{ + return in.Int64() / 1000; +} + +Phonon::State MMF::AudioPlayer::phononState(PrivateState state) +{ + const Phonon::State phononState = + GroundState == state + ? Phonon::StoppedState + : static_cast(state); + + return phononState; +} + +void MMF::AudioPlayer::changeState(PrivateState newState) +{ + TRACE_CONTEXT(AudioPlayer::changeState, EAudioInternal); + TRACE_ENTRY("state %d newState %d", m_state, newState); + + // TODO: add some invariants to check that the transition is valid + + const Phonon::State currentPhononState = phononState(m_state); + const Phonon::State newPhononState = phononState(newState); + if(currentPhononState != newPhononState) + { + TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); + emit stateChanged(newPhononState, currentPhononState); + } + + m_state = newState; + + TRACE_EXIT_0(); +} + +void MMF::AudioPlayer::tick() +{ + TRACE_CONTEXT(AudioPlayer::tick, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + emit tick(currentTime()); + + TRACE_EXIT_0(); +} + + + + diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h new file mode 100644 index 0000000..d9a64e1 --- /dev/null +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -0,0 +1,173 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_AUDIOPLAYER_H +#define PHONON_MMF_AUDIOPLAYER_H + +#include "abstractplayer.h" + +class CDrmPlayerUtility; +class TTimeIntervalMicroSeconds; +class QTimer; + +#ifdef QT_PHONON_MMF_AUDIO_DRM +#include +typedef CDrmPlayerUtility CPlayerType; +typedef MDrmAudioPlayerCallback MPlayerObserverType; +#else +#include +typedef CMdaAudioPlayerUtility CPlayerType; +typedef MMdaAudioPlayerCallback MPlayerObserverType; +#endif + +namespace Phonon +{ + namespace MMF + { + class AudioOutput; + + /** + * + * See + * How to + * play a video file using CVideoPlayerUtility + */ + class AudioPlayer : public AbstractPlayer + , public MPlayerObserverType // typedef +#ifdef QT_PHONON_MMF_AUDIO_DRM + , public MAudioLoadingObserver +#endif + { + Q_OBJECT + + public: + AudioPlayer(QObject *parent); + virtual ~AudioPlayer(); + + // AbstractPlayer + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual qint32 tickInterval() const; + virtual void setTickInterval(qint32 interval); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + virtual void setSource(const MediaSource &); + virtual void setNextSource(const MediaSource &source); + virtual qint32 prefinishMark() const; + virtual void setPrefinishMark(qint32); + virtual qint32 transitionTime() const; + virtual void setTransitionTime(qint32); + +#ifdef QT_PHONON_MMF_AUDIO_DRM + // MDrmAudioPlayerCallback + virtual void MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MdapcPlayComplete(TInt aError); + + // MAudioLoadingObserver + virtual void MaloLoadingStarted(); + virtual void MaloLoadingComplete(); +#else + // MMdaAudioPlayerCallback + virtual void MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MapcPlayComplete(TInt aError); +#endif + + qreal volume() const; + bool setVolume(qreal volume); + + void setAudioOutput(AudioOutput* audioOutput); + + Q_SIGNALS: + void totalTimeChanged(); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + void finished(); + void tick(qint64 time); + + private Q_SLOTS: + /** + * Receives signal from m_tickTimer + */ + void tick(); + + private: + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + + /** + * Defined private state enumeration in order to add GroundState + */ + enum PrivateState + { + LoadingState = Phonon::LoadingState, + StoppedState = Phonon::StoppedState, + PlayingState = Phonon::PlayingState, + BufferingState = Phonon::BufferingState, + PausedState = Phonon::PausedState, + ErrorState = Phonon::ErrorState, + GroundState + }; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + static Phonon::State phononState(PrivateState state); + + /** + * Changes state and emits stateChanged() + */ + void changeState(PrivateState newState); + + /** + * Using CPlayerType typedef in order to be able to easily switch between + * CMdaAudioPlayerUtility and CDrmPlayerUtility + */ + CPlayerType* m_player; + + AudioOutput* m_audioOutput; + + ErrorType m_error; + + /** + * Do not set this directly - call changeState() instead. + */ + PrivateState m_state; + + qint32 m_tickInterval; + + QTimer* m_tickTimer; + + MediaSource m_mediaSource; + MediaSource m_nextSource; + + qreal m_volume; + int m_maxVolume; + }; + } +} + +#endif diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 8a4b76e..fb079f0 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -16,61 +16,21 @@ along with this library. If not, see . */ -#include -#include -#include - #include "mediaobject.h" -#include "audiooutput.h" -#include "utils.h" using namespace Phonon; using namespace Phonon::MMF; //----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const qint32 DefaultTickInterval = 20; -const int NullMaxVolume = -1; - - -//----------------------------------------------------------------------------- // Constructor / destructor //----------------------------------------------------------------------------- -MMF::MediaObject::MediaObject(QObject *parent) : m_player(NULL) - , m_audioOutput(NULL) - , m_error(NoError) - , m_state(GroundState) - , m_tickInterval(DefaultTickInterval) - , m_tickTimer(NULL) - , m_volume(0.0) - , m_maxVolume(NullMaxVolume) +MMF::MediaObject::MediaObject(QObject *parent) : QObject::QObject(parent) { - TRACE_CONTEXT(MediaObject::MediaObject, EAudioApi); - TRACE_ENTRY_0(); - - Q_UNUSED(parent); - - // TODO: should leaves be trapped in the constructor? - m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); - - m_tickTimer = new QTimer(this); - connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); - - TRACE_EXIT_0(); } MMF::MediaObject::~MediaObject() { - TRACE_CONTEXT(MediaObject::~MediaObject, EAudioApi); - TRACE_ENTRY_0(); - - delete m_tickTimer; - delete m_player; - - TRACE_EXIT_0(); } //----------------------------------------------------------------------------- @@ -79,442 +39,84 @@ MMF::MediaObject::~MediaObject() void MMF::MediaObject::play() { - TRACE_CONTEXT(MediaObject::play, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - // Is this the correct error? Really we want 'NotReadyError' - m_error = NormalError; - changeState(ErrorState); - break; - - case StoppedState: - case PausedState: - m_player->Play(); - m_tickTimer->start(m_tickInterval); - changeState(PlayingState); - break; - - case PlayingState: - case BufferingState: - case ErrorState: - // Do nothing - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); } void MMF::MediaObject::pause() { - TRACE_CONTEXT(MediaObject::pause, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case PausedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - m_player->Pause(); - m_tickTimer->stop(); - changeState(PausedState); - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); } void MMF::MediaObject::stop() { - TRACE_CONTEXT(MediaObject::stop, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - case PausedState: - m_player->Stop(); - m_tickTimer->stop(); - changeState(StoppedState); - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); } void MMF::MediaObject::seek(qint64 ms) { - TRACE_CONTEXT(MediaObject::seek, EAudioApi); - TRACE_ENTRY("state %d pos %Ld", m_state, ms); - - m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); - - TRACE_EXIT_0(); + Q_UNUSED(ms); } qint32 MMF::MediaObject::tickInterval() const { - TRACE_CONTEXT(MediaObject::tickInterval, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_RETURN("%d", m_tickInterval); } void MMF::MediaObject::setTickInterval(qint32 interval) { - TRACE_CONTEXT(MediaObject::setTickInterval, EAudioApi); - TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); - - m_tickInterval = interval; - m_tickTimer->setInterval(interval); - - TRACE_EXIT_0(); } bool MMF::MediaObject::hasVideo() const { - TRACE_CONTEXT(MediaObject::hasVideo, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: re-factor this class so that audio playback and video playback are - // delegated to separate classes, which internally hoat a - // CMdaAudioPlayerUtility / CVideoPlayerUtility instance as appropriate. - - TRACE_RETURN("%d", false); } bool MMF::MediaObject::isSeekable() const { - TRACE_CONTEXT(MediaObject::isSeekable, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_RETURN("%d", true); } Phonon::State MMF::MediaObject::state() const { - TRACE_CONTEXT(MediaObject::state, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const Phonon::State result = phononState(m_state); - - TRACE_RETURN("%d", result); } qint64 MMF::MediaObject::currentTime() const { - TRACE_CONTEXT(MediaObject::currentTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TTimeIntervalMicroSeconds us; - const TInt err = m_player->GetPosition(us); - - qint64 result = -1; - - if(KErrNone == err) { - result = toMilliSeconds(us); - } - - TRACE_RETURN("%Ld", result); } QString MMF::MediaObject::errorString() const { - TRACE_CONTEXT(MediaObject::errorString, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_EXIT_0(); - // TODO: put in proper error strings - QString result; - return result; } Phonon::ErrorType MMF::MediaObject::errorType() const { - TRACE_CONTEXT(MediaObject::errorType, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const Phonon::ErrorType result = (ErrorState == m_state) - ? m_error : NoError; - - TRACE_RETURN("%d", result); } qint64 MMF::MediaObject::totalTime() const { - TRACE_CONTEXT(MediaObject::totalTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const qint64 result = toMilliSeconds(m_player->Duration()); - - TRACE_RETURN("%Ld", result); } MediaSource MMF::MediaObject::source() const { - TRACE_CONTEXT(MediaObject::source, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_EXIT_0(); - return m_mediaSource; } void MMF::MediaObject::setSource(const MediaSource &source) { - TRACE_CONTEXT(MediaObject::setSource, EAudioApi); - TRACE_ENTRY("state %d source.type %d", m_state, source.type()); - - m_player->Close(); - changeState(GroundState); - - // TODO: is it correct to assign even if the media type is not supported in - // the switch statement below? - m_mediaSource = source; - - TInt symbianErr = KErrNone; - - switch(m_mediaSource.type()) - { - case MediaSource::LocalFile: - { - // TODO: work out whose responsibility it is to ensure that paths - // are Symbian-style, i.e. have backslashes for path delimiters. - // Until then, use this utility function... - const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName()); - TRAP(symbianErr, m_player->OpenFileL(*filename)); - break; - } - - case MediaSource::Url: - { - const QHBufC filename(m_mediaSource.url().toString()); - TRAP(symbianErr, m_player->OpenUrlL(*filename)); - break; - } - - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - symbianErr = KErrNotSupported; - break; - - case MediaSource::Empty: - TRACE_EXIT_0(); - return; - - // Protection against adding new media types and forgetting to update this switch - default: - TRACE_PANIC(InvalidMediaTypePanic); - } - - if(KErrNone == symbianErr) - { -#ifdef QT_PHONON_MMF_AUDIO_DRM - // There appears to be a bug in the CDrmPlayerUtility implementation (at least - // in S60 5.x) whereby the player does not check whether the loading observer - // pointer is null before dereferencing it. Therefore we must register for - // loading notification, even though we do nothing in the callback functions. - m_player->RegisterForAudioLoadingNotification(*this); -#endif - changeState(LoadingState); - } - else - { - // TODO: do something with the value of symbianErr? - m_error = NormalError; - changeState(ErrorState); - } - - TRACE_EXIT_0(); } void MMF::MediaObject::setNextSource(const MediaSource &source) { - TRACE_CONTEXT(MediaObject::setNextSource, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: handle 'next source' - - m_nextSource = source; - Q_UNUSED(source); - - TRACE_EXIT_0(); } qint32 MMF::MediaObject::prefinishMark() const { - TRACE_CONTEXT(MediaObject::prefinishMark, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement prefinish mark - const qint32 result = 0; - TRACE_RETURN("%d", result); } void MMF::MediaObject::setPrefinishMark(qint32 mark) { - TRACE_CONTEXT(MediaObject::setPrefinishMark, EAudioApi); - TRACE_ENTRY("state %d mark %d", m_state, mark); - Q_UNUSED(mark); // to silence warnings in release builds - - // TODO: implement prefinish mark - - TRACE_EXIT_0(); } qint32 MMF::MediaObject::transitionTime() const { - TRACE_CONTEXT(MediaObject::transitionTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement transition time - const qint32 result = 0; - TRACE_RETURN("%d", result); } void MMF::MediaObject::setTransitionTime(qint32 time) { - TRACE_CONTEXT(MediaObject::setTransitionTime, EAudioApi); - TRACE_ENTRY("state %d time %d", m_state, time); - Q_UNUSED(time); // to silence warnings in release builds - - // TODO: implement transition time - - TRACE_EXIT_0(); -} - - -//----------------------------------------------------------------------------- -// Symbian multimedia client observer callbacks -//----------------------------------------------------------------------------- - -#ifdef QT_PHONON_MMF_AUDIO_DRM -void MMF::MediaObject::MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &) -#else -void MMF::MediaObject::MapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &) -#endif -{ - TRACE_CONTEXT(MediaObject::MapcInitComplete, EAudioInternal); - TRACE_ENTRY("state %d error %d", m_state, aError); - - __ASSERT_ALWAYS(LoadingState == m_state, Utils::panic(InvalidStatePanic)); - - if(KErrNone == aError) - { - TInt volume = 0; - aError = m_player->GetVolume(volume); - if(KErrNone == aError) - { - m_maxVolume = m_player->MaxVolume(); - m_volume = static_cast(volume) / m_maxVolume; - - if(m_audioOutput) - { - // Trigger AudioOutput signal - m_audioOutput->triggerVolumeChanged(m_volume); - } - - emit totalTimeChanged(); - changeState(StoppedState); - } - } - else - { - // TODO: set different error states according to value of aError? - m_error = NormalError; - changeState(ErrorState); - } - - TRACE_EXIT_0(); -} - -#ifdef QT_PHONON_MMF_AUDIO_DRM -void MMF::MediaObject::MdapcPlayComplete(TInt aError) -#else -void MMF::MediaObject::MapcPlayComplete(TInt aError) -#endif -{ - TRACE_CONTEXT(MediaObject::MapcPlayComplete, EAudioInternal); - TRACE_ENTRY("state %d error %d", m_state, aError); - - m_tickTimer->stop(); - - if(KErrNone == aError) - { - changeState(StoppedState); - // TODO: move on to m_nextSource - } - else - { - // TODO: do something with aError? - m_error = NormalError; - changeState(ErrorState); - } - -/* - if(aError == KErrNone) { - if(m_nextSource.type() == MediaSource::Empty) { - emit finished(); - } else { - setSource(m_nextSource); - m_nextSource = MediaSource(); - } - - changeState(StoppedState); - } - else { - m_error = NormalError; - changeState(ErrorState); - } -*/ - - TRACE_EXIT_0(); -} - -#ifdef QT_PHONON_MMF_AUDIO_DRM -void MMF::MediaObject::MaloLoadingStarted() -{ - -} - -void MMF::MediaObject::MaloLoadingComplete() -{ - } -#endif // QT_PHONON_MMF_AUDIO_DRM - //----------------------------------------------------------------------------- // Volume @@ -522,110 +124,13 @@ void MMF::MediaObject::MaloLoadingComplete() qreal MMF::MediaObject::volume() const { - return m_volume; } bool MMF::MediaObject::setVolume(qreal volume) { - TRACE_CONTEXT(MediaObject::setVolume, EAudioInternal); - TRACE_ENTRY("state %d", m_state); - - bool volumeChanged = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case ErrorState: - // Do nothing - break; - - case StoppedState: - case PausedState: - case PlayingState: - case BufferingState: - { - if(volume != m_volume) - { - const int err = m_player->SetVolume(volume * m_maxVolume); - if(KErrNone == err) - { - m_volume = volume; - volumeChanged = true; - } - else - { - m_error = NormalError; - changeState(ErrorState); - } - } - break; - } - - // Protection against adding new states and forgetting to update this - // switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_RETURN("%d", volumeChanged); } void MMF::MediaObject::setAudioOutput(AudioOutput* audioOutput) { - m_audioOutput = audioOutput; -} - - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -qint64 MMF::MediaObject::toMilliSeconds(const TTimeIntervalMicroSeconds &in) -{ - return in.Int64() / 1000; -} - -Phonon::State MMF::MediaObject::phononState(PrivateState state) -{ - const Phonon::State phononState = - GroundState == state - ? Phonon::StoppedState - : static_cast(state); - - return phononState; -} - -void MMF::MediaObject::changeState(PrivateState newState) -{ - TRACE_CONTEXT(MediaObject::changeState, EAudioInternal); - TRACE_ENTRY("state %d newState %d", m_state, newState); - - // TODO: add some invariants to check that the transition is valid - - const Phonon::State currentPhononState = phononState(m_state); - const Phonon::State newPhononState = phononState(newState); - if(currentPhononState != newPhononState) - { - TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); - emit stateChanged(newPhononState, currentPhononState); - } - - m_state = newState; - - TRACE_EXIT_0(); -} - -void MMF::MediaObject::tick() -{ - TRACE_CONTEXT(MediaObject::tick, EAudioInternal); - TRACE_ENTRY("state %d", m_state); - - emit tick(currentTime()); - - TRACE_EXIT_0(); } - - - diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index f17580e..d162455 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -19,26 +19,8 @@ along with this library. If not, see . #ifndef PHONON_MMF_MEDIAOBJECT_H #define PHONON_MMF_MEDIAOBJECT_H -/* We use the extra qualification include/ to avoid picking up the include - * Phonon has. */ -#include - #include -#include - -class CDrmPlayerUtility; -class TTimeIntervalMicroSeconds; -class QTimer; - -#ifdef QT_PHONON_MMF_AUDIO_DRM -#include -typedef CDrmPlayerUtility CPlayerType; -typedef MDrmAudioPlayerCallback MPlayerObserverType; -#else -#include -typedef CMdaAudioPlayerUtility CPlayerType; -typedef MMdaAudioPlayerCallback MPlayerObserverType; -#endif +#include namespace Phonon { @@ -47,17 +29,9 @@ namespace Phonon class AudioOutput; /** - * - * See - * How to - * play a video file using CVideoPlayerUtility */ class MediaObject : public QObject , public MediaObjectInterface - , public MPlayerObserverType // typedef -#ifdef QT_PHONON_MMF_AUDIO_DRM - , public MAudioLoadingObserver -#endif { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface) @@ -88,22 +62,6 @@ namespace Phonon virtual qint32 transitionTime() const; virtual void setTransitionTime(qint32); -#ifdef QT_PHONON_MMF_AUDIO_DRM - // MDrmAudioPlayerCallback - virtual void MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MdapcPlayComplete(TInt aError); - - // MAudioLoadingObserver - virtual void MaloLoadingStarted(); - virtual void MaloLoadingComplete(); -#else - // MMdaAudioPlayerCallback - virtual void MapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MapcPlayComplete(TInt aError); -#endif - qreal volume() const; bool setVolume(qreal volume); @@ -115,64 +73,6 @@ namespace Phonon Phonon::State newState); void finished(); void tick(qint64 time); - - private Q_SLOTS: - /** - * Receives signal from m_tickTimer - */ - void tick(); - - private: - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - /** - * Defined private state enumeration in order to add GroundState - */ - enum PrivateState - { - LoadingState = Phonon::LoadingState, - StoppedState = Phonon::StoppedState, - PlayingState = Phonon::PlayingState, - BufferingState = Phonon::BufferingState, - PausedState = Phonon::PausedState, - ErrorState = Phonon::ErrorState, - GroundState - }; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - static Phonon::State phononState(PrivateState state); - - /** - * Changes state and emits stateChanged() - */ - void changeState(PrivateState newState); - - /** - * Using CPlayerType typedef in order to be able to easily switch between - * CMdaAudioPlayerUtility and CDrmPlayerUtility - */ - CPlayerType* m_player; - - AudioOutput* m_audioOutput; - - ErrorType m_error; - - /** - * Do not set this directly - call changeState() instead. - */ - PrivateState m_state; - - qint32 m_tickInterval; - - QTimer* m_tickTimer; - - MediaSource m_mediaSource; - MediaSource m_nextSource; - - qreal m_volume; - int m_maxVolume; }; } } diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp new file mode 100644 index 0000000..3a51070 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -0,0 +1,577 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include +#include + +#include "mmf_videoplayer.h" +#include "audiooutput.h" +#include "utils.h" + +using namespace Phonon; +using namespace Phonon::MMF; + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const qint32 DefaultTickInterval = 20; +const int NullMaxVolume = -1; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::VideoPlayer::VideoPlayer(QObject *parent) : m_audioOutput(NULL) + , m_error(NoError) + , m_state(GroundState) + , m_tickInterval(DefaultTickInterval) + , m_tickTimer(NULL) + , m_volume(0.0) + , m_maxVolume(NullMaxVolume) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); + TRACE_ENTRY_0(); + + Q_UNUSED(parent); + + // TODO: should leaves be trapped in the constructor? + m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); + + m_tickTimer = new QTimer(this); + connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); + + TRACE_EXIT_0(); +#endif +} + +MMF::VideoPlayer::~VideoPlayer() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EAudioApi); + TRACE_ENTRY_0(); + + delete m_tickTimer; + delete m_player; + + TRACE_EXIT_0(); +#endif +} + +//----------------------------------------------------------------------------- +// VideoPlayerInterface +//----------------------------------------------------------------------------- + +void MMF::VideoPlayer::play() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::play, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + // Is this the correct error? Really we want 'NotReadyError' + m_error = NormalError; + changeState(ErrorState); + break; + + case StoppedState: + case PausedState: + m_player->Play(); + m_tickTimer->start(m_tickInterval); + changeState(PlayingState); + break; + + case PlayingState: + case BufferingState: + case ErrorState: + // Do nothing + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +#endif +} + +void MMF::VideoPlayer::pause() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::pause, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case PausedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + m_player->Pause(); + m_tickTimer->stop(); + changeState(PausedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +#endif +} + +void MMF::VideoPlayer::stop() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::stop, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + case PausedState: + m_player->Stop(); + m_tickTimer->stop(); + changeState(StoppedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +#endif +} + +void MMF::VideoPlayer::seek(qint64 ms) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::seek, EAudioApi); + TRACE_ENTRY("state %d pos %Ld", m_state, ms); + + m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); + + TRACE_EXIT_0(); +#endif +} + +qint32 MMF::VideoPlayer::tickInterval() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::tickInterval, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_RETURN("%d", m_tickInterval); +#endif +} + +void MMF::VideoPlayer::setTickInterval(qint32 interval) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setTickInterval, EAudioApi); + TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); + + m_tickInterval = interval; + m_tickTimer->setInterval(interval); + + TRACE_EXIT_0(); +#endif +} + +bool MMF::VideoPlayer::hasVideo() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::hasVideo, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: re-factor this class so that audio playback and video playback are + // delegated to separate classes, which internally hoat a + // CMdaVideoPlayerUtility / CVideoPlayerUtility instance as appropriate. + + TRACE_RETURN("%d", false); +#endif +} + +bool MMF::VideoPlayer::isSeekable() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::isSeekable, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_RETURN("%d", true); +#endif +} + +Phonon::State MMF::VideoPlayer::state() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::state, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const Phonon::State result = phononState(m_state); + + TRACE_RETURN("%d", result); +#endif +} + +qint64 MMF::VideoPlayer::currentTime() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::currentTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TTimeIntervalMicroSeconds us; + const TInt err = m_player->GetPosition(us); + + qint64 result = -1; + + if(KErrNone == err) { + result = toMilliSeconds(us); + } + + TRACE_RETURN("%Ld", result); +#endif +} + +QString MMF::VideoPlayer::errorString() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::errorString, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_EXIT_0(); + // TODO: put in proper error strings + QString result; + return result; +#endif +} + +Phonon::ErrorType MMF::VideoPlayer::errorType() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::errorType, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const Phonon::ErrorType result = (ErrorState == m_state) + ? m_error : NoError; + + TRACE_RETURN("%d", result); +#endif +} + +qint64 MMF::VideoPlayer::totalTime() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::totalTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const qint64 result = toMilliSeconds(m_player->Duration()); + + TRACE_RETURN("%Ld", result); +#endif +} + +MediaSource MMF::VideoPlayer::source() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::source, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_EXIT_0(); + return m_mediaSource; +#endif +} + +void MMF::VideoPlayer::setSource(const MediaSource &source) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setSource, EAudioApi); + TRACE_ENTRY("state %d source.type %d", m_state, source.type()); + + m_player->Close(); + changeState(GroundState); + + // TODO: is it correct to assign even if the media type is not supported in + // the switch statement below? + m_mediaSource = source; + + TInt symbianErr = KErrNone; + + switch(m_mediaSource.type()) + { + case MediaSource::LocalFile: + { + // TODO: work out whose responsibility it is to ensure that paths + // are Symbian-style, i.e. have backslashes for path delimiters. + // Until then, use this utility function... + const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName()); + TRAP(symbianErr, m_player->OpenFileL(*filename)); + break; + } + + case MediaSource::Url: + { + const QHBufC filename(m_mediaSource.url().toString()); + TRAP(symbianErr, m_player->OpenUrlL(*filename)); + break; + } + + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + symbianErr = KErrNotSupported; + break; + + case MediaSource::Empty: + TRACE_EXIT_0(); + return; + + // Protection against adding new media types and forgetting to update this switch + default: + TRACE_PANIC(InvalidMediaTypePanic); + } + + if(KErrNone == symbianErr) + { +#ifdef QT_PHONON_MMF_AUDIO_DRM + // There appears to be a bug in the CDrmPlayerUtility implementation (at least + // in S60 5.x) whereby the player does not check whether the loading observer + // pointer is null before dereferencing it. Therefore we must register for + // loading notification, even though we do nothing in the callback functions. + m_player->RegisterForAudioLoadingNotification(*this); +#endif + changeState(LoadingState); + } + else + { + // TODO: do something with the value of symbianErr? + m_error = NormalError; + changeState(ErrorState); + } + + TRACE_EXIT_0(); +#endif +} + +void MMF::VideoPlayer::setNextSource(const MediaSource &source) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setNextSource, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: handle 'next source' + + m_nextSource = source; + Q_UNUSED(source); + + TRACE_EXIT_0(); +#endif +} + +qint32 MMF::VideoPlayer::prefinishMark() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::prefinishMark, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement prefinish mark + const qint32 result = 0; + TRACE_RETURN("%d", result); +#endif +} + +void MMF::VideoPlayer::setPrefinishMark(qint32 mark) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setPrefinishMark, EAudioApi); + TRACE_ENTRY("state %d mark %d", m_state, mark); + Q_UNUSED(mark); // to silence warnings in release builds + + // TODO: implement prefinish mark + + TRACE_EXIT_0(); +#endif +} + +qint32 MMF::VideoPlayer::transitionTime() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::transitionTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement transition time + const qint32 result = 0; + TRACE_RETURN("%d", result); +#endif +} + +void MMF::VideoPlayer::setTransitionTime(qint32 time) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setTransitionTime, EAudioApi); + TRACE_ENTRY("state %d time %d", m_state, time); + Q_UNUSED(time); // to silence warnings in release builds + + // TODO: implement transition time + + TRACE_EXIT_0(); +#endif +} + + +//----------------------------------------------------------------------------- +// Volume +//----------------------------------------------------------------------------- + +qreal MMF::VideoPlayer::volume() const +{ + //return m_volume; +} + +bool MMF::VideoPlayer::setVolume(qreal volume) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setVolume, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + bool volumeChanged = false; + + switch(m_state) + { + case GroundState: + case LoadingState: + case ErrorState: + // Do nothing + break; + + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: + { + if(volume != m_volume) + { + const int err = m_player->SetVolume(volume * m_maxVolume); + if(KErrNone == err) + { + m_volume = volume; + volumeChanged = true; + } + else + { + m_error = NormalError; + changeState(ErrorState); + } + } + break; + } + + // Protection against adding new states and forgetting to update this + // switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_RETURN("%d", volumeChanged); +#endif +} + +void MMF::VideoPlayer::setAudioOutput(AudioOutput* audioOutput) +{ + //m_audioOutput = audioOutput; +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +qint64 MMF::VideoPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) +{ + //return in.Int64() / 1000; +} + +Phonon::State MMF::VideoPlayer::phononState(PrivateState state) +{ +#if 0 + const Phonon::State phononState = + GroundState == state + ? Phonon::StoppedState + : static_cast(state); + + return phononState; +#endif +} + +void MMF::VideoPlayer::changeState(PrivateState newState) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::changeState, EAudioInternal); + TRACE_ENTRY("state %d newState %d", m_state, newState); + + // TODO: add some invariants to check that the transition is valid + + const Phonon::State currentPhononState = phononState(m_state); + const Phonon::State newPhononState = phononState(newState); + if(currentPhononState != newPhononState) + { + TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); + emit stateChanged(newPhononState, currentPhononState); + } + + m_state = newState; + + TRACE_EXIT_0(); +#endif +} + +void MMF::VideoPlayer::tick() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::tick, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + emit tick(currentTime()); + + TRACE_EXIT_0(); +#endif +} + diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h new file mode 100644 index 0000000..3b0cd98 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -0,0 +1,163 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_VIDEOPLAYER_H +#define PHONON_MMF_VIDEOPLAYER_H + +/* We use the extra qualification include/ to avoid picking up the include + * Phonon has. */ +#include +#include "abstractplayer.h" + +#include + +class CDrmPlayerUtility; +class TTimeIntervalMicroSeconds; +class QTimer; + +namespace Phonon +{ + namespace MMF + { + class AudioOutput; + + /** + * + * See + * How to + * play a video file using CVideoPlayerUtility + */ + class VideoPlayer : public AbstractPlayer + { + Q_OBJECT + public: + VideoPlayer(QObject *parent); + virtual ~VideoPlayer(); + + // AbstractPlayer + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual qint32 tickInterval() const; + virtual void setTickInterval(qint32 interval); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + virtual void setSource(const MediaSource &); + virtual void setNextSource(const MediaSource &source); + virtual qint32 prefinishMark() const; + virtual void setPrefinishMark(qint32); + virtual qint32 transitionTime() const; + virtual void setTransitionTime(qint32); + +#ifdef QT_PHONON_MMF_AUDIO_DRM + // MDrmVideoPlayerCallback + virtual void MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MdapcPlayComplete(TInt aError); + + // MAudioLoadingObserver + virtual void MaloLoadingStarted(); + virtual void MaloLoadingComplete(); +#else + // MMdaVideoPlayerCallback + virtual void MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MapcPlayComplete(TInt aError); +#endif + + qreal volume() const; + bool setVolume(qreal volume); + + void setAudioOutput(AudioOutput* audioOutput); + + Q_SIGNALS: + void totalTimeChanged(); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + void finished(); + void tick(qint64 time); + + private Q_SLOTS: + /** + * Receives signal from m_tickTimer + */ + void tick(); + + private: + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + + /** + * Defined private state enumeration in order to add GroundState + */ + enum PrivateState + { + LoadingState = Phonon::LoadingState, + StoppedState = Phonon::StoppedState, + PlayingState = Phonon::PlayingState, + BufferingState = Phonon::BufferingState, + PausedState = Phonon::PausedState, + ErrorState = Phonon::ErrorState, + GroundState + }; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + static Phonon::State phononState(PrivateState state); + + /** + * Changes state and emits stateChanged() + */ + void changeState(PrivateState newState); + + /** + * Using CPlayerType typedef in order to be able to easily switch between + * CMdaVideoPlayerUtility and CDrmPlayerUtility + */ + // CPlayerType* m_player; TODO + + AudioOutput* m_audioOutput; + + ErrorType m_error; + + /** + * Do not set this directly - call changeState() instead. + */ + PrivateState m_state; + + qint32 m_tickInterval; + + QTimer* m_tickTimer; + + MediaSource m_mediaSource; + MediaSource m_nextSource; + + qreal m_volume; + int m_maxVolume; + }; + } +} + +#endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index ee2d3f9..266c3db 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -21,17 +21,22 @@ phonon_mmf_audio_drm { LIBS += -lmediaclientaudio.lib } -HEADERS += \ - $$PHONON_MMF_DIR/audiooutput.h \ - $$PHONON_MMF_DIR/backend.h \ - $$PHONON_MMF_DIR/mediaobject.h \ - $$PHONON_MMF_DIR/utils.h - -SOURCES += \ - $$PHONON_MMF_DIR/audiooutput.cpp \ - $$PHONON_MMF_DIR/backend.cpp \ - $$PHONON_MMF_DIR/mediaobject.cpp \ - $$PHONON_MMF_DIR/utils.cpp +HEADERS += \ + $$PHONON_MMF_DIR/abstractplayer.h \ + $$PHONON_MMF_DIR/audiooutput.h \ + $$PHONON_MMF_DIR/audioplayer.h \ + $$PHONON_MMF_DIR/backend.h \ + $$PHONON_MMF_DIR/mediaobject.h \ + $$PHONON_MMF_DIR/utils.h \ + $$PHONON_MMF_DIR/mmf_videoplayer.h + +SOURCES += \ + $$PHONON_MMF_DIR/audiooutput.cpp \ + $$PHONON_MMF_DIR/audioplayer.cpp \ + $$PHONON_MMF_DIR/backend.cpp \ + $$PHONON_MMF_DIR/mediaobject.cpp \ + $$PHONON_MMF_DIR/utils.cpp \ + $$PHONON_MMF_DIR/mmf_videoplayer.cpp # This is needed for having the .qtplugin file properly created on Symbian. QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend -- cgit v0.12 From a7b1ad0b2ecdedd5f2a9d52fe09c4497078bc669 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 17 Aug 2009 16:58:44 +0200 Subject: Delegate from MediaObject. --- src/3rdparty/phonon/mmf/abstractplayer.h | 13 +++++++++++++ src/3rdparty/phonon/mmf/mediaobject.cpp | 25 ++++++++++++++++++++++++- src/3rdparty/phonon/mmf/mediaobject.h | 4 ++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 6452090..0188068 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -27,6 +27,8 @@ namespace Phonon { namespace MMF { + class AudioOutput; + class AbstractPlayer : public QObject { public: @@ -42,9 +44,20 @@ namespace Phonon virtual Phonon::State state() const = 0; virtual QString errorString() const = 0; virtual Phonon::ErrorType errorType() const = 0; + virtual qint64 totalTime() const = 0; virtual Phonon::MediaSource source() const = 0; virtual void setSource(const Phonon::MediaSource &) = 0; virtual void setNextSource(const Phonon::MediaSource &) = 0; + + virtual void setTransitionTime(qint32) = 0; + virtual qint32 transitionTime() const = 0; + virtual qint32 prefinishMark() const = 0; + virtual void setPrefinishMark(qint32) = 0; + + virtual bool setVolume(qreal) = 0; + virtual qreal volume() const = 0; + + virtual void setAudioOutput(AudioOutput *) = 0; }; } } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index fb079f0..4769249 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -16,6 +16,7 @@ along with this library. If not, see . */ +#include "abstractplayer.h" #include "mediaobject.h" using namespace Phonon; @@ -39,83 +40,102 @@ MMF::MediaObject::~MediaObject() void MMF::MediaObject::play() { + m_player->play(); } void MMF::MediaObject::pause() { + m_player->pause(); } void MMF::MediaObject::stop() { + m_player->stop(); } void MMF::MediaObject::seek(qint64 ms) { - Q_UNUSED(ms); + m_player->seek(ms); } qint32 MMF::MediaObject::tickInterval() const { + return m_player->tickInterval(); } void MMF::MediaObject::setTickInterval(qint32 interval) { + m_player->setTransitionTime(interval); } bool MMF::MediaObject::hasVideo() const { + return m_player->hasVideo(); } bool MMF::MediaObject::isSeekable() const { + return m_player->isSeekable(); } Phonon::State MMF::MediaObject::state() const { + return m_player->state(); } qint64 MMF::MediaObject::currentTime() const { + return m_player->currentTime(); } QString MMF::MediaObject::errorString() const { + return m_player->errorString(); } Phonon::ErrorType MMF::MediaObject::errorType() const { + return m_player->errorType(); } qint64 MMF::MediaObject::totalTime() const { + return m_player->totalTime(); } MediaSource MMF::MediaObject::source() const { + return m_player->source(); } void MMF::MediaObject::setSource(const MediaSource &source) { + return m_player->setSource(source); } void MMF::MediaObject::setNextSource(const MediaSource &source) { + return m_player->setNextSource(source); } qint32 MMF::MediaObject::prefinishMark() const { + return m_player->prefinishMark(); } void MMF::MediaObject::setPrefinishMark(qint32 mark) { + m_player->setPrefinishMark(mark); } qint32 MMF::MediaObject::transitionTime() const { + return m_player->transitionTime(); } void MMF::MediaObject::setTransitionTime(qint32 time) { + m_player->setTransitionTime(time); } //----------------------------------------------------------------------------- @@ -124,13 +144,16 @@ void MMF::MediaObject::setTransitionTime(qint32 time) qreal MMF::MediaObject::volume() const { + return m_player->volume(); } bool MMF::MediaObject::setVolume(qreal volume) { + return m_player->setVolume(volume); } void MMF::MediaObject::setAudioOutput(AudioOutput* audioOutput) { + m_player->setAudioOutput(audioOutput); } diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index d162455..9b1e914 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -26,6 +26,7 @@ namespace Phonon { namespace MMF { + class AbstractPlayer; class AudioOutput; /** @@ -73,6 +74,9 @@ namespace Phonon Phonon::State newState); void finished(); void tick(qint64 time); + + private: + AbstractPlayer *m_player; }; } } -- cgit v0.12 From 427c415d876d57042a55e8b66730888512ac0ed1 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 17 Aug 2009 16:02:58 +0100 Subject: Added recognizer code to determine if file is audio or video --- src/3rdparty/phonon/mmf/mediaobject.cpp | 58 +++++++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/mediaobject.h | 10 ++++++ src/plugins/phonon/mmf/mmf.pro | 3 ++ 3 files changed, 71 insertions(+) diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 8a4b76e..6bf15e6 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -53,6 +53,10 @@ MMF::MediaObject::MediaObject(QObject *parent) : m_player(NULL) Q_UNUSED(parent); + TInt err = m_recognizer.Connect(); + err = m_fileServer.Connect(); + // TODO: handle this error + // TODO: should leaves be trapped in the constructor? m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); @@ -70,9 +74,63 @@ MMF::MediaObject::~MediaObject() delete m_tickTimer; delete m_player; + m_fileServer.Close(); + m_recognizer.Close(); + TRACE_EXIT_0(); } + +//----------------------------------------------------------------------------- +// Recognizer +//----------------------------------------------------------------------------- + +const TInt KMimePrefixLength = 6; // either "audio/" or "video/" +_LIT(KMimePrefixAudio, "audio/"); +_LIT(KMimePrefixVideo, "video/"); + +MMF::MediaObject::MediaType MMF::MediaObject::mimeTypeToMediaType(const TDesC& mimeType) +{ + MediaType result = MediaTypeUnknown; + + if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) + { + result = MediaTypeAudio; + } + else if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) + { + result = MediaTypeVideo; + } + + return result; +} + + +MMF::MediaObject::MediaType MMF::MediaObject::fileMediaType + (const QString& fileName) +{ + MediaType result = MediaTypeUnknown; + + QHBufC fileNameSymbian = Utils::symbianFilename(m_mediaSource.fileName()); + RFile file; + TInt err = file.Open(m_fileServer, *fileNameSymbian, EFileRead); + + if(KErrNone == err) + { + TDataRecognitionResult recognizerResult; + err = m_recognizer.RecognizeData(file, recognizerResult); + if(KErrNone == err) + { + const TPtrC mimeType = recognizerResult.iDataType.Des(); + result = mimeTypeToMediaType(mimeType); + } + + file.Close(); + } + return result; +} + + //----------------------------------------------------------------------------- // MediaObjectInterface //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index f17580e..af9bae2 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -40,6 +40,9 @@ typedef CMdaAudioPlayerUtility CPlayerType; typedef MMdaAudioPlayerCallback MPlayerObserverType; #endif +// For recognizer +#include + namespace Phonon { namespace MMF @@ -149,6 +152,13 @@ namespace Phonon */ void changeState(PrivateState newState); + RApaLsSession m_recognizer; + RFs m_fileServer; + enum MediaType { MediaTypeUnknown, MediaTypeAudio, MediaTypeVideo }; + MediaType mimeTypeToMediaType(const TDesC& mimeType); + MediaType fileMediaType(const QString& fileName); + // TODO: urlMediaType function + /** * Using CPlayerType typedef in order to be able to easily switch between * CMdaAudioPlayerUtility and CDrmPlayerUtility diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index ee2d3f9..3c8a721 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -33,6 +33,9 @@ SOURCES += \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/utils.cpp +LIBS += -lefsrv # For file server +LIBS += -lapgrfx.lib # For recognizer + # This is needed for having the .qtplugin file properly created on Symbian. QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend -- cgit v0.12 From 257984d8b8cf31394c4f20070ea045f5ae7fa170 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 17 Aug 2009 17:24:34 +0200 Subject: More delegation, basic plumbing. --- src/3rdparty/phonon/mmf/abstractplayer.h | 4 +--- src/3rdparty/phonon/mmf/audioplayer.cpp | 16 ++++++++-------- src/3rdparty/phonon/mmf/audioplayer.h | 2 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 19 ++++++++++++++++++- src/3rdparty/phonon/mmf/mediaobject.h | 6 +++++- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 14 +++++++------- src/3rdparty/phonon/mmf/mmf_videoplayer.h | 2 +- 7 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 0188068..613831a 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -37,7 +37,7 @@ namespace Phonon virtual void stop() = 0; virtual void seek(qint64 milliseconds) = 0; virtual qint32 tickInterval() const = 0; - virtual void setTickInterval() const = 0; + virtual void setTickInterval(qint32) = 0; virtual bool hasVideo() const = 0; virtual bool isSeekable() const = 0; virtual qint64 currentTime() const = 0; @@ -53,10 +53,8 @@ namespace Phonon virtual qint32 transitionTime() const = 0; virtual qint32 prefinishMark() const = 0; virtual void setPrefinishMark(qint32) = 0; - virtual bool setVolume(qreal) = 0; virtual qreal volume() const = 0; - virtual void setAudioOutput(AudioOutput *) = 0; }; } diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 4dd2eb8..106b71b 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -39,14 +39,14 @@ const int NullMaxVolume = -1; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioPlayer::AudioPlayer(QObject *parent) : m_player(NULL) - , m_audioOutput(NULL) - , m_error(NoError) - , m_state(GroundState) - , m_tickInterval(DefaultTickInterval) - , m_tickTimer(NULL) - , m_volume(0.0) - , m_maxVolume(NullMaxVolume) +MMF::AudioPlayer::AudioPlayer() : m_player(NULL) + , m_audioOutput(NULL) + , m_error(NoError) + , m_state(GroundState) + , m_tickInterval(DefaultTickInterval) + , m_tickTimer(NULL) + , m_volume(0.0) + , m_maxVolume(NullMaxVolume) { TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); TRACE_ENTRY_0(); diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index d9a64e1..338c6fa 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -56,7 +56,7 @@ namespace Phonon Q_OBJECT public: - AudioPlayer(QObject *parent); + AudioPlayer(); virtual ~AudioPlayer(); // AbstractPlayer diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 4769249..e9e4b5b 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -17,6 +17,8 @@ along with this library. If not, see . */ #include "abstractplayer.h" +#include "audioplayer.h" +#include "mmf_videoplayer.h" #include "mediaobject.h" using namespace Phonon; @@ -65,7 +67,7 @@ qint32 MMF::MediaObject::tickInterval() const void MMF::MediaObject::setTickInterval(qint32 interval) { - m_player->setTransitionTime(interval); + m_player->setTickInterval(interval); } bool MMF::MediaObject::hasVideo() const @@ -110,9 +112,24 @@ MediaSource MMF::MediaObject::source() const void MMF::MediaObject::setSource(const MediaSource &source) { + loadPlayer(source); + return m_player->setSource(source); } +void MMF::MediaObject::loadPlayer(const MediaSource &source) +{ + disconnect(m_player.data(), 0, this, 0); + + // TODO determine media type + m_player.reset(new AudioPlayer()); + + connect(m_player.data(), SIGNAL(totalTimeChanged()), SIGNAL(totalTimeChanged())); + connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); + connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); + connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); +} + void MMF::MediaObject::setNextSource(const MediaSource &source) { return m_player->setNextSource(source); diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 9b1e914..a55b6e6 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -21,6 +21,7 @@ along with this library. If not, see . #include #include +#include namespace Phonon { @@ -76,7 +77,10 @@ namespace Phonon void tick(qint64 time); private: - AbstractPlayer *m_player; + void loadPlayer(const MediaSource &source); + + QScopedPointer m_player; + }; } } diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 3a51070..c226835 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -39,13 +39,13 @@ const int NullMaxVolume = -1; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoPlayer::VideoPlayer(QObject *parent) : m_audioOutput(NULL) - , m_error(NoError) - , m_state(GroundState) - , m_tickInterval(DefaultTickInterval) - , m_tickTimer(NULL) - , m_volume(0.0) - , m_maxVolume(NullMaxVolume) +MMF::VideoPlayer::VideoPlayer() : m_audioOutput(NULL) + , m_error(NoError) + , m_state(GroundState) + , m_tickInterval(DefaultTickInterval) + , m_tickTimer(NULL) + , m_volume(0.0) + , m_maxVolume(NullMaxVolume) { #if 0 TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h index 3b0cd98..3ea9c1a 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -46,7 +46,7 @@ namespace Phonon { Q_OBJECT public: - VideoPlayer(QObject *parent); + VideoPlayer(); virtual ~VideoPlayer(); // AbstractPlayer -- cgit v0.12 From 6b7603a0a2fed844b1264d8deb0ce78b110858c4 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 17 Aug 2009 17:31:02 +0200 Subject: Rename mmf_videoplayer back to videoplayer, apparently the includes can be resolved anyway. --- src/3rdparty/phonon/mmf/mediaobject.cpp | 2 +- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 577 ---------------------------- src/3rdparty/phonon/mmf/mmf_videoplayer.h | 163 -------- src/3rdparty/phonon/mmf/videoplayer.cpp | 577 ++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/videoplayer.h | 163 ++++++++ src/plugins/phonon/mmf/mmf.pro | 4 +- 6 files changed, 743 insertions(+), 743 deletions(-) delete mode 100644 src/3rdparty/phonon/mmf/mmf_videoplayer.cpp delete mode 100644 src/3rdparty/phonon/mmf/mmf_videoplayer.h create mode 100644 src/3rdparty/phonon/mmf/videoplayer.cpp create mode 100644 src/3rdparty/phonon/mmf/videoplayer.h diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index e9e4b5b..877e463 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -18,7 +18,7 @@ along with this library. If not, see . #include "abstractplayer.h" #include "audioplayer.h" -#include "mmf_videoplayer.h" +#include "videoplayer.h" #include "mediaobject.h" using namespace Phonon; diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp deleted file mode 100644 index c226835..0000000 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ /dev/null @@ -1,577 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#include -#include -#include - -#include "mmf_videoplayer.h" -#include "audiooutput.h" -#include "utils.h" - -using namespace Phonon; -using namespace Phonon::MMF; - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const qint32 DefaultTickInterval = 20; -const int NullMaxVolume = -1; - - -//----------------------------------------------------------------------------- -// Constructor / destructor -//----------------------------------------------------------------------------- - -MMF::VideoPlayer::VideoPlayer() : m_audioOutput(NULL) - , m_error(NoError) - , m_state(GroundState) - , m_tickInterval(DefaultTickInterval) - , m_tickTimer(NULL) - , m_volume(0.0) - , m_maxVolume(NullMaxVolume) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); - TRACE_ENTRY_0(); - - Q_UNUSED(parent); - - // TODO: should leaves be trapped in the constructor? - m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); - - m_tickTimer = new QTimer(this); - connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); - - TRACE_EXIT_0(); -#endif -} - -MMF::VideoPlayer::~VideoPlayer() -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EAudioApi); - TRACE_ENTRY_0(); - - delete m_tickTimer; - delete m_player; - - TRACE_EXIT_0(); -#endif -} - -//----------------------------------------------------------------------------- -// VideoPlayerInterface -//----------------------------------------------------------------------------- - -void MMF::VideoPlayer::play() -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::play, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - // Is this the correct error? Really we want 'NotReadyError' - m_error = NormalError; - changeState(ErrorState); - break; - - case StoppedState: - case PausedState: - m_player->Play(); - m_tickTimer->start(m_tickInterval); - changeState(PlayingState); - break; - - case PlayingState: - case BufferingState: - case ErrorState: - // Do nothing - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); -#endif -} - -void MMF::VideoPlayer::pause() -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::pause, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case PausedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - m_player->Pause(); - m_tickTimer->stop(); - changeState(PausedState); - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); -#endif -} - -void MMF::VideoPlayer::stop() -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::stop, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - case PausedState: - m_player->Stop(); - m_tickTimer->stop(); - changeState(StoppedState); - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); -#endif -} - -void MMF::VideoPlayer::seek(qint64 ms) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::seek, EAudioApi); - TRACE_ENTRY("state %d pos %Ld", m_state, ms); - - m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); - - TRACE_EXIT_0(); -#endif -} - -qint32 MMF::VideoPlayer::tickInterval() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::tickInterval, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_RETURN("%d", m_tickInterval); -#endif -} - -void MMF::VideoPlayer::setTickInterval(qint32 interval) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setTickInterval, EAudioApi); - TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); - - m_tickInterval = interval; - m_tickTimer->setInterval(interval); - - TRACE_EXIT_0(); -#endif -} - -bool MMF::VideoPlayer::hasVideo() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::hasVideo, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: re-factor this class so that audio playback and video playback are - // delegated to separate classes, which internally hoat a - // CMdaVideoPlayerUtility / CVideoPlayerUtility instance as appropriate. - - TRACE_RETURN("%d", false); -#endif -} - -bool MMF::VideoPlayer::isSeekable() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::isSeekable, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_RETURN("%d", true); -#endif -} - -Phonon::State MMF::VideoPlayer::state() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::state, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const Phonon::State result = phononState(m_state); - - TRACE_RETURN("%d", result); -#endif -} - -qint64 MMF::VideoPlayer::currentTime() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::currentTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TTimeIntervalMicroSeconds us; - const TInt err = m_player->GetPosition(us); - - qint64 result = -1; - - if(KErrNone == err) { - result = toMilliSeconds(us); - } - - TRACE_RETURN("%Ld", result); -#endif -} - -QString MMF::VideoPlayer::errorString() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::errorString, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_EXIT_0(); - // TODO: put in proper error strings - QString result; - return result; -#endif -} - -Phonon::ErrorType MMF::VideoPlayer::errorType() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::errorType, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const Phonon::ErrorType result = (ErrorState == m_state) - ? m_error : NoError; - - TRACE_RETURN("%d", result); -#endif -} - -qint64 MMF::VideoPlayer::totalTime() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::totalTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const qint64 result = toMilliSeconds(m_player->Duration()); - - TRACE_RETURN("%Ld", result); -#endif -} - -MediaSource MMF::VideoPlayer::source() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::source, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_EXIT_0(); - return m_mediaSource; -#endif -} - -void MMF::VideoPlayer::setSource(const MediaSource &source) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setSource, EAudioApi); - TRACE_ENTRY("state %d source.type %d", m_state, source.type()); - - m_player->Close(); - changeState(GroundState); - - // TODO: is it correct to assign even if the media type is not supported in - // the switch statement below? - m_mediaSource = source; - - TInt symbianErr = KErrNone; - - switch(m_mediaSource.type()) - { - case MediaSource::LocalFile: - { - // TODO: work out whose responsibility it is to ensure that paths - // are Symbian-style, i.e. have backslashes for path delimiters. - // Until then, use this utility function... - const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName()); - TRAP(symbianErr, m_player->OpenFileL(*filename)); - break; - } - - case MediaSource::Url: - { - const QHBufC filename(m_mediaSource.url().toString()); - TRAP(symbianErr, m_player->OpenUrlL(*filename)); - break; - } - - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - symbianErr = KErrNotSupported; - break; - - case MediaSource::Empty: - TRACE_EXIT_0(); - return; - - // Protection against adding new media types and forgetting to update this switch - default: - TRACE_PANIC(InvalidMediaTypePanic); - } - - if(KErrNone == symbianErr) - { -#ifdef QT_PHONON_MMF_AUDIO_DRM - // There appears to be a bug in the CDrmPlayerUtility implementation (at least - // in S60 5.x) whereby the player does not check whether the loading observer - // pointer is null before dereferencing it. Therefore we must register for - // loading notification, even though we do nothing in the callback functions. - m_player->RegisterForAudioLoadingNotification(*this); -#endif - changeState(LoadingState); - } - else - { - // TODO: do something with the value of symbianErr? - m_error = NormalError; - changeState(ErrorState); - } - - TRACE_EXIT_0(); -#endif -} - -void MMF::VideoPlayer::setNextSource(const MediaSource &source) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setNextSource, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: handle 'next source' - - m_nextSource = source; - Q_UNUSED(source); - - TRACE_EXIT_0(); -#endif -} - -qint32 MMF::VideoPlayer::prefinishMark() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::prefinishMark, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement prefinish mark - const qint32 result = 0; - TRACE_RETURN("%d", result); -#endif -} - -void MMF::VideoPlayer::setPrefinishMark(qint32 mark) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setPrefinishMark, EAudioApi); - TRACE_ENTRY("state %d mark %d", m_state, mark); - Q_UNUSED(mark); // to silence warnings in release builds - - // TODO: implement prefinish mark - - TRACE_EXIT_0(); -#endif -} - -qint32 MMF::VideoPlayer::transitionTime() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::transitionTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement transition time - const qint32 result = 0; - TRACE_RETURN("%d", result); -#endif -} - -void MMF::VideoPlayer::setTransitionTime(qint32 time) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setTransitionTime, EAudioApi); - TRACE_ENTRY("state %d time %d", m_state, time); - Q_UNUSED(time); // to silence warnings in release builds - - // TODO: implement transition time - - TRACE_EXIT_0(); -#endif -} - - -//----------------------------------------------------------------------------- -// Volume -//----------------------------------------------------------------------------- - -qreal MMF::VideoPlayer::volume() const -{ - //return m_volume; -} - -bool MMF::VideoPlayer::setVolume(qreal volume) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setVolume, EAudioInternal); - TRACE_ENTRY("state %d", m_state); - - bool volumeChanged = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case ErrorState: - // Do nothing - break; - - case StoppedState: - case PausedState: - case PlayingState: - case BufferingState: - { - if(volume != m_volume) - { - const int err = m_player->SetVolume(volume * m_maxVolume); - if(KErrNone == err) - { - m_volume = volume; - volumeChanged = true; - } - else - { - m_error = NormalError; - changeState(ErrorState); - } - } - break; - } - - // Protection against adding new states and forgetting to update this - // switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_RETURN("%d", volumeChanged); -#endif -} - -void MMF::VideoPlayer::setAudioOutput(AudioOutput* audioOutput) -{ - //m_audioOutput = audioOutput; -} - - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -qint64 MMF::VideoPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) -{ - //return in.Int64() / 1000; -} - -Phonon::State MMF::VideoPlayer::phononState(PrivateState state) -{ -#if 0 - const Phonon::State phononState = - GroundState == state - ? Phonon::StoppedState - : static_cast(state); - - return phononState; -#endif -} - -void MMF::VideoPlayer::changeState(PrivateState newState) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::changeState, EAudioInternal); - TRACE_ENTRY("state %d newState %d", m_state, newState); - - // TODO: add some invariants to check that the transition is valid - - const Phonon::State currentPhononState = phononState(m_state); - const Phonon::State newPhononState = phononState(newState); - if(currentPhononState != newPhononState) - { - TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); - emit stateChanged(newPhononState, currentPhononState); - } - - m_state = newState; - - TRACE_EXIT_0(); -#endif -} - -void MMF::VideoPlayer::tick() -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::tick, EAudioInternal); - TRACE_ENTRY("state %d", m_state); - - emit tick(currentTime()); - - TRACE_EXIT_0(); -#endif -} - diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h deleted file mode 100644 index 3ea9c1a..0000000 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ /dev/null @@ -1,163 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#ifndef PHONON_MMF_VIDEOPLAYER_H -#define PHONON_MMF_VIDEOPLAYER_H - -/* We use the extra qualification include/ to avoid picking up the include - * Phonon has. */ -#include -#include "abstractplayer.h" - -#include - -class CDrmPlayerUtility; -class TTimeIntervalMicroSeconds; -class QTimer; - -namespace Phonon -{ - namespace MMF - { - class AudioOutput; - - /** - * - * See - * How to - * play a video file using CVideoPlayerUtility - */ - class VideoPlayer : public AbstractPlayer - { - Q_OBJECT - public: - VideoPlayer(); - virtual ~VideoPlayer(); - - // AbstractPlayer - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual qint32 tickInterval() const; - virtual void setTickInterval(qint32 interval); - virtual bool hasVideo() const; - virtual bool isSeekable() const; - virtual qint64 currentTime() const; - virtual Phonon::State state() const; - virtual QString errorString() const; - virtual Phonon::ErrorType errorType() const; - virtual qint64 totalTime() const; - virtual MediaSource source() const; - virtual void setSource(const MediaSource &); - virtual void setNextSource(const MediaSource &source); - virtual qint32 prefinishMark() const; - virtual void setPrefinishMark(qint32); - virtual qint32 transitionTime() const; - virtual void setTransitionTime(qint32); - -#ifdef QT_PHONON_MMF_AUDIO_DRM - // MDrmVideoPlayerCallback - virtual void MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MdapcPlayComplete(TInt aError); - - // MAudioLoadingObserver - virtual void MaloLoadingStarted(); - virtual void MaloLoadingComplete(); -#else - // MMdaVideoPlayerCallback - virtual void MapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MapcPlayComplete(TInt aError); -#endif - - qreal volume() const; - bool setVolume(qreal volume); - - void setAudioOutput(AudioOutput* audioOutput); - - Q_SIGNALS: - void totalTimeChanged(); - void stateChanged(Phonon::State oldState, - Phonon::State newState); - void finished(); - void tick(qint64 time); - - private Q_SLOTS: - /** - * Receives signal from m_tickTimer - */ - void tick(); - - private: - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - /** - * Defined private state enumeration in order to add GroundState - */ - enum PrivateState - { - LoadingState = Phonon::LoadingState, - StoppedState = Phonon::StoppedState, - PlayingState = Phonon::PlayingState, - BufferingState = Phonon::BufferingState, - PausedState = Phonon::PausedState, - ErrorState = Phonon::ErrorState, - GroundState - }; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - static Phonon::State phononState(PrivateState state); - - /** - * Changes state and emits stateChanged() - */ - void changeState(PrivateState newState); - - /** - * Using CPlayerType typedef in order to be able to easily switch between - * CMdaVideoPlayerUtility and CDrmPlayerUtility - */ - // CPlayerType* m_player; TODO - - AudioOutput* m_audioOutput; - - ErrorType m_error; - - /** - * Do not set this directly - call changeState() instead. - */ - PrivateState m_state; - - qint32 m_tickInterval; - - QTimer* m_tickTimer; - - MediaSource m_mediaSource; - MediaSource m_nextSource; - - qreal m_volume; - int m_maxVolume; - }; - } -} - -#endif diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp new file mode 100644 index 0000000..f465c96 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -0,0 +1,577 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include +#include + +#include "videoplayer.h" +#include "audiooutput.h" +#include "utils.h" + +using namespace Phonon; +using namespace Phonon::MMF; + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const qint32 DefaultTickInterval = 20; +const int NullMaxVolume = -1; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::VideoPlayer::VideoPlayer() : m_audioOutput(NULL) + , m_error(NoError) + , m_state(GroundState) + , m_tickInterval(DefaultTickInterval) + , m_tickTimer(NULL) + , m_volume(0.0) + , m_maxVolume(NullMaxVolume) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); + TRACE_ENTRY_0(); + + Q_UNUSED(parent); + + // TODO: should leaves be trapped in the constructor? + m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); + + m_tickTimer = new QTimer(this); + connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); + + TRACE_EXIT_0(); +#endif +} + +MMF::VideoPlayer::~VideoPlayer() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EAudioApi); + TRACE_ENTRY_0(); + + delete m_tickTimer; + delete m_player; + + TRACE_EXIT_0(); +#endif +} + +//----------------------------------------------------------------------------- +// VideoPlayerInterface +//----------------------------------------------------------------------------- + +void MMF::VideoPlayer::play() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::play, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + // Is this the correct error? Really we want 'NotReadyError' + m_error = NormalError; + changeState(ErrorState); + break; + + case StoppedState: + case PausedState: + m_player->Play(); + m_tickTimer->start(m_tickInterval); + changeState(PlayingState); + break; + + case PlayingState: + case BufferingState: + case ErrorState: + // Do nothing + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +#endif +} + +void MMF::VideoPlayer::pause() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::pause, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case PausedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + m_player->Pause(); + m_tickTimer->stop(); + changeState(PausedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +#endif +} + +void MMF::VideoPlayer::stop() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::stop, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + case PausedState: + m_player->Stop(); + m_tickTimer->stop(); + changeState(StoppedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +#endif +} + +void MMF::VideoPlayer::seek(qint64 ms) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::seek, EAudioApi); + TRACE_ENTRY("state %d pos %Ld", m_state, ms); + + m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); + + TRACE_EXIT_0(); +#endif +} + +qint32 MMF::VideoPlayer::tickInterval() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::tickInterval, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_RETURN("%d", m_tickInterval); +#endif +} + +void MMF::VideoPlayer::setTickInterval(qint32 interval) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setTickInterval, EAudioApi); + TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); + + m_tickInterval = interval; + m_tickTimer->setInterval(interval); + + TRACE_EXIT_0(); +#endif +} + +bool MMF::VideoPlayer::hasVideo() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::hasVideo, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: re-factor this class so that audio playback and video playback are + // delegated to separate classes, which internally hoat a + // CMdaVideoPlayerUtility / CVideoPlayerUtility instance as appropriate. + + TRACE_RETURN("%d", false); +#endif +} + +bool MMF::VideoPlayer::isSeekable() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::isSeekable, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_RETURN("%d", true); +#endif +} + +Phonon::State MMF::VideoPlayer::state() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::state, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const Phonon::State result = phononState(m_state); + + TRACE_RETURN("%d", result); +#endif +} + +qint64 MMF::VideoPlayer::currentTime() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::currentTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TTimeIntervalMicroSeconds us; + const TInt err = m_player->GetPosition(us); + + qint64 result = -1; + + if(KErrNone == err) { + result = toMilliSeconds(us); + } + + TRACE_RETURN("%Ld", result); +#endif +} + +QString MMF::VideoPlayer::errorString() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::errorString, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_EXIT_0(); + // TODO: put in proper error strings + QString result; + return result; +#endif +} + +Phonon::ErrorType MMF::VideoPlayer::errorType() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::errorType, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const Phonon::ErrorType result = (ErrorState == m_state) + ? m_error : NoError; + + TRACE_RETURN("%d", result); +#endif +} + +qint64 MMF::VideoPlayer::totalTime() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::totalTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const qint64 result = toMilliSeconds(m_player->Duration()); + + TRACE_RETURN("%Ld", result); +#endif +} + +MediaSource MMF::VideoPlayer::source() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::source, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_EXIT_0(); + return m_mediaSource; +#endif +} + +void MMF::VideoPlayer::setSource(const MediaSource &source) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setSource, EAudioApi); + TRACE_ENTRY("state %d source.type %d", m_state, source.type()); + + m_player->Close(); + changeState(GroundState); + + // TODO: is it correct to assign even if the media type is not supported in + // the switch statement below? + m_mediaSource = source; + + TInt symbianErr = KErrNone; + + switch(m_mediaSource.type()) + { + case MediaSource::LocalFile: + { + // TODO: work out whose responsibility it is to ensure that paths + // are Symbian-style, i.e. have backslashes for path delimiters. + // Until then, use this utility function... + const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName()); + TRAP(symbianErr, m_player->OpenFileL(*filename)); + break; + } + + case MediaSource::Url: + { + const QHBufC filename(m_mediaSource.url().toString()); + TRAP(symbianErr, m_player->OpenUrlL(*filename)); + break; + } + + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + symbianErr = KErrNotSupported; + break; + + case MediaSource::Empty: + TRACE_EXIT_0(); + return; + + // Protection against adding new media types and forgetting to update this switch + default: + TRACE_PANIC(InvalidMediaTypePanic); + } + + if(KErrNone == symbianErr) + { +#ifdef QT_PHONON_MMF_AUDIO_DRM + // There appears to be a bug in the CDrmPlayerUtility implementation (at least + // in S60 5.x) whereby the player does not check whether the loading observer + // pointer is null before dereferencing it. Therefore we must register for + // loading notification, even though we do nothing in the callback functions. + m_player->RegisterForAudioLoadingNotification(*this); +#endif + changeState(LoadingState); + } + else + { + // TODO: do something with the value of symbianErr? + m_error = NormalError; + changeState(ErrorState); + } + + TRACE_EXIT_0(); +#endif +} + +void MMF::VideoPlayer::setNextSource(const MediaSource &source) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setNextSource, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: handle 'next source' + + m_nextSource = source; + Q_UNUSED(source); + + TRACE_EXIT_0(); +#endif +} + +qint32 MMF::VideoPlayer::prefinishMark() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::prefinishMark, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement prefinish mark + const qint32 result = 0; + TRACE_RETURN("%d", result); +#endif +} + +void MMF::VideoPlayer::setPrefinishMark(qint32 mark) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setPrefinishMark, EAudioApi); + TRACE_ENTRY("state %d mark %d", m_state, mark); + Q_UNUSED(mark); // to silence warnings in release builds + + // TODO: implement prefinish mark + + TRACE_EXIT_0(); +#endif +} + +qint32 MMF::VideoPlayer::transitionTime() const +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::transitionTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement transition time + const qint32 result = 0; + TRACE_RETURN("%d", result); +#endif +} + +void MMF::VideoPlayer::setTransitionTime(qint32 time) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setTransitionTime, EAudioApi); + TRACE_ENTRY("state %d time %d", m_state, time); + Q_UNUSED(time); // to silence warnings in release builds + + // TODO: implement transition time + + TRACE_EXIT_0(); +#endif +} + + +//----------------------------------------------------------------------------- +// Volume +//----------------------------------------------------------------------------- + +qreal MMF::VideoPlayer::volume() const +{ + //return m_volume; +} + +bool MMF::VideoPlayer::setVolume(qreal volume) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::setVolume, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + bool volumeChanged = false; + + switch(m_state) + { + case GroundState: + case LoadingState: + case ErrorState: + // Do nothing + break; + + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: + { + if(volume != m_volume) + { + const int err = m_player->SetVolume(volume * m_maxVolume); + if(KErrNone == err) + { + m_volume = volume; + volumeChanged = true; + } + else + { + m_error = NormalError; + changeState(ErrorState); + } + } + break; + } + + // Protection against adding new states and forgetting to update this + // switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_RETURN("%d", volumeChanged); +#endif +} + +void MMF::VideoPlayer::setAudioOutput(AudioOutput* audioOutput) +{ + //m_audioOutput = audioOutput; +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +qint64 MMF::VideoPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) +{ + //return in.Int64() / 1000; +} + +Phonon::State MMF::VideoPlayer::phononState(PrivateState state) +{ +#if 0 + const Phonon::State phononState = + GroundState == state + ? Phonon::StoppedState + : static_cast(state); + + return phononState; +#endif +} + +void MMF::VideoPlayer::changeState(PrivateState newState) +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::changeState, EAudioInternal); + TRACE_ENTRY("state %d newState %d", m_state, newState); + + // TODO: add some invariants to check that the transition is valid + + const Phonon::State currentPhononState = phononState(m_state); + const Phonon::State newPhononState = phononState(newState); + if(currentPhononState != newPhononState) + { + TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); + emit stateChanged(newPhononState, currentPhononState); + } + + m_state = newState; + + TRACE_EXIT_0(); +#endif +} + +void MMF::VideoPlayer::tick() +{ +#if 0 + TRACE_CONTEXT(VideoPlayer::tick, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + emit tick(currentTime()); + + TRACE_EXIT_0(); +#endif +} + diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h new file mode 100644 index 0000000..3ea9c1a --- /dev/null +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -0,0 +1,163 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_VIDEOPLAYER_H +#define PHONON_MMF_VIDEOPLAYER_H + +/* We use the extra qualification include/ to avoid picking up the include + * Phonon has. */ +#include +#include "abstractplayer.h" + +#include + +class CDrmPlayerUtility; +class TTimeIntervalMicroSeconds; +class QTimer; + +namespace Phonon +{ + namespace MMF + { + class AudioOutput; + + /** + * + * See + * How to + * play a video file using CVideoPlayerUtility + */ + class VideoPlayer : public AbstractPlayer + { + Q_OBJECT + public: + VideoPlayer(); + virtual ~VideoPlayer(); + + // AbstractPlayer + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual qint32 tickInterval() const; + virtual void setTickInterval(qint32 interval); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + virtual void setSource(const MediaSource &); + virtual void setNextSource(const MediaSource &source); + virtual qint32 prefinishMark() const; + virtual void setPrefinishMark(qint32); + virtual qint32 transitionTime() const; + virtual void setTransitionTime(qint32); + +#ifdef QT_PHONON_MMF_AUDIO_DRM + // MDrmVideoPlayerCallback + virtual void MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MdapcPlayComplete(TInt aError); + + // MAudioLoadingObserver + virtual void MaloLoadingStarted(); + virtual void MaloLoadingComplete(); +#else + // MMdaVideoPlayerCallback + virtual void MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MapcPlayComplete(TInt aError); +#endif + + qreal volume() const; + bool setVolume(qreal volume); + + void setAudioOutput(AudioOutput* audioOutput); + + Q_SIGNALS: + void totalTimeChanged(); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + void finished(); + void tick(qint64 time); + + private Q_SLOTS: + /** + * Receives signal from m_tickTimer + */ + void tick(); + + private: + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + + /** + * Defined private state enumeration in order to add GroundState + */ + enum PrivateState + { + LoadingState = Phonon::LoadingState, + StoppedState = Phonon::StoppedState, + PlayingState = Phonon::PlayingState, + BufferingState = Phonon::BufferingState, + PausedState = Phonon::PausedState, + ErrorState = Phonon::ErrorState, + GroundState + }; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + static Phonon::State phononState(PrivateState state); + + /** + * Changes state and emits stateChanged() + */ + void changeState(PrivateState newState); + + /** + * Using CPlayerType typedef in order to be able to easily switch between + * CMdaVideoPlayerUtility and CDrmPlayerUtility + */ + // CPlayerType* m_player; TODO + + AudioOutput* m_audioOutput; + + ErrorType m_error; + + /** + * Do not set this directly - call changeState() instead. + */ + PrivateState m_state; + + qint32 m_tickInterval; + + QTimer* m_tickTimer; + + MediaSource m_mediaSource; + MediaSource m_nextSource; + + qreal m_volume; + int m_maxVolume; + }; + } +} + +#endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 266c3db..5ac62ad 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -28,7 +28,7 @@ HEADERS += \ $$PHONON_MMF_DIR/backend.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/utils.h \ - $$PHONON_MMF_DIR/mmf_videoplayer.h + $$PHONON_MMF_DIR/videoplayer.h SOURCES += \ $$PHONON_MMF_DIR/audiooutput.cpp \ @@ -36,7 +36,7 @@ SOURCES += \ $$PHONON_MMF_DIR/backend.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/utils.cpp \ - $$PHONON_MMF_DIR/mmf_videoplayer.cpp + $$PHONON_MMF_DIR/videoplayer.cpp # This is needed for having the .qtplugin file properly created on Symbian. QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend -- cgit v0.12 From f21096e918a587287d61446e930c40914e2b7ce5 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 18 Aug 2009 11:50:35 +0200 Subject: Add the DummyPlayer, as discussed with Gareth. --- src/3rdparty/phonon/mmf/abstractplayer.h | 3 +- src/3rdparty/phonon/mmf/dummyplayer.cpp | 137 +++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/dummyplayer.h | 74 +++++++++++++++ src/3rdparty/phonon/mmf/mediaobject.cpp | 154 +++++++------------------------ src/plugins/phonon/mmf/mmf.pro | 6 +- 5 files changed, 247 insertions(+), 127 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/dummyplayer.cpp create mode 100644 src/3rdparty/phonon/mmf/dummyplayer.h diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 418b896..397521a 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -52,8 +52,7 @@ namespace Phonon // This is a temporary hack to work around KErrInUse from MMF // client utility OpenFileL calls //virtual void setSource(const Phonon::MediaSource &) = 0; - virtual void setFileSource - (const Phonon::MediaSource&, RFile&) = 0; + virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; virtual void setNextSource(const Phonon::MediaSource &) = 0; diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp new file mode 100644 index 0000000..ecd6815 --- /dev/null +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -0,0 +1,137 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "dummyplayer.h" + +using namespace Phonon; +using namespace Phonon::MMF; + +void MMF::DummyPlayer::play() +{ +} + +void MMF::DummyPlayer::pause() +{ +} + +void MMF::DummyPlayer::stop() +{ +} + +void MMF::DummyPlayer::seek(qint64) +{ +} + +qint32 MMF::DummyPlayer::tickInterval() const +{ + return 0; +} + +void MMF::DummyPlayer::setTickInterval(qint32) +{ +} + +bool MMF::DummyPlayer::hasVideo() const +{ + return false; +} + +bool MMF::DummyPlayer::isSeekable() const +{ + return false; +} + +Phonon::State MMF::DummyPlayer::state() const +{ + return Phonon::StoppedState; +} + +qint64 MMF::DummyPlayer::currentTime() const +{ + return 0; +} + +QString MMF::DummyPlayer::errorString() const +{ + return QString(); +} + +Phonon::ErrorType MMF::DummyPlayer::errorType() const +{ + return Phonon::NoError; +} + +qint64 MMF::DummyPlayer::totalTime() const +{ + return 0; +} + +MediaSource MMF::DummyPlayer::source() const +{ + return MediaSource(); +} + +void MMF::DummyPlayer::setSource(const MediaSource &) +{ +} + +void MMF::DummyPlayer::setNextSource(const MediaSource &) +{ +} + +qint32 MMF::DummyPlayer::prefinishMark() const +{ + return 0; +} + +void MMF::DummyPlayer::setPrefinishMark(qint32) +{ +} + +qint32 MMF::DummyPlayer::transitionTime() const +{ + return 0; +} + +void MMF::DummyPlayer::setTransitionTime(qint32) +{ +} + +void MMF::DummyPlayer::setFileSource(const Phonon::MediaSource &, RFile &) +{ +} + +//----------------------------------------------------------------------------- +// Volume +//----------------------------------------------------------------------------- + +qreal MMF::DummyPlayer::volume() const +{ + return 0; +} + +bool MMF::DummyPlayer::setVolume(qreal) +{ + return true; +} + +void MMF::DummyPlayer::setAudioOutput(AudioOutput *) +{ +} + + diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h new file mode 100644 index 0000000..263a013 --- /dev/null +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -0,0 +1,74 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_DUMMYPLAYER_H +#define PHONON_MMF_DUMMYPLAYER_H + +#include "abstractplayer.h" + +namespace Phonon +{ + namespace MMF + { + class AudioOutput; + + /** + * @short In order to make the implementation of MediaObject simpler, + * we have this class. + */ + class DummyPlayer : public AbstractPlayer + { + public: + // AbstractPlayer + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual qint32 tickInterval() const; + virtual void setTickInterval(qint32 interval); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + virtual void setSource(const MediaSource &); + virtual void setNextSource(const MediaSource &source); + virtual qint32 prefinishMark() const; + virtual void setPrefinishMark(qint32); + virtual qint32 transitionTime() const; + virtual void setTransitionTime(qint32); + virtual qreal volume() const; + virtual bool setVolume(qreal volume); + + virtual void setAudioOutput(AudioOutput* audioOutput); + virtual void setFileSource(const Phonon::MediaSource&, RFile&); + + Q_SIGNALS: + void totalTimeChanged(); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + void finished(); + void tick(qint64 time); + }; + } +} + +#endif diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 62dc903..0d106f5 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -17,6 +17,7 @@ along with this library. If not, see . */ #include "audioplayer.h" +#include "dummyplayer.h" #include "mediaobject.h" #include "utils.h" #include "videoplayer.h" @@ -31,6 +32,8 @@ using namespace Phonon::MMF; MMF::MediaObject::MediaObject(QObject *parent) : QObject::QObject(parent) { + m_player.reset(new DummyPlayer()); + TRACE_CONTEXT(MediaObject::MediaObject, EAudioApi); TRACE_ENTRY_0(); @@ -121,145 +124,81 @@ MMF::MediaObject::MediaType MMF::MediaObject::fileMediaType void MMF::MediaObject::play() { - if(!m_player.isNull()) - { - m_player->play(); - } + m_player->play(); } void MMF::MediaObject::pause() { - if(!m_player.isNull()) - { - m_player->pause(); - } + m_player->pause(); } void MMF::MediaObject::stop() { - if(!m_player.isNull()) - { - m_player->stop(); - } + m_player->stop(); } void MMF::MediaObject::seek(qint64 ms) { - if(!m_player.isNull()) - { - m_player->seek(ms); - } + m_player->seek(ms); } qint32 MMF::MediaObject::tickInterval() const { - qint32 result = 0; - if(!m_player.isNull()) - { - result = m_player->tickInterval(); - } - return result; + return m_player->tickInterval(); } void MMF::MediaObject::setTickInterval(qint32 interval) { - if(!m_player.isNull()) - { - m_player->setTickInterval(interval); - } + m_player->setTickInterval(interval); } bool MMF::MediaObject::hasVideo() const { - bool result = false; - if(!m_player.isNull()) - { - result = m_player->hasVideo(); - } - return result; + return m_player->hasVideo(); } bool MMF::MediaObject::isSeekable() const { - bool result = false; - if(!m_player.isNull()) - { - result = m_player->isSeekable(); - } - return result; + return m_player->isSeekable(); } Phonon::State MMF::MediaObject::state() const { - Phonon::State result = Phonon::StoppedState; - if(!m_player.isNull()) - { - result = m_player->state(); - } - return result; + return m_player->state(); } qint64 MMF::MediaObject::currentTime() const { - qint64 result = 0; - if(!m_player.isNull()) - { - result = m_player->currentTime(); - } - return result; + return m_player->currentTime(); } QString MMF::MediaObject::errorString() const { - QString result; - if(!m_player.isNull()) - { - result = m_player->errorString(); - } - return result; + return m_player->errorString(); } Phonon::ErrorType MMF::MediaObject::errorType() const { - Phonon::ErrorType result = Phonon::NoError; - if(!m_player.isNull()) - { - result = m_player->errorType(); - } - return result; + return m_player->errorType(); } qint64 MMF::MediaObject::totalTime() const { - qint64 result = 0; - if(!m_player.isNull()) - { - result = m_player->totalTime(); - } - return result; + return m_player->totalTime(); } MediaSource MMF::MediaObject::source() const { - MediaSource result; - if(!m_player.isNull()) - { - result = m_player->source(); - } - return result; + return m_player->source(); } void MMF::MediaObject::setSource(const MediaSource &source) { loadPlayer(source); - if(!m_player.isNull()) - { - //m_player->setSource(source); - - // This is a hack to work around KErrInUse from MMF client utility - // OpenFileL calls - m_player->setFileSource(source, m_file); - } + + // This is a hack to work around KErrInUse from MMF client utility + // OpenFileL calls + m_player->setFileSource(source, m_file); } void MMF::MediaObject::loadPlayer(const MediaSource &source) @@ -273,7 +212,7 @@ void MMF::MediaObject::loadPlayer(const MediaSource &source) if(!m_player.isNull()) { disconnect(m_player.data(), 0, this, 0); - m_player.reset(NULL); + m_player.reset(); } MediaType mediaType = MediaTypeUnknown; @@ -317,6 +256,7 @@ void MMF::MediaObject::loadPlayer(const MediaSource &source) switch(mediaType) { case MediaTypeUnknown: + m_player.reset(new DummyPlayer()); TRACE_0("Media type could not be determined"); /* * TODO: handle error @@ -346,46 +286,27 @@ void MMF::MediaObject::loadPlayer(const MediaSource &source) void MMF::MediaObject::setNextSource(const MediaSource &source) { - if(!m_player.isNull()) - { - m_player->setNextSource(source); - } + m_player->setNextSource(source); } qint32 MMF::MediaObject::prefinishMark() const { - qint32 result = 0; - if(!m_player.isNull()) - { - result = m_player->prefinishMark(); - } - return result; + return m_player->prefinishMark(); } void MMF::MediaObject::setPrefinishMark(qint32 mark) { - if(!m_player.isNull()) - { - m_player->setPrefinishMark(mark); - } + m_player->setPrefinishMark(mark); } qint32 MMF::MediaObject::transitionTime() const { - qint32 result = 0; - if(!m_player.isNull()) - { - result = m_player->transitionTime(); - } - return result; + return m_player->transitionTime(); } void MMF::MediaObject::setTransitionTime(qint32 time) { - if(!m_player.isNull()) - { - m_player->setTransitionTime(time); - } + m_player->setTransitionTime(time); } //----------------------------------------------------------------------------- @@ -394,29 +315,16 @@ void MMF::MediaObject::setTransitionTime(qint32 time) qreal MMF::MediaObject::volume() const { - qreal result = 0.0; - if(!m_player.isNull()) - { - m_player->volume(); - } - return result; + return m_player->volume(); } bool MMF::MediaObject::setVolume(qreal volume) { - bool result = false; - if(!m_player.isNull()) - { - result = m_player->setVolume(volume); - } - return result; + return m_player->setVolume(volume); } void MMF::MediaObject::setAudioOutput(AudioOutput* audioOutput) { - if(!m_player.isNull()) - { - m_player->setAudioOutput(audioOutput); - } + m_player->setAudioOutput(audioOutput); } diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 0f00832..7beaa86 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -26,6 +26,7 @@ HEADERS += \ $$PHONON_MMF_DIR/audiooutput.h \ $$PHONON_MMF_DIR/audioplayer.h \ $$PHONON_MMF_DIR/backend.h \ + $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/utils.h \ $$PHONON_MMF_DIR/videoplayer.h @@ -34,12 +35,13 @@ SOURCES += \ $$PHONON_MMF_DIR/audiooutput.cpp \ $$PHONON_MMF_DIR/audioplayer.cpp \ $$PHONON_MMF_DIR/backend.cpp \ + $$PHONON_MMF_DIR/dummyplayer.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/utils.cpp \ $$PHONON_MMF_DIR/videoplayer.cpp -LIBS += -lefsrv # For file server -LIBS += -lapgrfx.lib -lapmime.lib # For recognizer +LIBS += -lefsrv # For file server +LIBS += -lapgrfx.lib -lapmime.lib # For recognizer # This is needed for having the .qtplugin file properly created on Symbian. QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend -- cgit v0.12 From 62e9750e4055808f5eb04479b2f0c221e13747ff Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 18 Aug 2009 17:15:01 +0100 Subject: Refactored AudioPlayer and VideoPlayer to separate out common code into AbstractMediaPlayer --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 492 ++++++++++++++++++++++ src/3rdparty/phonon/mmf/abstractmediaplayer.h | 148 +++++++ src/3rdparty/phonon/mmf/abstractplayer.h | 4 + src/3rdparty/phonon/mmf/audioplayer.cpp | 452 ++------------------ src/3rdparty/phonon/mmf/audioplayer.h | 95 +---- src/3rdparty/phonon/mmf/utils.h | 1 + src/3rdparty/phonon/mmf/videoplayer.cpp | 521 ++---------------------- src/3rdparty/phonon/mmf/videoplayer.h | 96 +---- src/plugins/phonon/mmf/mmf.pro | 28 +- 9 files changed, 745 insertions(+), 1092 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/abstractmediaplayer.cpp create mode 100644 src/3rdparty/phonon/mmf/abstractmediaplayer.h diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp new file mode 100644 index 0000000..a3affef --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -0,0 +1,492 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "abstractmediaplayer.h" +#include "audiooutput.h" +#include "utils.h" + +using namespace Phonon; +using namespace Phonon::MMF; + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const qint32 DefaultTickInterval = 20; +const int NullMaxVolume = -1; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AbstractMediaPlayer::AbstractMediaPlayer() : + m_state(GroundState) + , m_error(NoError) + , m_tickInterval(DefaultTickInterval) + , m_tickTimer(new QTimer(this)) + , m_volume(0.0) + , m_mmfMaxVolume(NullMaxVolume) + , m_audioOutput(NULL) +{ + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); +} + +MMF::AbstractMediaPlayer::~AbstractMediaPlayer() +{ + +} + + +//----------------------------------------------------------------------------- +// Public functions (AbstractPlayer interface) +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::play() +{ + TRACE_CONTEXT(AbstractMediaPlayer::play, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + // Is this the correct error? Really we want 'NotReadyError' + m_error = NormalError; + changeState(ErrorState); + break; + + case StoppedState: + case PausedState: + doPlay(); + startTickTimer(); + changeState(PlayingState); + break; + + case PlayingState: + case BufferingState: + case ErrorState: + // Do nothing + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +} + +void MMF::AbstractMediaPlayer::pause() +{ + TRACE_CONTEXT(AbstractMediaPlayer::pause, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case PausedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + doPause(); + stopTickTimer(); + changeState(PausedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +} + +void MMF::AbstractMediaPlayer::stop() +{ + TRACE_CONTEXT(AbstractMediaPlayer::stop, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + switch(m_state) + { + case GroundState: + case LoadingState: + case StoppedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + case PausedState: + doStop(); + stopTickTimer(); + changeState(StoppedState); + break; + + // Protection against adding new states and forgetting to update this switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_EXIT("state %d", m_state); +} + +bool MMF::AbstractMediaPlayer::isSeekable() const +{ + return true; +} + +qint32 MMF::AbstractMediaPlayer::tickInterval() const +{ + TRACE_CONTEXT(AbstractMediaPlayer::tickInterval, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_RETURN("%d", m_tickInterval); +} + +void MMF::AbstractMediaPlayer::setTickInterval(qint32 interval) +{ + TRACE_CONTEXT(AbstractMediaPlayer::setTickInterval, EAudioApi); + TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); + + m_tickInterval = interval; + m_tickTimer->setInterval(interval); + + TRACE_EXIT_0(); +} + +Phonon::ErrorType MMF::AbstractMediaPlayer::errorType() const +{ + TRACE_CONTEXT(AbstractMediaPlayer::errorType, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const Phonon::ErrorType result = (ErrorState == m_state) + ? m_error : NoError; + + TRACE_RETURN("%d", result); +} + +QString MMF::AbstractMediaPlayer::errorString() const +{ + TRACE_CONTEXT(AbstractMediaPlayer::errorString, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + TRACE_EXIT_0(); + // TODO: put in proper error strings + QString result; + return result; +} + +Phonon::State MMF::AbstractMediaPlayer::state() const +{ + TRACE_CONTEXT(AbstractMediaPlayer::state, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + const Phonon::State result = phononState(m_state); + + TRACE_RETURN("%d", result); +} + +qint32 MMF::AbstractMediaPlayer::prefinishMark() const +{ + TRACE_CONTEXT(AbstractMediaPlayer::prefinishMark, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement prefinish mark + const qint32 result = 0; + TRACE_RETURN("%d", result); +} + +void MMF::AbstractMediaPlayer::setPrefinishMark(qint32 mark) +{ + TRACE_CONTEXT(AbstractMediaPlayer::setPrefinishMark, EAudioApi); + TRACE_ENTRY("state %d mark %d", m_state, mark); + Q_UNUSED(mark); // to silence warnings in release builds + + // TODO: implement prefinish mark + + TRACE_EXIT_0(); +} + +qint32 MMF::AbstractMediaPlayer::transitionTime() const +{ + TRACE_CONTEXT(AbstractMediaPlayer::transitionTime, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: implement transition time + const qint32 result = 0; + TRACE_RETURN("%d", result); +} + +void MMF::AbstractMediaPlayer::setTransitionTime(qint32 time) +{ + TRACE_CONTEXT(AbstractMediaPlayer::setTransitionTime, EAudioApi); + TRACE_ENTRY("state %d time %d", m_state, time); + Q_UNUSED(time); // to silence warnings in release builds + + // TODO: implement transition time + + TRACE_EXIT_0(); +} + +MediaSource MMF::AbstractMediaPlayer::source() const +{ + return m_source; +} + +void MMF::AbstractMediaPlayer::setNextSource(const MediaSource &source) +{ + TRACE_CONTEXT(AbstractMediaPlayer::setNextSource, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: handle 'next source' + + m_nextSource = source; + Q_UNUSED(source); + + TRACE_EXIT_0(); +} + +void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& file) +{ + TRACE_CONTEXT(AudioPlayer::setSource, EAudioApi); + TRACE_ENTRY("state %d source.type %d", m_state, source.type()); + + close(); + changeState(GroundState); + + // TODO: is it correct to assign even if the media type is not supported in + // the switch statement below? + m_source = source; + + TInt symbianErr = KErrNone; + + switch(m_source.type()) + { + case MediaSource::LocalFile: + { + // TODO: work out whose responsibility it is to ensure that paths + // are Symbian-style, i.e. have backslashes for path delimiters. + // Until then, use this utility function... + //const QHBufC filename = Utils::symbianFilename(m_source.fileName()); + //TRAP(symbianErr, m_player->OpenFileL(*filename)); + + // Open using shared filehandle + // This is a temporary hack to work around KErrInUse from MMF + // client utility OpenFileL calls + //TRAP(symbianErr, m_player->OpenFileL(file)); + + symbianErr = openFile(file); + break; + } + + case MediaSource::Url: + { + // TODO: support opening URLs + symbianErr = KErrNotSupported; + break; + } + + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + symbianErr = KErrNotSupported; + break; + + case MediaSource::Empty: + TRACE_EXIT_0(); + return; + + // Protection against adding new media types and forgetting to update this switch + default: + TRACE_PANIC(InvalidMediaTypePanic); + } + + if(KErrNone == symbianErr) + { + changeState(LoadingState); + } + else + { + // TODO: do something with the value of symbianErr? + m_error = NormalError; + changeState(ErrorState); + } + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- +// Volume +//----------------------------------------------------------------------------- + +qreal MMF::AbstractMediaPlayer::volume() const +{ + return m_volume; +} + +bool MMF::AbstractMediaPlayer::setVolume(qreal volume) +{ + TRACE_CONTEXT(AbstractMediaPlayer::setVolume, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + bool volumeChanged = false; + + switch(m_state) + { + case GroundState: + case LoadingState: + case ErrorState: + // Do nothing + break; + + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: + { + if(volume != m_volume) + { + const int err = doSetVolume(volume * m_mmfMaxVolume); + + if(KErrNone == err) + { + m_volume = volume; + volumeChanged = true; + + if(m_audioOutput) + { + // Trigger AudioOutput signal + m_audioOutput->triggerVolumeChanged(m_volume); + } + } + else + { + m_error = NormalError; + changeState(ErrorState); + } + } + break; + } + + // Protection against adding new states and forgetting to update this + // switch + default: + TRACE_PANIC(InvalidStatePanic); + } + + TRACE_RETURN("%d", volumeChanged); +} + + +//----------------------------------------------------------------------------- +// Proxies +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::setAudioOutput(AudioOutput* audioOutput) +{ + m_audioOutput = audioOutput; +} + + +//----------------------------------------------------------------------------- +// Protected functions +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::startTickTimer() +{ + m_tickTimer->start(m_tickInterval); +} + +void MMF::AbstractMediaPlayer::stopTickTimer() +{ + m_tickTimer->stop(); +} + +void MMF::AbstractMediaPlayer::initVolume(int initialVolume, int mmfMaxVolume) +{ + m_volume = static_cast(initialVolume) / mmfMaxVolume; + m_mmfMaxVolume = mmfMaxVolume; +} + +Phonon::State MMF::AbstractMediaPlayer::phononState() const +{ + return phononState(m_state); +} + +Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) +{ + const Phonon::State phononState = + GroundState == state + ? Phonon::StoppedState + : static_cast(state); + + return phononState; +} + +void MMF::AbstractMediaPlayer::changeState(PrivateState newState) +{ + TRACE_CONTEXT(AbstractMediaPlayer::changeState, EAudioInternal); + TRACE_ENTRY("state %d newState %d", m_state, newState); + + // TODO: add some invariants to check that the transition is valid + + const Phonon::State currentPhononState = phononState(m_state); + const Phonon::State newPhononState = phononState(newState); + if(currentPhononState != newPhononState) + { + TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); + emit stateChanged(newPhononState, currentPhononState); + } + + m_state = newState; + + TRACE_EXIT_0(); +} + +qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) +{ + return in.Int64() / 1000; +} + + +//----------------------------------------------------------------------------- +// Slots +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::tick() +{ + TRACE_CONTEXT(AbstractMediaPlayer::tick, EAudioInternal); + TRACE_ENTRY("state %d", m_state); + + emit tick(currentTime()); + + TRACE_EXIT_0(); +} + + + + + diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h new file mode 100644 index 0000000..6f7ae1d --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -0,0 +1,148 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_ABSTRACTMEDIAPLAYER_H +#define PHONON_MMF_ABSTRACTMEDIAPLAYER_H + +#include +#include +#include +#include "abstractplayer.h" + +class RFile; + +namespace Phonon +{ + namespace MMF + { + class AudioOutput; + + class AbstractMediaPlayer : public AbstractPlayer + { + Q_OBJECT + + protected: + AbstractMediaPlayer(); + ~AbstractMediaPlayer(); + + public: + // AbstractPlayer + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual bool isSeekable() const; + virtual qint32 tickInterval() const; + virtual void setTickInterval(qint32 interval); + virtual Phonon::ErrorType errorType() const; + virtual QString errorString() const; + virtual Phonon::State state() const; + virtual qint32 prefinishMark() const; + virtual void setPrefinishMark(qint32); + virtual qint32 transitionTime() const; + virtual void setTransitionTime(qint32); + virtual MediaSource source() const; + virtual void setNextSource(const MediaSource &source); + + // This is a temporary hack to work around KErrInUse from MMF + // client utility OpenFileL calls + //virtual void setSource(const Phonon::MediaSource &) = 0; + virtual void setFileSource + (const Phonon::MediaSource&, RFile&); + + qreal volume() const; + bool setVolume(qreal volume); + + void setAudioOutput(AudioOutput* audioOutput); + + protected: + virtual void doPlay() = 0; + virtual void doPause() = 0; + virtual void doStop() = 0; + virtual int doSetVolume(int mmfVolume) = 0; + virtual int openFile(RFile& file) = 0; + virtual void close() = 0; + + protected: + void startTickTimer(); + void stopTickTimer(); + void initVolume(int initialVolume, int maxVolume); + + /** + * Defined private state enumeration in order to add GroundState + */ + enum PrivateState + { + LoadingState = Phonon::LoadingState, + StoppedState = Phonon::StoppedState, + PlayingState = Phonon::PlayingState, + BufferingState = Phonon::BufferingState, + PausedState = Phonon::PausedState, + ErrorState = Phonon::ErrorState, + GroundState + }; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + Phonon::State phononState() const; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + static Phonon::State phononState(PrivateState state); + + /** + * Changes state and emits stateChanged() + */ + void changeState(PrivateState newState); + + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + + Q_SIGNALS: + void tick(qint64 time); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + + private Q_SLOTS: + /** + * Receives signal from m_tickTimer + */ + void tick(); + + protected: // Temporary + PrivateState m_state; + Phonon::ErrorType m_error; + + private: + qint32 m_tickInterval; + QScopedPointer m_tickTimer; + qreal m_volume; + int m_mmfMaxVolume; + + // Not owned + AudioOutput* m_audioOutput; + + MediaSource m_source; + MediaSource m_nextSource; + + }; + } +} + +#endif + diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 418b896..97527ff 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -33,6 +33,10 @@ namespace Phonon class AbstractPlayer : public QObject { + // Required although this class has no signals or slots + // Without this, qobject_cast will fail + Q_OBJECT + public: virtual void play() = 0; virtual void pause() = 0; diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index ce6a5f3..45105ee 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -17,36 +17,18 @@ along with this library. If not, see . */ #include -#include -#include #include "audioplayer.h" -#include "audiooutput.h" #include "utils.h" using namespace Phonon; using namespace Phonon::MMF; //----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const qint32 DefaultTickInterval = 20; -const int NullMaxVolume = -1; - - -//----------------------------------------------------------------------------- // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioPlayer::AudioPlayer() : m_player(NULL) - , m_audioOutput(NULL) - , m_error(NoError) - , m_state(GroundState) - , m_tickInterval(DefaultTickInterval) - , m_tickTimer(NULL) - , m_volume(0.0) - , m_maxVolume(NullMaxVolume) +MMF::AudioPlayer::AudioPlayer() : m_player(NULL) { TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); TRACE_ENTRY_0(); @@ -56,9 +38,6 @@ MMF::AudioPlayer::AudioPlayer() : m_player(NULL) // TODO: should leaves be trapped in the constructor? m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); - m_tickTimer = new QTimer(this); - connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); - TRACE_EXIT_0(); } @@ -67,136 +46,64 @@ MMF::AudioPlayer::~AudioPlayer() TRACE_CONTEXT(AudioPlayer::~AudioPlayer, EAudioApi); TRACE_ENTRY_0(); - delete m_tickTimer; delete m_player; TRACE_EXIT_0(); } //----------------------------------------------------------------------------- -// AudioPlayerInterface +// Public API //----------------------------------------------------------------------------- -void MMF::AudioPlayer::play() +void MMF::AudioPlayer::doPlay() { - TRACE_CONTEXT(AudioPlayer::play, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - // Is this the correct error? Really we want 'NotReadyError' - m_error = NormalError; - changeState(ErrorState); - break; - - case StoppedState: - case PausedState: - m_player->Play(); - m_tickTimer->start(m_tickInterval); - changeState(PlayingState); - break; - - case PlayingState: - case BufferingState: - case ErrorState: - // Do nothing - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); + m_player->Play(); } -void MMF::AudioPlayer::pause() +void MMF::AudioPlayer::doPause() { - TRACE_CONTEXT(AudioPlayer::pause, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case PausedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - m_player->Pause(); - m_tickTimer->stop(); - changeState(PausedState); - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); + m_player->Pause(); } -void MMF::AudioPlayer::stop() +void MMF::AudioPlayer::doStop() { - TRACE_CONTEXT(AudioPlayer::stop, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - case PausedState: - m_player->Stop(); - m_tickTimer->stop(); - changeState(StoppedState); - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); + m_player->Stop(); } -void MMF::AudioPlayer::seek(qint64 ms) +int MMF::AudioPlayer::doSetVolume(int mmfVolume) { - TRACE_CONTEXT(AudioPlayer::seek, EAudioApi); - TRACE_ENTRY("state %d pos %Ld", m_state, ms); - - m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); - - TRACE_EXIT_0(); + return m_player->SetVolume(mmfVolume); } -qint32 MMF::AudioPlayer::tickInterval() const +int MMF::AudioPlayer::openFile(RFile& file) { - TRACE_CONTEXT(AudioPlayer::tickInterval, EAudioApi); - TRACE_ENTRY("state %d", m_state); + TRAPD(err, m_player->OpenFileL(file)); + +#ifdef QT_PHONON_MMF_AUDIO_DRM + if(KErrNone == err) + { + // There appears to be a bug in the CDrmPlayerUtility implementation (at least + // in S60 5.x) whereby the player does not check whether the loading observer + // pointer is null before dereferencing it. Therefore we must register for + // loading notification, even though we do nothing in the callback functions. + m_player->RegisterForAudioLoadingNotification(*this); + } +#endif + + return err; +} - TRACE_RETURN("%d", m_tickInterval); +void MMF::AudioPlayer::close() +{ + m_player->Close(); } -void MMF::AudioPlayer::setTickInterval(qint32 interval) +void MMF::AudioPlayer::seek(qint64 ms) { - TRACE_CONTEXT(AudioPlayer::setTickInterval, EAudioApi); - TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); + TRACE_CONTEXT(AudioPlayer::seek, EAudioApi); + TRACE_ENTRY("state %d pos %Ld", m_state, ms); - m_tickInterval = interval; - m_tickTimer->setInterval(interval); + m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); TRACE_EXIT_0(); } @@ -205,32 +112,9 @@ bool MMF::AudioPlayer::hasVideo() const { TRACE_CONTEXT(AudioPlayer::hasVideo, EAudioApi); TRACE_ENTRY("state %d", m_state); - - // TODO: re-factor this class so that audio playback and video playback are - // delegated to separate classes, which internally hoat a - // CMdaAudioPlayerUtility / CVideoPlayerUtility instance as appropriate. - TRACE_RETURN("%d", false); } -bool MMF::AudioPlayer::isSeekable() const -{ - TRACE_CONTEXT(AudioPlayer::isSeekable, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_RETURN("%d", true); -} - -Phonon::State MMF::AudioPlayer::state() const -{ - TRACE_CONTEXT(AudioPlayer::state, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const Phonon::State result = phononState(m_state); - - TRACE_RETURN("%d", result); -} - qint64 MMF::AudioPlayer::currentTime() const { TRACE_CONTEXT(AudioPlayer::currentTime, EAudioApi); @@ -248,28 +132,6 @@ qint64 MMF::AudioPlayer::currentTime() const TRACE_RETURN("%Ld", result); } -QString MMF::AudioPlayer::errorString() const -{ - TRACE_CONTEXT(AudioPlayer::errorString, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_EXIT_0(); - // TODO: put in proper error strings - QString result; - return result; -} - -Phonon::ErrorType MMF::AudioPlayer::errorType() const -{ - TRACE_CONTEXT(AudioPlayer::errorType, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const Phonon::ErrorType result = (ErrorState == m_state) - ? m_error : NoError; - - TRACE_RETURN("%d", result); -} - qint64 MMF::AudioPlayer::totalTime() const { TRACE_CONTEXT(AudioPlayer::totalTime, EAudioApi); @@ -280,144 +142,6 @@ qint64 MMF::AudioPlayer::totalTime() const TRACE_RETURN("%Ld", result); } -MediaSource MMF::AudioPlayer::source() const -{ - TRACE_CONTEXT(AudioPlayer::source, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_EXIT_0(); - return m_mediaSource; -} - -void MMF::AudioPlayer::setFileSource(const MediaSource &source, RFile& file) -{ - TRACE_CONTEXT(AudioPlayer::setSource, EAudioApi); - TRACE_ENTRY("state %d source.type %d", m_state, source.type()); - - m_player->Close(); - changeState(GroundState); - - // TODO: is it correct to assign even if the media type is not supported in - // the switch statement below? - m_mediaSource = source; - - TInt symbianErr = KErrNone; - - switch(m_mediaSource.type()) - { - case MediaSource::LocalFile: - { - // TODO: work out whose responsibility it is to ensure that paths - // are Symbian-style, i.e. have backslashes for path delimiters. - // Until then, use this utility function... - const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName()); - //TRAP(symbianErr, m_player->OpenFileL(*filename)); - - // Open using shared filehandle - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - TRAP(symbianErr, m_player->OpenFileL(file)); - break; - } - - case MediaSource::Url: - { - const QHBufC filename(m_mediaSource.url().toString()); - TRAP(symbianErr, m_player->OpenUrlL(*filename)); - break; - } - - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - symbianErr = KErrNotSupported; - break; - - case MediaSource::Empty: - TRACE_EXIT_0(); - return; - - // Protection against adding new media types and forgetting to update this switch - default: - TRACE_PANIC(InvalidMediaTypePanic); - } - - if(KErrNone == symbianErr) - { -#ifdef QT_PHONON_MMF_AUDIO_DRM - // There appears to be a bug in the CDrmPlayerUtility implementation (at least - // in S60 5.x) whereby the player does not check whether the loading observer - // pointer is null before dereferencing it. Therefore we must register for - // loading notification, even though we do nothing in the callback functions. - m_player->RegisterForAudioLoadingNotification(*this); -#endif - changeState(LoadingState); - } - else - { - // TODO: do something with the value of symbianErr? - m_error = NormalError; - changeState(ErrorState); - } - - TRACE_EXIT_0(); -} - -void MMF::AudioPlayer::setNextSource(const MediaSource &source) -{ - TRACE_CONTEXT(AudioPlayer::setNextSource, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: handle 'next source' - - m_nextSource = source; - Q_UNUSED(source); - - TRACE_EXIT_0(); -} - -qint32 MMF::AudioPlayer::prefinishMark() const -{ - TRACE_CONTEXT(AudioPlayer::prefinishMark, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement prefinish mark - const qint32 result = 0; - TRACE_RETURN("%d", result); -} - -void MMF::AudioPlayer::setPrefinishMark(qint32 mark) -{ - TRACE_CONTEXT(AudioPlayer::setPrefinishMark, EAudioApi); - TRACE_ENTRY("state %d mark %d", m_state, mark); - Q_UNUSED(mark); // to silence warnings in release builds - - // TODO: implement prefinish mark - - TRACE_EXIT_0(); -} - -qint32 MMF::AudioPlayer::transitionTime() const -{ - TRACE_CONTEXT(AudioPlayer::transitionTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement transition time - const qint32 result = 0; - TRACE_RETURN("%d", result); -} - -void MMF::AudioPlayer::setTransitionTime(qint32 time) -{ - TRACE_CONTEXT(AudioPlayer::setTransitionTime, EAudioApi); - TRACE_ENTRY("state %d time %d", m_state, time); - Q_UNUSED(time); // to silence warnings in release builds - - // TODO: implement transition time - - TRACE_EXIT_0(); -} - //----------------------------------------------------------------------------- // Symbian multimedia client observer callbacks @@ -442,14 +166,7 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, aError = m_player->GetVolume(volume); if(KErrNone == aError) { - m_maxVolume = m_player->MaxVolume(); - m_volume = static_cast(volume) / m_maxVolume; - - if(m_audioOutput) - { - // Trigger AudioOutput signal - m_audioOutput->triggerVolumeChanged(m_volume); - } + initVolume(volume, m_player->MaxVolume()); emit totalTimeChanged(); changeState(StoppedState); @@ -474,7 +191,7 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) TRACE_CONTEXT(AudioPlayer::MapcPlayComplete, EAudioInternal); TRACE_ENTRY("state %d error %d", m_state, aError); - m_tickTimer->stop(); + stopTickTimer(); if(KErrNone == aError) { @@ -521,115 +238,16 @@ void MMF::AudioPlayer::MaloLoadingComplete() #endif // QT_PHONON_MMF_AUDIO_DRM -//----------------------------------------------------------------------------- -// Volume -//----------------------------------------------------------------------------- - -qreal MMF::AudioPlayer::volume() const -{ - return m_volume; -} - -bool MMF::AudioPlayer::setVolume(qreal volume) -{ - TRACE_CONTEXT(AudioPlayer::setVolume, EAudioInternal); - TRACE_ENTRY("state %d", m_state); - - bool volumeChanged = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case ErrorState: - // Do nothing - break; - - case StoppedState: - case PausedState: - case PlayingState: - case BufferingState: - { - if(volume != m_volume) - { - const int err = m_player->SetVolume(volume * m_maxVolume); - if(KErrNone == err) - { - m_volume = volume; - volumeChanged = true; - } - else - { - m_error = NormalError; - changeState(ErrorState); - } - } - break; - } - - // Protection against adding new states and forgetting to update this - // switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_RETURN("%d", volumeChanged); -} - -void MMF::AudioPlayer::setAudioOutput(AudioOutput* audioOutput) -{ - m_audioOutput = audioOutput; -} - - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -qint64 MMF::AudioPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) -{ - return in.Int64() / 1000; -} -Phonon::State MMF::AudioPlayer::phononState(PrivateState state) -{ - const Phonon::State phononState = - GroundState == state - ? Phonon::StoppedState - : static_cast(state); - return phononState; -} -void MMF::AudioPlayer::changeState(PrivateState newState) -{ - TRACE_CONTEXT(AudioPlayer::changeState, EAudioInternal); - TRACE_ENTRY("state %d newState %d", m_state, newState); - // TODO: add some invariants to check that the transition is valid - const Phonon::State currentPhononState = phononState(m_state); - const Phonon::State newPhononState = phononState(newState); - if(currentPhononState != newPhononState) - { - TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); - emit stateChanged(newPhononState, currentPhononState); - } - m_state = newState; - TRACE_EXIT_0(); -} -void MMF::AudioPlayer::tick() -{ - TRACE_CONTEXT(AudioPlayer::tick, EAudioInternal); - TRACE_ENTRY("state %d", m_state); - emit tick(currentTime()); - TRACE_EXIT_0(); -} diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index f573c94..f58ee0d 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -19,7 +19,7 @@ along with this library. If not, see . #ifndef PHONON_MMF_AUDIOPLAYER_H #define PHONON_MMF_AUDIOPLAYER_H -#include "abstractplayer.h" +#include "abstractmediaplayer.h" class CDrmPlayerUtility; class TTimeIntervalMicroSeconds; @@ -47,7 +47,7 @@ namespace Phonon * How to * play a video file using CVideoPlayerUtility */ - class AudioPlayer : public AbstractPlayer + class AudioPlayer : public AbstractMediaPlayer , public MPlayerObserverType // typedef #ifdef QT_PHONON_MMF_AUDIO_DRM , public MAudioLoadingObserver @@ -59,33 +59,18 @@ namespace Phonon AudioPlayer(); virtual ~AudioPlayer(); - // AbstractPlayer - virtual void play(); - virtual void pause(); - virtual void stop(); + // AbstractMediaPlayer + virtual void doPlay(); + virtual void doPause(); + virtual void doStop(); + virtual int doSetVolume(int mmfVolume); + virtual int openFile(RFile& file); + virtual void close(); + virtual void seek(qint64 milliseconds); - virtual qint32 tickInterval() const; - virtual void setTickInterval(qint32 interval); virtual bool hasVideo() const; - virtual bool isSeekable() const; virtual qint64 currentTime() const; - virtual Phonon::State state() const; - virtual QString errorString() const; - virtual Phonon::ErrorType errorType() const; virtual qint64 totalTime() const; - virtual MediaSource source() const; - - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //virtual void setSource(const Phonon::MediaSource &) = 0; - virtual void setFileSource - (const Phonon::MediaSource&, RFile&); - - virtual void setNextSource(const MediaSource &source); - virtual qint32 prefinishMark() const; - virtual void setPrefinishMark(qint32); - virtual qint32 transitionTime() const; - virtual void setTransitionTime(qint32); #ifdef QT_PHONON_MMF_AUDIO_DRM // MDrmAudioPlayerCallback @@ -103,75 +88,17 @@ namespace Phonon virtual void MapcPlayComplete(TInt aError); #endif - qreal volume() const; - bool setVolume(qreal volume); - - void setAudioOutput(AudioOutput* audioOutput); - Q_SIGNALS: void totalTimeChanged(); - void stateChanged(Phonon::State oldState, - Phonon::State newState); - void finished(); - void tick(qint64 time); - - private Q_SLOTS: - /** - * Receives signal from m_tickTimer - */ - void tick(); + void finished(); private: - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - /** - * Defined private state enumeration in order to add GroundState - */ - enum PrivateState - { - LoadingState = Phonon::LoadingState, - StoppedState = Phonon::StoppedState, - PlayingState = Phonon::PlayingState, - BufferingState = Phonon::BufferingState, - PausedState = Phonon::PausedState, - ErrorState = Phonon::ErrorState, - GroundState - }; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - static Phonon::State phononState(PrivateState state); - - /** - * Changes state and emits stateChanged() - */ - void changeState(PrivateState newState); - /** * Using CPlayerType typedef in order to be able to easily switch between * CMdaAudioPlayerUtility and CDrmPlayerUtility */ CPlayerType* m_player; - AudioOutput* m_audioOutput; - - ErrorType m_error; - - /** - * Do not set this directly - call changeState() instead. - */ - PrivateState m_state; - - qint32 m_tickInterval; - - QTimer* m_tickTimer; - - MediaSource m_mediaSource; - MediaSource m_nextSource; - - qreal m_volume; - int m_maxVolume; }; } } diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index 72d5472..51470cd 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -20,6 +20,7 @@ along with this library. If not, see . #define PHONON_MMF_UTILS_H #include +#include // for RDebug namespace Phonon { diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index a1cfc3c..3ffa3e7 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -18,560 +18,99 @@ along with this library. If not, see . #include #include -#include #include "videoplayer.h" -#include "audiooutput.h" #include "utils.h" using namespace Phonon; using namespace Phonon::MMF; //----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const qint32 DefaultTickInterval = 20; -const int NullMaxVolume = -1; - - -//----------------------------------------------------------------------------- // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoPlayer::VideoPlayer() : m_audioOutput(NULL) - , m_error(NoError) - , m_state(GroundState) - , m_tickInterval(DefaultTickInterval) - , m_tickTimer(NULL) - , m_volume(0.0) - , m_maxVolume(NullMaxVolume) +MMF::VideoPlayer::VideoPlayer() { -#if 0 TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); TRACE_ENTRY_0(); - Q_UNUSED(parent); - - // TODO: should leaves be trapped in the constructor? - m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); - - m_tickTimer = new QTimer(this); - connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); + // TODO TRACE_EXIT_0(); -#endif } MMF::VideoPlayer::~VideoPlayer() { -#if 0 - TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EAudioApi); - TRACE_ENTRY_0(); - - delete m_tickTimer; - delete m_player; - - TRACE_EXIT_0(); -#endif + // TODO } //----------------------------------------------------------------------------- -// VideoPlayerInterface +// Public API //----------------------------------------------------------------------------- -void MMF::VideoPlayer::play() +void MMF::VideoPlayer::doPlay() { -#if 0 - TRACE_CONTEXT(VideoPlayer::play, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - // Is this the correct error? Really we want 'NotReadyError' - m_error = NormalError; - changeState(ErrorState); - break; - - case StoppedState: - case PausedState: - m_player->Play(); - m_tickTimer->start(m_tickInterval); - changeState(PlayingState); - break; - - case PlayingState: - case BufferingState: - case ErrorState: - // Do nothing - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); -#endif + // TODO } -void MMF::VideoPlayer::pause() +void MMF::VideoPlayer::doPause() { -#if 0 - TRACE_CONTEXT(VideoPlayer::pause, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case PausedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - m_player->Pause(); - m_tickTimer->stop(); - changeState(PausedState); - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); -#endif + // TODO } -void MMF::VideoPlayer::stop() +void MMF::VideoPlayer::doStop() { -#if 0 - TRACE_CONTEXT(VideoPlayer::stop, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - case PausedState: - m_player->Stop(); - m_tickTimer->stop(); - changeState(StoppedState); - break; - - // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_EXIT("state %d", m_state); -#endif + // TODO } -void MMF::VideoPlayer::seek(qint64 ms) +int MMF::VideoPlayer::doSetVolume(int mmfVolume) { -#if 0 - TRACE_CONTEXT(VideoPlayer::seek, EAudioApi); - TRACE_ENTRY("state %d pos %Ld", m_state, ms); - - m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); - - TRACE_EXIT_0(); -#endif -} - -qint32 MMF::VideoPlayer::tickInterval() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::tickInterval, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_RETURN("%d", m_tickInterval); -#endif + // TODO + Q_UNUSED(mmfVolume); + return KErrNotSupported; } -void MMF::VideoPlayer::setTickInterval(qint32 interval) +int MMF::VideoPlayer::openFile(RFile& file) { -#if 0 - TRACE_CONTEXT(VideoPlayer::setTickInterval, EAudioApi); - TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); - - m_tickInterval = interval; - m_tickTimer->setInterval(interval); - - TRACE_EXIT_0(); -#endif + // TODO + Q_UNUSED(file); + return KErrNotSupported; } -bool MMF::VideoPlayer::hasVideo() const +void MMF::VideoPlayer::close() { -#if 0 - TRACE_CONTEXT(VideoPlayer::hasVideo, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: re-factor this class so that audio playback and video playback are - // delegated to separate classes, which internally hoat a - // CMdaVideoPlayerUtility / CVideoPlayerUtility instance as appropriate. - TRACE_RETURN("%d", false); -#endif } -bool MMF::VideoPlayer::isSeekable() const +void MMF::VideoPlayer::seek(qint64 ms) { -#if 0 - TRACE_CONTEXT(VideoPlayer::isSeekable, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_RETURN("%d", true); -#endif + // TODO + Q_UNUSED(ms); } -Phonon::State MMF::VideoPlayer::state() const +bool MMF::VideoPlayer::hasVideo() const { -#if 0 - TRACE_CONTEXT(VideoPlayer::state, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const Phonon::State result = phononState(m_state); - - TRACE_RETURN("%d", result); -#endif + return true; } qint64 MMF::VideoPlayer::currentTime() const { -#if 0 - TRACE_CONTEXT(VideoPlayer::currentTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TTimeIntervalMicroSeconds us; - const TInt err = m_player->GetPosition(us); - - qint64 result = -1; - - if(KErrNone == err) { - result = toMilliSeconds(us); - } - - TRACE_RETURN("%Ld", result); -#endif -} - -QString MMF::VideoPlayer::errorString() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::errorString, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_EXIT_0(); - // TODO: put in proper error strings - QString result; - return result; -#endif -} - -Phonon::ErrorType MMF::VideoPlayer::errorType() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::errorType, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const Phonon::ErrorType result = (ErrorState == m_state) - ? m_error : NoError; - - TRACE_RETURN("%d", result); -#endif + // TODO + return 0; } qint64 MMF::VideoPlayer::totalTime() const { -#if 0 - TRACE_CONTEXT(VideoPlayer::totalTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const qint64 result = toMilliSeconds(m_player->Duration()); - - TRACE_RETURN("%Ld", result); -#endif -} - -MediaSource MMF::VideoPlayer::source() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::source, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_EXIT_0(); - return m_mediaSource; -#endif -} - -void MMF::VideoPlayer::setFileSource(const MediaSource &source, RFile&) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setSource, EAudioApi); - TRACE_ENTRY("state %d source.type %d", m_state, source.type()); - - m_player->Close(); - changeState(GroundState); - - // TODO: is it correct to assign even if the media type is not supported in - // the switch statement below? - m_mediaSource = source; - - TInt symbianErr = KErrNone; - - switch(m_mediaSource.type()) - { - case MediaSource::LocalFile: - { - // TODO: work out whose responsibility it is to ensure that paths - // are Symbian-style, i.e. have backslashes for path delimiters. - // Until then, use this utility function... - const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName()); - TRAP(symbianErr, m_player->OpenFileL(*filename)); - break; - } - - case MediaSource::Url: - { - const QHBufC filename(m_mediaSource.url().toString()); - TRAP(symbianErr, m_player->OpenUrlL(*filename)); - break; - } - - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - symbianErr = KErrNotSupported; - break; - - case MediaSource::Empty: - TRACE_EXIT_0(); - return; - - // Protection against adding new media types and forgetting to update this switch - default: - TRACE_PANIC(InvalidMediaTypePanic); - } - - if(KErrNone == symbianErr) - { -#ifdef QT_PHONON_MMF_AUDIO_DRM - // There appears to be a bug in the CDrmPlayerUtility implementation (at least - // in S60 5.x) whereby the player does not check whether the loading observer - // pointer is null before dereferencing it. Therefore we must register for - // loading notification, even though we do nothing in the callback functions. - m_player->RegisterForAudioLoadingNotification(*this); -#endif - changeState(LoadingState); - } - else - { - // TODO: do something with the value of symbianErr? - m_error = NormalError; - changeState(ErrorState); - } - - TRACE_EXIT_0(); -#endif -} - -void MMF::VideoPlayer::setNextSource(const MediaSource &source) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setNextSource, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: handle 'next source' - - m_nextSource = source; - Q_UNUSED(source); - - TRACE_EXIT_0(); -#endif -} - -qint32 MMF::VideoPlayer::prefinishMark() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::prefinishMark, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement prefinish mark - const qint32 result = 0; - TRACE_RETURN("%d", result); -#endif -} - -void MMF::VideoPlayer::setPrefinishMark(qint32 mark) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setPrefinishMark, EAudioApi); - TRACE_ENTRY("state %d mark %d", m_state, mark); - Q_UNUSED(mark); // to silence warnings in release builds - - // TODO: implement prefinish mark - - TRACE_EXIT_0(); -#endif -} - -qint32 MMF::VideoPlayer::transitionTime() const -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::transitionTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement transition time - const qint32 result = 0; - TRACE_RETURN("%d", result); -#endif -} - -void MMF::VideoPlayer::setTransitionTime(qint32 time) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setTransitionTime, EAudioApi); - TRACE_ENTRY("state %d time %d", m_state, time); - Q_UNUSED(time); // to silence warnings in release builds - - // TODO: implement transition time - - TRACE_EXIT_0(); -#endif -} - - -//----------------------------------------------------------------------------- -// Volume -//----------------------------------------------------------------------------- - -qreal MMF::VideoPlayer::volume() const -{ - //return m_volume; -} - -bool MMF::VideoPlayer::setVolume(qreal volume) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::setVolume, EAudioInternal); - TRACE_ENTRY("state %d", m_state); - - bool volumeChanged = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case ErrorState: - // Do nothing - break; - - case StoppedState: - case PausedState: - case PlayingState: - case BufferingState: - { - if(volume != m_volume) - { - const int err = m_player->SetVolume(volume * m_maxVolume); - if(KErrNone == err) - { - m_volume = volume; - volumeChanged = true; - } - else - { - m_error = NormalError; - changeState(ErrorState); - } - } - break; - } - - // Protection against adding new states and forgetting to update this - // switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_RETURN("%d", volumeChanged); -#endif -} - -void MMF::VideoPlayer::setAudioOutput(AudioOutput* audioOutput) -{ - //m_audioOutput = audioOutput; + // TODO + return 0; } //----------------------------------------------------------------------------- -// Private functions +// Symbian multimedia client observer callbacks //----------------------------------------------------------------------------- -qint64 MMF::VideoPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) -{ - //return in.Int64() / 1000; -} - -Phonon::State MMF::VideoPlayer::phononState(PrivateState state) -{ -#if 0 - const Phonon::State phononState = - GroundState == state - ? Phonon::StoppedState - : static_cast(state); - - return phononState; -#endif -} - -void MMF::VideoPlayer::changeState(PrivateState newState) -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::changeState, EAudioInternal); - TRACE_ENTRY("state %d newState %d", m_state, newState); - - // TODO: add some invariants to check that the transition is valid - - const Phonon::State currentPhononState = phononState(m_state); - const Phonon::State newPhononState = phononState(newState); - if(currentPhononState != newPhononState) - { - TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); - emit stateChanged(newPhononState, currentPhononState); - } +// TODO - m_state = newState; - TRACE_EXIT_0(); -#endif -} - -void MMF::VideoPlayer::tick() -{ -#if 0 - TRACE_CONTEXT(VideoPlayer::tick, EAudioInternal); - TRACE_ENTRY("state %d", m_state); - - emit tick(currentTime()); - - TRACE_EXIT_0(); -#endif -} diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index a880966..65133c2 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -22,7 +22,7 @@ along with this library. If not, see . /* We use the extra qualification include/ to avoid picking up the include * Phonon has. */ #include -#include "abstractplayer.h" +#include "abstractmediaplayer.h" #include @@ -42,7 +42,7 @@ namespace Phonon * How to * play a video file using CVideoPlayerUtility */ - class VideoPlayer : public AbstractPlayer + class VideoPlayer : public AbstractMediaPlayer { Q_OBJECT public: @@ -50,102 +50,24 @@ namespace Phonon virtual ~VideoPlayer(); // AbstractPlayer - virtual void play(); - virtual void pause(); - virtual void stop(); + virtual void doPlay(); + virtual void doPause(); + virtual void doStop(); + virtual int doSetVolume(int mmfVolume); + virtual int openFile(RFile& file); + virtual void close(); + virtual void seek(qint64 milliseconds); - virtual qint32 tickInterval() const; - virtual void setTickInterval(qint32 interval); virtual bool hasVideo() const; - virtual bool isSeekable() const; virtual qint64 currentTime() const; - virtual Phonon::State state() const; - virtual QString errorString() const; - virtual Phonon::ErrorType errorType() const; virtual qint64 totalTime() const; - virtual MediaSource source() const; - - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //virtual void setSource(const Phonon::MediaSource &); - virtual void setFileSource - (const Phonon::MediaSource&, RFile&); - virtual void setNextSource(const MediaSource &source); - virtual qint32 prefinishMark() const; - virtual void setPrefinishMark(qint32); - virtual qint32 transitionTime() const; - virtual void setTransitionTime(qint32); - - qreal volume() const; - bool setVolume(qreal volume); - - void setAudioOutput(AudioOutput* audioOutput); - Q_SIGNALS: void totalTimeChanged(); void stateChanged(Phonon::State oldState, Phonon::State newState); void finished(); - void tick(qint64 time); - - private Q_SLOTS: - /** - * Receives signal from m_tickTimer - */ - void tick(); - - private: - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - /** - * Defined private state enumeration in order to add GroundState - */ - enum PrivateState - { - LoadingState = Phonon::LoadingState, - StoppedState = Phonon::StoppedState, - PlayingState = Phonon::PlayingState, - BufferingState = Phonon::BufferingState, - PausedState = Phonon::PausedState, - ErrorState = Phonon::ErrorState, - GroundState - }; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - static Phonon::State phononState(PrivateState state); - - /** - * Changes state and emits stateChanged() - */ - void changeState(PrivateState newState); - - /** - * Using CPlayerType typedef in order to be able to easily switch between - * CMdaVideoPlayerUtility and CDrmPlayerUtility - */ - // CPlayerType* m_player; TODO - - AudioOutput* m_audioOutput; - - ErrorType m_error; - - /** - * Do not set this directly - call changeState() instead. - */ - PrivateState m_state; - - qint32 m_tickInterval; - - QTimer* m_tickTimer; - - MediaSource m_mediaSource; - MediaSource m_nextSource; - qreal m_volume; - int m_maxVolume; }; } } diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 0f00832..040a6a7 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -21,21 +21,23 @@ phonon_mmf_audio_drm { LIBS += -lmediaclientaudio.lib } -HEADERS += \ - $$PHONON_MMF_DIR/abstractplayer.h \ - $$PHONON_MMF_DIR/audiooutput.h \ - $$PHONON_MMF_DIR/audioplayer.h \ - $$PHONON_MMF_DIR/backend.h \ - $$PHONON_MMF_DIR/mediaobject.h \ - $$PHONON_MMF_DIR/utils.h \ +HEADERS += \ + $$PHONON_MMF_DIR/abstractplayer.h \ + $$PHONON_MMF_DIR/abstractmediaplayer.h \ + $$PHONON_MMF_DIR/audiooutput.h \ + $$PHONON_MMF_DIR/audioplayer.h \ + $$PHONON_MMF_DIR/backend.h \ + $$PHONON_MMF_DIR/mediaobject.h \ + $$PHONON_MMF_DIR/utils.h \ $$PHONON_MMF_DIR/videoplayer.h -SOURCES += \ - $$PHONON_MMF_DIR/audiooutput.cpp \ - $$PHONON_MMF_DIR/audioplayer.cpp \ - $$PHONON_MMF_DIR/backend.cpp \ - $$PHONON_MMF_DIR/mediaobject.cpp \ - $$PHONON_MMF_DIR/utils.cpp \ +SOURCES += \ + $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ + $$PHONON_MMF_DIR/audiooutput.cpp \ + $$PHONON_MMF_DIR/audioplayer.cpp \ + $$PHONON_MMF_DIR/backend.cpp \ + $$PHONON_MMF_DIR/mediaobject.cpp \ + $$PHONON_MMF_DIR/utils.cpp \ $$PHONON_MMF_DIR/videoplayer.cpp LIBS += -lefsrv # For file server -- cgit v0.12 From 109e04933e4e6b51a3e546f9dc3f0a062eb8470e Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 18 Aug 2009 18:30:53 +0100 Subject: Started work on VideoPlayer implementation --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 16 +++-- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 8 ++- src/3rdparty/phonon/mmf/audioplayer.cpp | 32 ++++----- src/3rdparty/phonon/mmf/audioplayer.h | 9 +-- src/3rdparty/phonon/mmf/mediaobject.cpp | 80 ++++++++++++++-------- src/3rdparty/phonon/mmf/mediaobject.h | 61 ++++------------- src/3rdparty/phonon/mmf/utils.h | 12 +++- src/3rdparty/phonon/mmf/videoplayer.cpp | 91 +++++++++++++++++++++++-- src/3rdparty/phonon/mmf/videoplayer.h | 24 ++++--- src/plugins/phonon/mmf/mmf.pro | 4 ++ 10 files changed, 214 insertions(+), 123 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index a3affef..703590b 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -178,13 +178,8 @@ void MMF::AbstractMediaPlayer::setTickInterval(qint32 interval) Phonon::ErrorType MMF::AbstractMediaPlayer::errorType() const { - TRACE_CONTEXT(AbstractMediaPlayer::errorType, EAudioApi); - TRACE_ENTRY("state %d", m_state); - const Phonon::ErrorType result = (ErrorState == m_state) ? m_error : NoError; - - TRACE_RETURN("%d", result); } QString MMF::AbstractMediaPlayer::errorString() const @@ -466,6 +461,17 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) TRACE_EXIT_0(); } +void MMF::AbstractMediaPlayer::setError(Phonon::ErrorType error) +{ + TRACE_CONTEXT(AbstractMediaPlayer::setError, EAudioInternal); + TRACE_ENTRY("state %d error %d", m_state, error); + + m_error = error; + changeState(ErrorState); + + TRACE_EXIT_0(); +} + qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) { return in.Int64() / 1000; diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 6f7ae1d..9f86ee6 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -111,6 +111,11 @@ namespace Phonon */ void changeState(PrivateState newState); + /** + * Records error and changes state to ErrorState + */ + void setError(Phonon::ErrorType error); + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); Q_SIGNALS: @@ -124,11 +129,10 @@ namespace Phonon */ void tick(); - protected: // Temporary + private: PrivateState m_state; Phonon::ErrorType m_error; - private: qint32 m_tickInterval; QScopedPointer m_tickTimer; qreal m_volume; diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 45105ee..ec29ac1 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -33,11 +33,13 @@ MMF::AudioPlayer::AudioPlayer() : m_player(NULL) TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); TRACE_ENTRY_0(); - Q_UNUSED(parent); - - // TODO: should leaves be trapped in the constructor? - m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone); - + // TODO: is this the correct way to handle errors in constructing Symbian objects? + TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); + if(KErrNone != err) + { + changeState(ErrorState); + } + TRACE_EXIT_0(); } @@ -101,7 +103,7 @@ void MMF::AudioPlayer::close() void MMF::AudioPlayer::seek(qint64 ms) { TRACE_CONTEXT(AudioPlayer::seek, EAudioApi); - TRACE_ENTRY("state %d pos %Ld", m_state, ms); + TRACE_ENTRY("state %d pos %Ld", state(), ms); m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); @@ -111,14 +113,14 @@ void MMF::AudioPlayer::seek(qint64 ms) bool MMF::AudioPlayer::hasVideo() const { TRACE_CONTEXT(AudioPlayer::hasVideo, EAudioApi); - TRACE_ENTRY("state %d", m_state); + TRACE_ENTRY("state %d", state()); TRACE_RETURN("%d", false); } qint64 MMF::AudioPlayer::currentTime() const { TRACE_CONTEXT(AudioPlayer::currentTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); + TRACE_ENTRY("state %d", state()); TTimeIntervalMicroSeconds us; const TInt err = m_player->GetPosition(us); @@ -135,7 +137,7 @@ qint64 MMF::AudioPlayer::currentTime() const qint64 MMF::AudioPlayer::totalTime() const { TRACE_CONTEXT(AudioPlayer::totalTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); + TRACE_ENTRY("state %d", state()); const qint64 result = toMilliSeconds(m_player->Duration()); @@ -156,9 +158,9 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, #endif { TRACE_CONTEXT(AudioPlayer::MapcInitComplete, EAudioInternal); - TRACE_ENTRY("state %d error %d", m_state, aError); + TRACE_ENTRY("state %d error %d", state(), aError); - __ASSERT_ALWAYS(LoadingState == m_state, Utils::panic(InvalidStatePanic)); + __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); if(KErrNone == aError) { @@ -175,8 +177,7 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, else { // TODO: set different error states according to value of aError? - m_error = NormalError; - changeState(ErrorState); + setError(NormalError); } TRACE_EXIT_0(); @@ -189,7 +190,7 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) #endif { TRACE_CONTEXT(AudioPlayer::MapcPlayComplete, EAudioInternal); - TRACE_ENTRY("state %d error %d", m_state, aError); + TRACE_ENTRY("state %d error %d", state(), aError); stopTickTimer(); @@ -201,8 +202,7 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) else { // TODO: do something with aError? - m_error = NormalError; - changeState(ErrorState); + setError(NormalError); } /* diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index f58ee0d..39e55d9 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -23,7 +23,6 @@ along with this library. If not, see . class CDrmPlayerUtility; class TTimeIntervalMicroSeconds; -class QTimer; #ifdef QT_PHONON_MMF_AUDIO_DRM #include @@ -39,18 +38,16 @@ namespace Phonon { namespace MMF { - class AudioOutput; - /** * * See * How to * play a video file using CVideoPlayerUtility */ - class AudioPlayer : public AbstractMediaPlayer - , public MPlayerObserverType // typedef + class AudioPlayer : public AbstractMediaPlayer + , public MPlayerObserverType // typedef #ifdef QT_PHONON_MMF_AUDIO_DRM - , public MAudioLoadingObserver + , public MAudioLoadingObserver #endif { Q_OBJECT diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 62dc903..5b0ac36 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -29,25 +29,14 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::MediaObject::MediaObject(QObject *parent) : QObject::QObject(parent) +MMF::MediaObject::MediaObject(QObject *parent) : QObject::QObject(parent) + , m_recognizerOpened(false) { TRACE_CONTEXT(MediaObject::MediaObject, EAudioApi); TRACE_ENTRY_0(); Q_UNUSED(parent); - TInt err = m_recognizer.Connect(); - err = m_fileServer.Connect(); - // TODO: handle this error - - // This must be called in order to be able to share file handles with - // the recognizer server (see fileMediaType function). - err = m_fileServer.ShareProtected(); - // TODO: handle this error - - m_tickTimer = new QTimer(this); - connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick())); - TRACE_EXIT_0(); } @@ -56,8 +45,6 @@ MMF::MediaObject::~MediaObject() TRACE_CONTEXT(MediaObject::~MediaObject, EAudioApi); TRACE_ENTRY_0(); - delete m_tickTimer; - m_file.Close(); m_fileServer.Close(); m_recognizer.Close(); @@ -70,6 +57,36 @@ MMF::MediaObject::~MediaObject() // Recognizer //----------------------------------------------------------------------------- +bool MMF::MediaObject::openRecognizer() +{ + if(!m_recognizerOpened) + { + TInt err = m_recognizer.Connect(); + if(KErrNone != err) + { + return false; + } + + err = m_fileServer.Connect(); + if(KErrNone != err) + { + return false; + } + + // This must be called in order to be able to share file handles with + // the recognizer server (see fileMediaType function). + err = m_fileServer.ShareProtected(); + if(KErrNone != err) + { + return false; + } + + m_recognizerOpened = true; + } + + return true; +} + const TInt KMimePrefixLength = 6; // either "audio/" or "video/" _LIT(KMimePrefixAudio, "audio/"); _LIT(KMimePrefixVideo, "video/"); @@ -96,21 +113,25 @@ MMF::MediaObject::MediaType MMF::MediaObject::fileMediaType { MediaType result = MediaTypeUnknown; - QHBufC fileNameSymbian = Utils::symbianFilename(fileName); + if(openRecognizer()) + { + QHBufC fileNameSymbian = Utils::symbianFilename(fileName); + + m_file.Close(); + TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead|EFileShareReadersOnly); - m_file.Close(); - TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead|EFileShareReadersOnly); - - if(KErrNone == err) - { - TDataRecognitionResult recognizerResult; - err = m_recognizer.RecognizeData(m_file, recognizerResult); if(KErrNone == err) { - const TPtrC mimeType = recognizerResult.iDataType.Des(); - result = mimeTypeToMediaType(mimeType); + TDataRecognitionResult recognizerResult; + err = m_recognizer.RecognizeData(m_file, recognizerResult); + if(KErrNone == err) + { + const TPtrC mimeType = recognizerResult.iDataType.Des(); + result = mimeTypeToMediaType(mimeType); + } } } + return result; } @@ -251,7 +272,7 @@ MediaSource MMF::MediaObject::source() const void MMF::MediaObject::setSource(const MediaSource &source) { - loadPlayer(source); + createPlayer(source); if(!m_player.isNull()) { //m_player->setSource(source); @@ -262,11 +283,10 @@ void MMF::MediaObject::setSource(const MediaSource &source) } } -void MMF::MediaObject::loadPlayer(const MediaSource &source) +void MMF::MediaObject::createPlayer(const MediaSource &source) { - TRACE_CONTEXT(AudioPlayer::loadPlayer, EAudioApi); - //TRACE_ENTRY("state %d source.type %d", m_state, source.type()); - // TODO: log state + TRACE_CONTEXT(AudioPlayer::createPlayer, EAudioApi); + TRACE_ENTRY("state %d source.type %d", state(), source.type()); TRACE_ENTRY("source.type %d", source.type()); // Destroy old player object diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 2eb70c3..9c39884 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -79,63 +79,28 @@ namespace Phonon Phonon::State newState); void finished(); void tick(qint64 time); - - private: - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - -// The following has been moved into the AbstractPlayer-derived classes -// This needs to be cleaned up - at present, there is no way for this class -// to enter an error state, unless it has already constructed m_player -#if 0 - /** - * Defined private state enumeration in order to add GroundState - */ - enum PrivateState - { - LoadingState = Phonon::LoadingState, - StoppedState = Phonon::StoppedState, - PlayingState = Phonon::PlayingState, - BufferingState = Phonon::BufferingState, - PausedState = Phonon::PausedState, - ErrorState = Phonon::ErrorState, - GroundState - }; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - static Phonon::State phononState(PrivateState state); - - /** - * Changes state and emits stateChanged() - */ - void changeState(PrivateState newState); - ErrorType m_error; - PrivateState m_state; -#endif + private: + void createPlayer(const MediaSource &source); + bool openRecognizer(); - RApaLsSession m_recognizer; - RFs m_fileServer; - enum MediaType { MediaTypeUnknown, MediaTypeAudio, MediaTypeVideo }; + // Audio / video media type recognition + enum MediaType { MediaTypeUnknown, MediaTypeAudio, MediaTypeVideo }; MediaType mimeTypeToMediaType(const TDesC& mimeType); MediaType fileMediaType(const QString& fileName); // TODO: urlMediaType function + + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + + private: + // Audio / video media type recognition + bool m_recognizerOpened; + RApaLsSession m_recognizer; + RFs m_fileServer; // Storing the file handle here to work around KErrInUse error // from MMF player utility OpenFileL functions RFile m_file; - - AudioOutput* m_audioOutput; - - qint32 m_tickInterval; - - QTimer* m_tickTimer; - - qreal m_volume; - int m_maxVolume; - - void loadPlayer(const MediaSource &source); QScopedPointer m_player; }; diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index 51470cd..e3e7317 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -65,7 +65,17 @@ namespace Phonon /** * Internal functions in the audio implementation */ - EAudioInternal = 0x00000002 + EAudioInternal = 0x00000002, + + /** + * Functions which map directly to the public Phonon video API + */ + EVideoApi = 0x00010000, + + /** + * Internal functions in the video implementation + */ + EVideoInternal = 0x00020000 }; /** diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 3ffa3e7..3cf468a 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -19,6 +19,8 @@ along with this library. If not, see . #include #include +#include // For CCoeEnv + #include "videoplayer.h" #include "utils.h" @@ -33,15 +35,44 @@ MMF::VideoPlayer::VideoPlayer() { TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); TRACE_ENTRY_0(); - - // TODO + + const TInt priority = 0; + const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; + CCoeEnv* coeEnv = CCoeEnv::Static(); + RWsSession& wsSession = coeEnv->WsSession(); + CWsScreenDevice& screenDevice = *(coeEnv->ScreenDevice()); + /* DUMMY */ RWindow window; + /* DUMMY */ TRect screenRect; + /* DUMMY */ TRect clipRect; + + // TODO: is this the correct way to handle errors in constructing Symbian objects? + TRAPD(err, + m_player = CVideoPlayerUtility::NewL + ( + *this, + priority, preference, + wsSession, screenDevice, + window, + screenRect, clipRect + ) + ); + + if(KErrNone != err) + { + changeState(ErrorState); + } TRACE_EXIT_0(); } MMF::VideoPlayer::~VideoPlayer() { - // TODO + TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); + TRACE_ENTRY_0(); + + delete m_player; + + TRACE_EXIT_0(); } //----------------------------------------------------------------------------- @@ -107,10 +138,60 @@ qint64 MMF::VideoPlayer::totalTime() const //----------------------------------------------------------------------------- -// Symbian multimedia client observer callbacks +// MVideoPlayerUtilityObserver callbacks //----------------------------------------------------------------------------- -// TODO +void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) +{ + TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); + + // TODO + + TRACE_EXIT_0(); +} + +void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) +{ + TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); + + // TODO + + TRACE_EXIT_0(); +} + +void MMF::VideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) +{ + TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); + + // TODO + Q_UNUSED(aFrame); + + TRACE_EXIT_0(); +} + +void MMF::VideoPlayer::MvpuoPlayComplete(TInt aError) +{ + TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) + TRACE_ENTRY("state %d error %d", state(), aError); + + // TODO + + TRACE_EXIT_0(); +} + +void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) +{ + TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); + TRACE_ENTRY("state %d", state()); + + // TODO + Q_UNUSED(aEvent); + + TRACE_EXIT_0(); +} diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index 65133c2..a10bee3 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -19,30 +19,24 @@ along with this library. If not, see . #ifndef PHONON_MMF_VIDEOPLAYER_H #define PHONON_MMF_VIDEOPLAYER_H -/* We use the extra qualification include/ to avoid picking up the include - * Phonon has. */ #include -#include "abstractmediaplayer.h" -#include +#include "abstractmediaplayer.h" -class CDrmPlayerUtility; -class TTimeIntervalMicroSeconds; -class QTimer; +class CVideoPlayerUtility; namespace Phonon { namespace MMF { - class AudioOutput; - /** * * See * How to * play a video file using CVideoPlayerUtility */ - class VideoPlayer : public AbstractMediaPlayer + class VideoPlayer : public AbstractMediaPlayer + , public MVideoPlayerUtilityObserver { Q_OBJECT public: @@ -62,11 +56,21 @@ namespace Phonon virtual qint64 currentTime() const; virtual qint64 totalTime() const; + // MVideoPlayerUtilityObserver + virtual void MvpuoOpenComplete(TInt aError); + virtual void MvpuoPrepareComplete(TInt aError); + virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); + virtual void MvpuoPlayComplete(TInt aError); + virtual void MvpuoEvent(const TMMFEvent &aEvent); + Q_SIGNALS: void totalTimeChanged(); void stateChanged(Phonon::State oldState, Phonon::State newState); void finished(); + + private: + CVideoPlayerUtility* m_player; }; } diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 040a6a7..4a4d856 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -21,6 +21,10 @@ phonon_mmf_audio_drm { LIBS += -lmediaclientaudio.lib } +LIBS += -lmediaclientvideo.lib # For CVideoPlayerUtility +LIBS += -lcone.lib # For CCoeEnv +LIBS += -lws32.lib # For RWindow + HEADERS += \ $$PHONON_MMF_DIR/abstractplayer.h \ $$PHONON_MMF_DIR/abstractmediaplayer.h \ -- cgit v0.12 From 1e986d8aa4742c7fcb298305c9f4f9d5ea227727 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 19 Aug 2009 09:20:12 +0100 Subject: Started work on VideoPlayer implementation --- src/3rdparty/phonon/mmf/videoplayer.cpp | 14 +++++++++----- src/3rdparty/phonon/mmf/videoplayer.h | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 3cf468a..6bbd010 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -18,8 +18,10 @@ along with this library. If not, see . #include #include +#include #include // For CCoeEnv +#include #include "videoplayer.h" #include "utils.h" @@ -31,19 +33,21 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoPlayer::VideoPlayer() +MMF::VideoPlayer::VideoPlayer() : m_widget(new QWidget()) { TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); TRACE_ENTRY_0(); + + CCoeControl* control = m_widget->winId(); + CCoeEnv* coeEnv = control->ControlEnv(); const TInt priority = 0; const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; - CCoeEnv* coeEnv = CCoeEnv::Static(); RWsSession& wsSession = coeEnv->WsSession(); CWsScreenDevice& screenDevice = *(coeEnv->ScreenDevice()); - /* DUMMY */ RWindow window; - /* DUMMY */ TRect screenRect; - /* DUMMY */ TRect clipRect; + RDrawableWindow& window = *(control->DrawableWindow()); + const TRect screenRect = control->Rect(); + const TRect clipRect = control->Rect(); // TODO: is this the correct way to handle errors in constructing Symbian objects? TRAPD(err, diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index a10bee3..ae44ec3 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -24,6 +24,7 @@ along with this library. If not, see . #include "abstractmediaplayer.h" class CVideoPlayerUtility; +class QSymbianControl; namespace Phonon { @@ -70,7 +71,8 @@ namespace Phonon void finished(); private: - CVideoPlayerUtility* m_player; + CVideoPlayerUtility* m_player; + QScopedPointer m_widget; }; } -- cgit v0.12 From 98d4c657803d5f1956560bd9b62e73f15c05e8fd Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 19 Aug 2009 11:13:00 +0100 Subject: Added missing return statement --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 703590b..4bfd839 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -180,6 +180,7 @@ Phonon::ErrorType MMF::AbstractMediaPlayer::errorType() const { const Phonon::ErrorType result = (ErrorState == m_state) ? m_error : NoError; + return result; } QString MMF::AbstractMediaPlayer::errorString() const -- cgit v0.12 From 991fb666cd7ba1d543156980bdc601309ec2c434 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 19 Aug 2009 13:03:16 +0100 Subject: Tidying up: removing commented-out code --- src/3rdparty/phonon/mmf/mediaobject.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index c5310a5..ffc7fb8 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -228,19 +228,6 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) TRACE_ENTRY("state %d source.type %d", state(), source.type()); TRACE_ENTRY("source.type %d", source.type()); - // Store old player object -/* - AbstractPlayer* oldPlayer = m_player.take(); - - - // Destroy old player object - if(!m_player.isNull()) - { - disconnect(m_player.data(), 0, this, 0); - m_player.reset(); - } -*/ - MediaType mediaType = MediaTypeUnknown; // Determine media type -- cgit v0.12 From f695026fce1c20fdf4ca101dd7ac8da291ecf381 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 20 Aug 2009 12:24:03 +0100 Subject: Added VolumeControlInterface to abstract details of path between MediaObject and AudioOutput --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 32 ++++---------- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 25 +++++------ src/3rdparty/phonon/mmf/abstractplayer.h | 23 ++++++---- src/3rdparty/phonon/mmf/audiooutput.cpp | 55 +++++++++++++++++------- src/3rdparty/phonon/mmf/audiooutput.h | 20 +++++---- src/3rdparty/phonon/mmf/audioplayer.cpp | 9 +++- src/3rdparty/phonon/mmf/backend.cpp | 49 ++++++++++++++------- src/3rdparty/phonon/mmf/dummyplayer.cpp | 14 +++--- src/3rdparty/phonon/mmf/dummyplayer.h | 22 ++++++---- src/3rdparty/phonon/mmf/mediaobject.cpp | 6 +-- src/3rdparty/phonon/mmf/mediaobject.h | 6 ++- src/3rdparty/phonon/mmf/volumecontrolinterface.h | 48 +++++++++++++++++++++ src/plugins/phonon/mmf/mmf.pro | 3 +- 13 files changed, 201 insertions(+), 111 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/volumecontrolinterface.h diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 4bfd839..0777276 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -30,6 +30,9 @@ using namespace Phonon::MMF; const qint32 DefaultTickInterval = 20; const int NullMaxVolume = -1; +// TODO: consolidate this with constant used in AudioOutput +const qreal InitialVolume = 0.5; + //----------------------------------------------------------------------------- // Constructor / destructor @@ -40,9 +43,8 @@ MMF::AbstractMediaPlayer::AbstractMediaPlayer() : , m_error(NoError) , m_tickInterval(DefaultTickInterval) , m_tickTimer(new QTimer(this)) - , m_volume(0.0) + , m_volume(InitialVolume) , m_mmfMaxVolume(NullMaxVolume) - , m_audioOutput(NULL) { connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); } @@ -54,7 +56,7 @@ MMF::AbstractMediaPlayer::~AbstractMediaPlayer() //----------------------------------------------------------------------------- -// Public functions (AbstractPlayer interface) +// MediaObjectInterface //----------------------------------------------------------------------------- void MMF::AbstractMediaPlayer::play() @@ -335,7 +337,7 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f //----------------------------------------------------------------------------- -// Volume +// VolumeControlInterface //----------------------------------------------------------------------------- qreal MMF::AbstractMediaPlayer::volume() const @@ -355,7 +357,7 @@ bool MMF::AbstractMediaPlayer::setVolume(qreal volume) case GroundState: case LoadingState: case ErrorState: - // Do nothing + m_volume = volume; break; case StoppedState: @@ -371,12 +373,6 @@ bool MMF::AbstractMediaPlayer::setVolume(qreal volume) { m_volume = volume; volumeChanged = true; - - if(m_audioOutput) - { - // Trigger AudioOutput signal - m_audioOutput->triggerVolumeChanged(m_volume); - } } else { @@ -398,16 +394,6 @@ bool MMF::AbstractMediaPlayer::setVolume(qreal volume) //----------------------------------------------------------------------------- -// Proxies -//----------------------------------------------------------------------------- - -void MMF::AbstractMediaPlayer::setAudioOutput(AudioOutput* audioOutput) -{ - m_audioOutput = audioOutput; -} - - -//----------------------------------------------------------------------------- // Protected functions //----------------------------------------------------------------------------- @@ -421,10 +407,10 @@ void MMF::AbstractMediaPlayer::stopTickTimer() m_tickTimer->stop(); } -void MMF::AbstractMediaPlayer::initVolume(int initialVolume, int mmfMaxVolume) +void MMF::AbstractMediaPlayer::initVolume(int mmfMaxVolume) { - m_volume = static_cast(initialVolume) / mmfMaxVolume; m_mmfMaxVolume = mmfMaxVolume; + doSetVolume(m_volume * m_mmfMaxVolume); } Phonon::State MMF::AbstractMediaPlayer::phononState() const diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 9f86ee6..2f95e73 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -32,6 +32,10 @@ namespace Phonon { class AudioOutput; + /** + * Interface via which MMF client APIs for both audio and video can be + * accessed. + */ class AbstractMediaPlayer : public AbstractPlayer { Q_OBJECT @@ -41,7 +45,7 @@ namespace Phonon ~AbstractMediaPlayer(); public: - // AbstractPlayer + // MediaObjectInterface virtual void play(); virtual void pause(); virtual void stop(); @@ -56,18 +60,12 @@ namespace Phonon virtual qint32 transitionTime() const; virtual void setTransitionTime(qint32); virtual MediaSource source() const; + virtual void setFileSource(const Phonon::MediaSource&, RFile&); virtual void setNextSource(const MediaSource &source); - - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //virtual void setSource(const Phonon::MediaSource &) = 0; - virtual void setFileSource - (const Phonon::MediaSource&, RFile&); - + + // VolumeControlInterface qreal volume() const; - bool setVolume(qreal volume); - - void setAudioOutput(AudioOutput* audioOutput); + bool setVolume(qreal volume); protected: virtual void doPlay() = 0; @@ -80,7 +78,7 @@ namespace Phonon protected: void startTickTimer(); void stopTickTimer(); - void initVolume(int initialVolume, int maxVolume); + void initVolume(int maxVolume); /** * Defined private state enumeration in order to add GroundState @@ -138,9 +136,6 @@ namespace Phonon qreal m_volume; int m_mmfMaxVolume; - // Not owned - AudioOutput* m_audioOutput; - MediaSource m_source; MediaSource m_nextSource; diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 02c0807..0f496ac 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -23,6 +23,8 @@ along with this library. If not, see . #include #include +#include "volumecontrolinterface.h" + class RFile; namespace Phonon @@ -31,13 +33,23 @@ namespace Phonon { class AudioOutput; - class AbstractPlayer : public QObject + /** + * Interface which abstracts from MediaObject the current media type. + * This may be: + * - Nothing, in which case this interface is implemented by + * DummyPlayer + * - Audio, in which case the implementation is AudioPlayer + * - Video, in which case the implementation is VideoPlayer + */ + class AbstractPlayer : public QObject + , public VolumeControlInterface { // Required although this class has no signals or slots // Without this, qobject_cast will fail Q_OBJECT public: + // Mirror of Phonon::MediaObjectInterfac virtual void play() = 0; virtual void pause() = 0; virtual void stop() = 0; @@ -51,22 +63,17 @@ namespace Phonon virtual QString errorString() const = 0; virtual Phonon::ErrorType errorType() const = 0; virtual qint64 totalTime() const = 0; - virtual Phonon::MediaSource source() const = 0; - + virtual Phonon::MediaSource source() const = 0; // This is a temporary hack to work around KErrInUse from MMF // client utility OpenFileL calls //virtual void setSource(const Phonon::MediaSource &) = 0; virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; - virtual void setNextSource(const Phonon::MediaSource &) = 0; - virtual void setTransitionTime(qint32) = 0; virtual qint32 transitionTime() const = 0; virtual qint32 prefinishMark() const = 0; virtual void setPrefinishMark(qint32) = 0; - virtual bool setVolume(qreal) = 0; - virtual qreal volume() const = 0; - virtual void setAudioOutput(AudioOutput *) = 0; + }; } } diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index d8758fd..77d9a6d 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -21,21 +21,41 @@ along with this library. If not, see . #include "mediaobject.h" #include "audiooutput.h" #include "utils.h" +#include "volumecontrolinterface.h" using namespace Phonon; using namespace Phonon::MMF; -MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : m_mediaObject(NULL) + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +static const qreal InitialVolume = 0.5; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) + , m_volume(InitialVolume) + , m_volumeControl(NULL) { - setParent(parent); + } + +//----------------------------------------------------------------------------- +// Public API +//----------------------------------------------------------------------------- + qreal MMF::AudioOutput::volume() const { TRACE_CONTEXT(AudioOutput::volume, EAudioApi); - TRACE_ENTRY("m_mediaObject 0x%08x", m_mediaObject); + TRACE_ENTRY("control 0x%08x ", m_volumeControl); - const qreal result = m_mediaObject ? m_mediaObject->volume() : 0.0; + const qreal result = m_volumeControl ? m_volumeControl->volume() : m_volume; TRACE_RETURN("%f", result); } @@ -43,22 +63,24 @@ qreal MMF::AudioOutput::volume() const void MMF::AudioOutput::setVolume(qreal volume) { TRACE_CONTEXT(AudioOutput::setVolume, EAudioApi); - TRACE_ENTRY("volume %f", volume); + TRACE_ENTRY("control 0x%08x volume %f", m_volumeControl, volume); - if(m_mediaObject and m_mediaObject->setVolume(volume)) + if(m_volumeControl) + { + if(m_volumeControl->setVolume(volume)) + { + TRACE("emit volumeChanged(%f)", volume) + emit volumeChanged(volume); + } + } + else { - TRACE("emit volumeChanged(%f)", volume) - emit volumeChanged(volume); + m_volume = volume; } TRACE_EXIT_0(); } -void MMF::AudioOutput::triggerVolumeChanged(qreal volume) -{ - emit volumeChanged(volume); -} - int MMF::AudioOutput::outputDevice() const { return 0; @@ -74,9 +96,10 @@ bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) return true; } -void MMF::AudioOutput::setMediaObject(MediaObject *mo) +void MMF::AudioOutput::setVolumeControl(VolumeControlInterface *volumeControl) { - Q_ASSERT(!m_mediaObject); - m_mediaObject = mo; + Q_ASSERT(!m_volumeControl); + m_volumeControl = volumeControl; + m_volumeControl->setVolume(m_volume); } diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 5e4fef2..b8290c7 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -26,16 +26,13 @@ namespace Phonon namespace MMF { class Backend; - class MediaObject; + class VolumeControlInterface; /** * @short AudioOutputInterface implementation for MMF. * - * Implements the AudioOutputInterface for Symbian/S60's MMF - * framework. - * - * This class has a very small role, we simply access CDrmPlayerUtility - * in MediaObject::m_player and forward everything there. + * Forwards volume commands to the VolumeControlInterface instance, + * provided by the backend. * * \section volume Volume * @@ -69,20 +66,25 @@ namespace Phonon */ virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); - void setMediaObject(MediaObject *mo); + void setVolumeControl(VolumeControlInterface *volumeControl); /** * Called by MediaObject to pass initial volume when clip has been * successfully opened */ - void triggerVolumeChanged(qreal volume); + //void triggerVolumeChanged(qreal volume); Q_SIGNALS: void volumeChanged(qreal volume); void audioDeviceFailed(); private: - MediaObject * m_mediaObject; + /** + * This value is used when m_volumeControl is NULL. + */ + qreal m_volume; + + VolumeControlInterface * m_volumeControl; }; } } diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index ec29ac1..c0a0767 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -164,15 +164,22 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, if(KErrNone == aError) { +// TODO: CLEANUP +/* TInt volume = 0; aError = m_player->GetVolume(volume); if(KErrNone == aError) { - initVolume(volume, m_player->MaxVolume()); +*/ + initVolume(m_player->MaxVolume()); emit totalTimeChanged(); changeState(StoppedState); + +// TODO: CLEANUP +/* } +*/ } else { diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 8d7903e..7a0f3f5 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -26,10 +26,10 @@ along with this library. If not, see . using namespace Phonon; using namespace Phonon::MMF; -Backend::Backend(QObject *parent) +Backend::Backend(QObject *parent) : QObject(parent) { + // TODO: replace this with logging macros as per rest of the module qDebug() << Q_FUNC_INFO; - setParent(parent); setProperty("identifier", QLatin1String("phonon_mmf")); setProperty("backendName", QLatin1String("MMF")); @@ -40,12 +40,20 @@ Backend::Backend(QObject *parent) QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &) { + // TODO: add trace + + QObject* result = NULL; + switch(c) { case AudioOutputClass: - return new AudioOutput(this, parent); + result = new AudioOutput(this, parent); + break; + case MediaObjectClass: - return new MediaObject(parent); + result = new MediaObject(parent); + break; + case VolumeFaderEffectClass: /* Fallthrough. */ case VisualizationClass: @@ -55,12 +63,14 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const case EffectClass: /* Fallthrough. */ case VideoWidgetClass: - return 0; + result = NULL; + break; + + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "This line should never be reached."); } - Q_ASSERT_X(false, Q_FUNC_INFO, - "This line should never be reached."); - return 0; + return result; } QList Backend::objectDescriptionIndexes(ObjectDescriptionType) const @@ -80,20 +90,25 @@ bool Backend::startConnectionChange(QSet) bool Backend::connectNodes(QObject *source, QObject *target) { - MediaObject *const mo = qobject_cast(source); - AudioOutput *const ao = qobject_cast(target); + // TODO: add trace - if(!mo || !ao) - return false; + MediaObject *const mediaObject = qobject_cast(source); + AudioOutput *const audioOutput = qobject_cast(target); - ao->setMediaObject(mo); - mo->setAudioOutput(ao); - - return true; + if(mediaObject and audioOutput) + { + audioOutput->setVolumeControl(mediaObject); + return true; + } + + // Node types not recognised + return false; } bool Backend::disconnectNodes(QObject *, QObject *) { + // TODO: add trace + return true; } @@ -104,6 +119,8 @@ bool Backend::endConnectionChange(QSet) QStringList Backend::availableMimeTypes() const { + // TODO: query MMF for available MIME types + return QStringList(); } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index ecd6815..26257c0 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -21,6 +21,10 @@ along with this library. If not, see . using namespace Phonon; using namespace Phonon::MMF; +//----------------------------------------------------------------------------- +// Public functions (AbstractPlayer interface) +//----------------------------------------------------------------------------- + void MMF::DummyPlayer::play() { } @@ -86,9 +90,11 @@ MediaSource MMF::DummyPlayer::source() const return MediaSource(); } +/* void MMF::DummyPlayer::setSource(const MediaSource &) { } +*/ void MMF::DummyPlayer::setNextSource(const MediaSource &) { @@ -116,10 +122,6 @@ void MMF::DummyPlayer::setFileSource(const Phonon::MediaSource &, RFile &) { } -//----------------------------------------------------------------------------- -// Volume -//----------------------------------------------------------------------------- - qreal MMF::DummyPlayer::volume() const { return 0; @@ -130,8 +132,6 @@ bool MMF::DummyPlayer::setVolume(qreal) return true; } -void MMF::DummyPlayer::setAudioOutput(AudioOutput *) -{ -} + diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 263a013..e5c1365 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -28,13 +28,19 @@ namespace Phonon class AudioOutput; /** - * @short In order to make the implementation of MediaObject simpler, - * we have this class. + * @short Stub implementation of AbstractPlayer. + * + * The functions of this class are: + * - Allow MediaObject to call a subset of the MediaObjectInterface + * API, before SetSource has been called. + * - Cache any parameters which are set in this state (e.g. + * prefinish mark), so that they can be copied into the 'real' + * AbstractPlayer implementation once a source has been loaded. */ class DummyPlayer : public AbstractPlayer { public: - // AbstractPlayer + // MediaObjectInterface virtual void play(); virtual void pause(); virtual void stop(); @@ -49,18 +55,18 @@ namespace Phonon virtual Phonon::ErrorType errorType() const; virtual qint64 totalTime() const; virtual MediaSource source() const; - virtual void setSource(const MediaSource &); + // virtual void setSource(const MediaSource &); + virtual void setFileSource(const Phonon::MediaSource&, RFile&); virtual void setNextSource(const MediaSource &source); virtual qint32 prefinishMark() const; virtual void setPrefinishMark(qint32); virtual qint32 transitionTime() const; virtual void setTransitionTime(qint32); + + // VolumeControlInterface virtual qreal volume() const; virtual bool setVolume(qreal volume); - - virtual void setAudioOutput(AudioOutput* audioOutput); - virtual void setFileSource(const Phonon::MediaSource&, RFile&); - + Q_SIGNALS: void totalTimeChanged(); void stateChanged(Phonon::State oldState, diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index ffc7fb8..6b32eb3 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -319,7 +319,7 @@ void MMF::MediaObject::setTransitionTime(qint32 time) } //----------------------------------------------------------------------------- -// Volume +// VolumeControlInterface //----------------------------------------------------------------------------- qreal MMF::MediaObject::volume() const @@ -332,8 +332,4 @@ bool MMF::MediaObject::setVolume(qreal volume) return m_player->setVolume(volume); } -void MMF::MediaObject::setAudioOutput(AudioOutput* audioOutput) -{ - m_player->setAudioOutput(audioOutput); -} diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 9c39884..97ea115 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -27,6 +27,8 @@ along with this library. If not, see . // For recognizer #include +#include "volumecontrolinterface.h" + namespace Phonon { namespace MMF @@ -38,6 +40,7 @@ namespace Phonon */ class MediaObject : public QObject , public MediaObjectInterface + , public VolumeControlInterface { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface) @@ -68,11 +71,10 @@ namespace Phonon virtual qint32 transitionTime() const; virtual void setTransitionTime(qint32); + // VolumeControlInterface qreal volume() const; bool setVolume(qreal volume); - void setAudioOutput(AudioOutput* audioOutput); - Q_SIGNALS: void totalTimeChanged(); void stateChanged(Phonon::State oldState, diff --git a/src/3rdparty/phonon/mmf/volumecontrolinterface.h b/src/3rdparty/phonon/mmf/volumecontrolinterface.h new file mode 100644 index 0000000..7965dd4 --- /dev/null +++ b/src/3rdparty/phonon/mmf/volumecontrolinterface.h @@ -0,0 +1,48 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_VOLUMECONTROLINTERFACE_H +#define PHONON_MMF_VOLUMECONTROLINTERFACE_H + +#include + +namespace Phonon +{ + namespace MMF + { + /** + * Interface used by AudioOutput to pass volume control commands + * back along the audio path to the MediaObject. + */ + class VolumeControlInterface + { + public: + virtual qreal volume() const = 0; + + /** + * Returns true if the volume of the underlying audio stack is + * changed as a result of this call. The return value is used + * by the AudioDevice to determine whether to emit a + * volumeChanged signal. + */ + virtual bool setVolume(qreal volume) = 0; + }; + } +} + +#endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index bb2dffd..a196930 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -30,7 +30,8 @@ HEADERS += \ $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/utils.h \ - $$PHONON_MMF_DIR/videoplayer.h + $$PHONON_MMF_DIR/videoplayer.h \ + $$PHONON_MMF_DIR/volumecontrolinterface.h SOURCES += \ $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ -- cgit v0.12 From 008967cde3f2ea210efd77727d8098c24e5a0127 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 20 Aug 2009 13:45:31 +0100 Subject: Implemented parameter copying between AbstractPlayer instances --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 142 +++++++----------------- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 18 +-- src/3rdparty/phonon/mmf/abstractplayer.cpp | 107 ++++++++++++++++++ src/3rdparty/phonon/mmf/abstractplayer.h | 39 +++++-- src/3rdparty/phonon/mmf/audiooutput.cpp | 9 +- src/3rdparty/phonon/mmf/audiooutput.h | 3 +- src/3rdparty/phonon/mmf/audioplayer.cpp | 52 ++++----- src/3rdparty/phonon/mmf/audioplayer.h | 12 +- src/3rdparty/phonon/mmf/defs.h | 34 ++++++ src/3rdparty/phonon/mmf/dummyplayer.cpp | 60 +++++----- src/3rdparty/phonon/mmf/dummyplayer.h | 23 ++-- src/3rdparty/phonon/mmf/mediaobject.cpp | 39 ++++++- src/3rdparty/phonon/mmf/mediaobject.h | 1 + src/3rdparty/phonon/mmf/videoplayer.cpp | 54 +++++---- src/3rdparty/phonon/mmf/videoplayer.h | 8 +- src/plugins/phonon/mmf/mmf.pro | 2 + 16 files changed, 366 insertions(+), 237 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/abstractplayer.cpp create mode 100644 src/3rdparty/phonon/mmf/defs.h diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 0777276..a86f634 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -17,7 +17,6 @@ along with this library. If not, see . */ #include "abstractmediaplayer.h" -#include "audiooutput.h" #include "utils.h" using namespace Phonon; @@ -27,12 +26,8 @@ using namespace Phonon::MMF; // Constants //----------------------------------------------------------------------------- -const qint32 DefaultTickInterval = 20; const int NullMaxVolume = -1; -// TODO: consolidate this with constant used in AudioOutput -const qreal InitialVolume = 0.5; - //----------------------------------------------------------------------------- // Constructor / destructor @@ -41,9 +36,17 @@ const qreal InitialVolume = 0.5; MMF::AbstractMediaPlayer::AbstractMediaPlayer() : m_state(GroundState) , m_error(NoError) - , m_tickInterval(DefaultTickInterval) , m_tickTimer(new QTimer(this)) - , m_volume(InitialVolume) + , m_mmfMaxVolume(NullMaxVolume) +{ + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); +} + +MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) : + AbstractPlayer(player) + , m_state(GroundState) + , m_error(NoError) + , m_tickTimer(new QTimer(this)) , m_mmfMaxVolume(NullMaxVolume) { connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); @@ -159,20 +162,11 @@ bool MMF::AbstractMediaPlayer::isSeekable() const return true; } -qint32 MMF::AbstractMediaPlayer::tickInterval() const -{ - TRACE_CONTEXT(AbstractMediaPlayer::tickInterval, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_RETURN("%d", m_tickInterval); -} - -void MMF::AbstractMediaPlayer::setTickInterval(qint32 interval) +void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) { - TRACE_CONTEXT(AbstractMediaPlayer::setTickInterval, EAudioApi); - TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval); + TRACE_CONTEXT(AbstractMediaPlayer::doSetTickInterval, EAudioApi); + TRACE_ENTRY("state %d m_interval %d interval %d", m_state, tickInterval(), interval); - m_tickInterval = interval; m_tickTimer->setInterval(interval); TRACE_EXIT_0(); @@ -206,66 +200,11 @@ Phonon::State MMF::AbstractMediaPlayer::state() const TRACE_RETURN("%d", result); } -qint32 MMF::AbstractMediaPlayer::prefinishMark() const -{ - TRACE_CONTEXT(AbstractMediaPlayer::prefinishMark, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement prefinish mark - const qint32 result = 0; - TRACE_RETURN("%d", result); -} - -void MMF::AbstractMediaPlayer::setPrefinishMark(qint32 mark) -{ - TRACE_CONTEXT(AbstractMediaPlayer::setPrefinishMark, EAudioApi); - TRACE_ENTRY("state %d mark %d", m_state, mark); - Q_UNUSED(mark); // to silence warnings in release builds - - // TODO: implement prefinish mark - - TRACE_EXIT_0(); -} - -qint32 MMF::AbstractMediaPlayer::transitionTime() const -{ - TRACE_CONTEXT(AbstractMediaPlayer::transitionTime, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: implement transition time - const qint32 result = 0; - TRACE_RETURN("%d", result); -} - -void MMF::AbstractMediaPlayer::setTransitionTime(qint32 time) -{ - TRACE_CONTEXT(AbstractMediaPlayer::setTransitionTime, EAudioApi); - TRACE_ENTRY("state %d time %d", m_state, time); - Q_UNUSED(time); // to silence warnings in release builds - - // TODO: implement transition time - - TRACE_EXIT_0(); -} - MediaSource MMF::AbstractMediaPlayer::source() const { return m_source; } -void MMF::AbstractMediaPlayer::setNextSource(const MediaSource &source) -{ - TRACE_CONTEXT(AbstractMediaPlayer::setNextSource, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - // TODO: handle 'next source' - - m_nextSource = source; - Q_UNUSED(source); - - TRACE_EXIT_0(); -} - void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& file) { TRACE_CONTEXT(AudioPlayer::setSource, EAudioApi); @@ -335,29 +274,37 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f TRACE_EXIT_0(); } +void MMF::AbstractMediaPlayer::setNextSource(const MediaSource &source) +{ + TRACE_CONTEXT(AbstractMediaPlayer::setNextSource, EAudioApi); + TRACE_ENTRY("state %d", m_state); + + // TODO: handle 'next source' + + m_nextSource = source; + Q_UNUSED(source); + + TRACE_EXIT_0(); +} + //----------------------------------------------------------------------------- // VolumeControlInterface //----------------------------------------------------------------------------- -qreal MMF::AbstractMediaPlayer::volume() const +bool MMF::AbstractMediaPlayer::doSetVolume(qreal volume) { - return m_volume; -} - -bool MMF::AbstractMediaPlayer::setVolume(qreal volume) -{ - TRACE_CONTEXT(AbstractMediaPlayer::setVolume, EAudioInternal); + TRACE_CONTEXT(AbstractMediaPlayer::doSetVolume, EAudioInternal); TRACE_ENTRY("state %d", m_state); - bool volumeChanged = false; - + bool result = true; + switch(m_state) { case GroundState: case LoadingState: case ErrorState: - m_volume = volume; + // Do nothing break; case StoppedState: @@ -365,20 +312,13 @@ bool MMF::AbstractMediaPlayer::setVolume(qreal volume) case PlayingState: case BufferingState: { - if(volume != m_volume) - { - const int err = doSetVolume(volume * m_mmfMaxVolume); + const int err = doSetMmfVolume(volume * m_mmfMaxVolume); - if(KErrNone == err) - { - m_volume = volume; - volumeChanged = true; - } - else - { - m_error = NormalError; - changeState(ErrorState); - } + if(KErrNone != err) + { + m_error = NormalError; + changeState(ErrorState); + result = false; } break; } @@ -388,8 +328,8 @@ bool MMF::AbstractMediaPlayer::setVolume(qreal volume) default: TRACE_PANIC(InvalidStatePanic); } - - TRACE_RETURN("%d", volumeChanged); + + return result; } @@ -399,7 +339,7 @@ bool MMF::AbstractMediaPlayer::setVolume(qreal volume) void MMF::AbstractMediaPlayer::startTickTimer() { - m_tickTimer->start(m_tickInterval); + m_tickTimer->start(tickInterval()); } void MMF::AbstractMediaPlayer::stopTickTimer() @@ -410,7 +350,7 @@ void MMF::AbstractMediaPlayer::stopTickTimer() void MMF::AbstractMediaPlayer::initVolume(int mmfMaxVolume) { m_mmfMaxVolume = mmfMaxVolume; - doSetVolume(m_volume * m_mmfMaxVolume); + doSetVolume(volume() * m_mmfMaxVolume); } Phonon::State MMF::AbstractMediaPlayer::phononState() const diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 2f95e73..0c233c9 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -42,6 +42,7 @@ namespace Phonon protected: AbstractMediaPlayer(); + explicit AbstractMediaPlayer(const AbstractPlayer& player); ~AbstractMediaPlayer(); public: @@ -50,28 +51,23 @@ namespace Phonon virtual void pause(); virtual void stop(); virtual bool isSeekable() const; - virtual qint32 tickInterval() const; - virtual void setTickInterval(qint32 interval); virtual Phonon::ErrorType errorType() const; virtual QString errorString() const; virtual Phonon::State state() const; - virtual qint32 prefinishMark() const; - virtual void setPrefinishMark(qint32); - virtual qint32 transitionTime() const; - virtual void setTransitionTime(qint32); virtual MediaSource source() const; virtual void setFileSource(const Phonon::MediaSource&, RFile&); virtual void setNextSource(const MediaSource &source); - // VolumeControlInterface - qreal volume() const; - bool setVolume(qreal volume); + protected: + // AbstractPlayer + virtual void doSetTickInterval(qint32 interval); + virtual bool doSetVolume(qreal volume); protected: virtual void doPlay() = 0; virtual void doPause() = 0; virtual void doStop() = 0; - virtual int doSetVolume(int mmfVolume) = 0; + virtual int doSetMmfVolume(int mmfVolume) = 0; virtual int openFile(RFile& file) = 0; virtual void close() = 0; @@ -131,9 +127,7 @@ namespace Phonon PrivateState m_state; Phonon::ErrorType m_error; - qint32 m_tickInterval; QScopedPointer m_tickTimer; - qreal m_volume; int m_mmfMaxVolume; MediaSource m_source; diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp new file mode 100644 index 0000000..7786d8b --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -0,0 +1,107 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "abstractplayer.h" +#include "defs.h" + +using namespace Phonon; +using namespace Phonon::MMF; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AbstractPlayer::AbstractPlayer() : + m_tickInterval(DefaultTickInterval) + , m_volume(InitialVolume) + , m_transitionTime(0) + , m_prefinishMark(0) +{ + +} + +MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) : + m_tickInterval(player.tickInterval()) + , m_volume(player.volume()) + , m_transitionTime(player.transitionTime()) + , m_prefinishMark(player.prefinishMark()) +{ + +} + +//----------------------------------------------------------------------------- +// MediaObjectInterface +//----------------------------------------------------------------------------- + +qint32 MMF::AbstractPlayer::tickInterval() const +{ + return m_tickInterval; +} + +void MMF::AbstractPlayer::setTickInterval(qint32 interval) +{ + m_tickInterval = interval; + doSetTickInterval(interval); +} + +qint32 MMF::AbstractPlayer::prefinishMark() const +{ + return m_prefinishMark; +} + +void MMF::AbstractPlayer::setPrefinishMark(qint32 mark) +{ + m_prefinishMark = mark; +} + +qint32 MMF::AbstractPlayer::transitionTime() const +{ + return m_transitionTime; +} + +void MMF::AbstractPlayer::setTransitionTime(qint32 time) +{ + m_transitionTime = time; +} + + +//----------------------------------------------------------------------------- +// VolumeControlInterface +//----------------------------------------------------------------------------- + +qreal MMF::AbstractPlayer::volume() const +{ + return m_volume; +} + +bool MMF::AbstractPlayer::setVolume(qreal volume) +{ + bool result = false; + if(volume != m_volume) + { + result = doSetVolume(volume); + if(result) + { + m_volume = volume; + } + } + return result; +} + + diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 0f496ac..546d929 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -34,9 +34,11 @@ namespace Phonon class AudioOutput; /** - * Interface which abstracts from MediaObject the current media type. + * @short Interface which abstracts from MediaObject the current + * media type + * * This may be: - * - Nothing, in which case this interface is implemented by + * - Nothing, in which case this interface is implemented by * DummyPlayer * - Audio, in which case the implementation is AudioPlayer * - Video, in which case the implementation is VideoPlayer @@ -49,13 +51,22 @@ namespace Phonon Q_OBJECT public: - // Mirror of Phonon::MediaObjectInterfac + AbstractPlayer(); + explicit AbstractPlayer(const AbstractPlayer& player); + + // MediaObjectInterface (implemented) + qint32 tickInterval() const; + void setTickInterval(qint32); + void setTransitionTime(qint32); + qint32 transitionTime() const; + void setPrefinishMark(qint32); + qint32 prefinishMark() const; + + // MediaObjectInterface (abstract) virtual void play() = 0; virtual void pause() = 0; virtual void stop() = 0; virtual void seek(qint64 milliseconds) = 0; - virtual qint32 tickInterval() const = 0; - virtual void setTickInterval(qint32) = 0; virtual bool hasVideo() const = 0; virtual bool isSeekable() const = 0; virtual qint64 currentTime() const = 0; @@ -69,10 +80,20 @@ namespace Phonon //virtual void setSource(const Phonon::MediaSource &) = 0; virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; virtual void setNextSource(const Phonon::MediaSource &) = 0; - virtual void setTransitionTime(qint32) = 0; - virtual qint32 transitionTime() const = 0; - virtual qint32 prefinishMark() const = 0; - virtual void setPrefinishMark(qint32) = 0; + + // VolumeControlInterface + qreal volume() const; + bool setVolume(qreal volume); + + private: + virtual void doSetTickInterval(qint32 interval) = 0; + virtual bool doSetVolume(qreal volume) = 0; + + private: + qint32 m_tickInterval; + qreal m_volume; + qint32 m_transitionTime; + qint32 m_prefinishMark; }; } diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 77d9a6d..2e5cbc6 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -18,8 +18,8 @@ along with this library. If not, see . #include -#include "mediaobject.h" #include "audiooutput.h" +#include "defs.h" #include "utils.h" #include "volumecontrolinterface.h" @@ -28,13 +28,6 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -static const qreal InitialVolume = 0.5; - - -//----------------------------------------------------------------------------- // Constructor / destructor //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index b8290c7..016ec8e 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -32,7 +32,8 @@ namespace Phonon * @short AudioOutputInterface implementation for MMF. * * Forwards volume commands to the VolumeControlInterface instance, - * provided by the backend. + * which is provided by the backend when MediaNode objects are + * connected. * * \section volume Volume * diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index c0a0767..f7ab0df 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -28,19 +28,31 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioPlayer::AudioPlayer() : m_player(NULL) +MMF::AudioPlayer::AudioPlayer() : m_player(NULL) { - TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); - TRACE_ENTRY_0(); + construct(); +} - // TODO: is this the correct way to handle errors in constructing Symbian objects? - TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); - if(KErrNone != err) - { +MMF::AudioPlayer::AudioPlayer(const AbstractPlayer& player) + : AbstractMediaPlayer(player) + , m_player(NULL) +{ + construct(); +} + +void MMF::AudioPlayer::construct() +{ + TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); + TRACE_ENTRY_0(); + + // TODO: is this the correct way to handle errors in constructing Symbian objects? + TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); + if(KErrNone != err) + { changeState(ErrorState); - } - - TRACE_EXIT_0(); + } + + TRACE_EXIT_0(); } MMF::AudioPlayer::~AudioPlayer() @@ -72,7 +84,7 @@ void MMF::AudioPlayer::doStop() m_player->Stop(); } -int MMF::AudioPlayer::doSetVolume(int mmfVolume) +int MMF::AudioPlayer::doSetMmfVolume(int mmfVolume) { return m_player->SetVolume(mmfVolume); } @@ -164,22 +176,10 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, if(KErrNone == aError) { -// TODO: CLEANUP -/* - TInt volume = 0; - aError = m_player->GetVolume(volume); - if(KErrNone == aError) - { -*/ - initVolume(m_player->MaxVolume()); + initVolume(m_player->MaxVolume()); - emit totalTimeChanged(); - changeState(StoppedState); - -// TODO: CLEANUP -/* - } -*/ + emit totalTimeChanged(); + changeState(StoppedState); } else { diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 39e55d9..b73ea44 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -39,10 +39,7 @@ namespace Phonon namespace MMF { /** - * - * See - * How to - * play a video file using CVideoPlayerUtility + * @short Wrapper over MMF audio client utility */ class AudioPlayer : public AbstractMediaPlayer , public MPlayerObserverType // typedef @@ -54,16 +51,18 @@ namespace Phonon public: AudioPlayer(); + explicit AudioPlayer(const AbstractPlayer& player); virtual ~AudioPlayer(); // AbstractMediaPlayer virtual void doPlay(); virtual void doPause(); virtual void doStop(); - virtual int doSetVolume(int mmfVolume); + virtual int doSetMmfVolume(int mmfVolume); virtual int openFile(RFile& file); virtual void close(); + // MediaObjectInterface virtual void seek(qint64 milliseconds); virtual bool hasVideo() const; virtual qint64 currentTime() const; @@ -88,6 +87,9 @@ namespace Phonon Q_SIGNALS: void totalTimeChanged(); void finished(); + + private: + void construct(); private: /** diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h new file mode 100644 index 0000000..d31cabb --- /dev/null +++ b/src/3rdparty/phonon/mmf/defs.h @@ -0,0 +1,34 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_DEFS_H +#define PHONON_MMF_DEFS_H + +#include + +namespace Phonon +{ + namespace MMF + { + static const qint32 DefaultTickInterval = 20; + static const qreal InitialVolume = 0.5; + + } +} + +#endif diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index 26257c0..737af78 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -22,32 +22,43 @@ using namespace Phonon; using namespace Phonon::MMF; //----------------------------------------------------------------------------- -// Public functions (AbstractPlayer interface) +// Constructor / destructor //----------------------------------------------------------------------------- -void MMF::DummyPlayer::play() +MMF::DummyPlayer::DummyPlayer() { + } -void MMF::DummyPlayer::pause() +MMF::DummyPlayer::DummyPlayer(const AbstractPlayer& player) + : AbstractPlayer(player) { + } -void MMF::DummyPlayer::stop() + +//----------------------------------------------------------------------------- +// MediaObjectInterface +//----------------------------------------------------------------------------- + +void MMF::DummyPlayer::play() { + } -void MMF::DummyPlayer::seek(qint64) +void MMF::DummyPlayer::pause() { + } -qint32 MMF::DummyPlayer::tickInterval() const +void MMF::DummyPlayer::stop() { - return 0; + } -void MMF::DummyPlayer::setTickInterval(qint32) +void MMF::DummyPlayer::seek(qint64) { + } bool MMF::DummyPlayer::hasVideo() const @@ -90,46 +101,29 @@ MediaSource MMF::DummyPlayer::source() const return MediaSource(); } -/* -void MMF::DummyPlayer::setSource(const MediaSource &) +void MMF::DummyPlayer::setFileSource(const Phonon::MediaSource &, RFile &) { -} -*/ -void MMF::DummyPlayer::setNextSource(const MediaSource &) -{ } -qint32 MMF::DummyPlayer::prefinishMark() const +void MMF::DummyPlayer::setNextSource(const MediaSource &) { - return 0; -} -void MMF::DummyPlayer::setPrefinishMark(qint32) -{ } -qint32 MMF::DummyPlayer::transitionTime() const -{ - return 0; -} -void MMF::DummyPlayer::setTransitionTime(qint32) -{ -} +//----------------------------------------------------------------------------- +// AbstractPlayer +//----------------------------------------------------------------------------- -void MMF::DummyPlayer::setFileSource(const Phonon::MediaSource &, RFile &) +void MMF::DummyPlayer::doSetTickInterval(qint32) { -} -qreal MMF::DummyPlayer::volume() const -{ - return 0; } -bool MMF::DummyPlayer::setVolume(qreal) +bool MMF::DummyPlayer::doSetVolume(qreal) { - return true; + return true; } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index e5c1365..6a2ad73 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -40,13 +40,14 @@ namespace Phonon class DummyPlayer : public AbstractPlayer { public: + DummyPlayer(); + DummyPlayer(const AbstractPlayer& player); + // MediaObjectInterface virtual void play(); virtual void pause(); virtual void stop(); virtual void seek(qint64 milliseconds); - virtual qint32 tickInterval() const; - virtual void setTickInterval(qint32 interval); virtual bool hasVideo() const; virtual bool isSeekable() const; virtual qint64 currentTime() const; @@ -55,24 +56,14 @@ namespace Phonon virtual Phonon::ErrorType errorType() const; virtual qint64 totalTime() const; virtual MediaSource source() const; - // virtual void setSource(const MediaSource &); + // virtual void setSource(const MediaSource &); virtual void setFileSource(const Phonon::MediaSource&, RFile&); virtual void setNextSource(const MediaSource &source); - virtual qint32 prefinishMark() const; - virtual void setPrefinishMark(qint32); - virtual qint32 transitionTime() const; - virtual void setTransitionTime(qint32); - // VolumeControlInterface - virtual qreal volume() const; - virtual bool setVolume(qreal volume); + // AbstractPlayer + virtual void doSetTickInterval(qint32 interval); + virtual bool doSetVolume(qreal volume); - Q_SIGNALS: - void totalTimeChanged(); - void stateChanged(Phonon::State oldState, - Phonon::State newState); - void finished(); - void tick(qint64 time); }; } } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 6b32eb3..0336109 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -230,6 +230,8 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) MediaType mediaType = MediaTypeUnknown; + AbstractPlayer* oldPlayer = m_player.data(); + // Determine media type switch(source.type()) { @@ -265,13 +267,26 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) break; } + AbstractPlayer* newPlayer = NULL; + + // Construct newPlayer using oldPlayer (if not NULL) in order to copy + // parameters (volume, prefinishMark, transitionTime) which may have + // been set on oldPlayer. + switch(mediaType) { case MediaTypeUnknown: TRACE_0("Media type could not be determined"); - m_player.reset(new DummyPlayer()); + if(oldPlayer) + { + newPlayer = new DummyPlayer(*oldPlayer); + } + else + { + newPlayer = new DummyPlayer(); + } /* - * TODO: handle error + * TODO: handle error? * m_error = NormalError; changeState(ErrorState); @@ -279,13 +294,29 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) break; case MediaTypeAudio: - m_player.reset(new AudioPlayer()); + if(oldPlayer) + { + newPlayer = new AudioPlayer(*oldPlayer); + } + else + { + newPlayer = new AudioPlayer(); + } break; case MediaTypeVideo: - m_player.reset(new VideoPlayer()); + if(oldPlayer) + { + newPlayer = new VideoPlayer(*oldPlayer); + } + else + { + newPlayer = new VideoPlayer(); + } break; } + + m_player.reset(newPlayer); connect(m_player.data(), SIGNAL(totalTimeChanged()), SIGNAL(totalTimeChanged())); connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 97ea115..a6d932d 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -37,6 +37,7 @@ namespace Phonon class AudioOutput; /** + * @short Facade class which wraps MMF client utility instance */ class MediaObject : public QObject , public MediaObjectInterface diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 6bbd010..b0c786b 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -35,23 +35,35 @@ using namespace Phonon::MMF; MMF::VideoPlayer::VideoPlayer() : m_widget(new QWidget()) { - TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); - TRACE_ENTRY_0(); - - CCoeControl* control = m_widget->winId(); - CCoeEnv* coeEnv = control->ControlEnv(); - - const TInt priority = 0; - const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; - RWsSession& wsSession = coeEnv->WsSession(); - CWsScreenDevice& screenDevice = *(coeEnv->ScreenDevice()); - RDrawableWindow& window = *(control->DrawableWindow()); - const TRect screenRect = control->Rect(); - const TRect clipRect = control->Rect(); - - // TODO: is this the correct way to handle errors in constructing Symbian objects? - TRAPD(err, - m_player = CVideoPlayerUtility::NewL + construct(); +} + +MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) + : AbstractMediaPlayer(player) + , m_widget(new QWidget()) +{ + construct(); +} + +void MMF::VideoPlayer::construct() +{ + TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); + TRACE_ENTRY_0(); + + CCoeControl* control = m_widget->winId(); + CCoeEnv* coeEnv = control->ControlEnv(); + + const TInt priority = 0; + const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; + RWsSession& wsSession = coeEnv->WsSession(); + CWsScreenDevice& screenDevice = *(coeEnv->ScreenDevice()); + RDrawableWindow& window = *(control->DrawableWindow()); + const TRect screenRect = control->Rect(); + const TRect clipRect = control->Rect(); + + // TODO: is this the correct way to handle errors in constructing Symbian objects? + TRAPD(err, + m_player = CVideoPlayerUtility::NewL ( *this, priority, preference, @@ -60,13 +72,13 @@ MMF::VideoPlayer::VideoPlayer() : m_widget(new QWidget()) screenRect, clipRect ) ); - + if(KErrNone != err) { changeState(ErrorState); } - - TRACE_EXIT_0(); + + TRACE_EXIT_0(); } MMF::VideoPlayer::~VideoPlayer() @@ -98,7 +110,7 @@ void MMF::VideoPlayer::doStop() // TODO } -int MMF::VideoPlayer::doSetVolume(int mmfVolume) +int MMF::VideoPlayer::doSetMmfVolume(int mmfVolume) { // TODO Q_UNUSED(mmfVolume); diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index ae44ec3..9bf2622 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -31,6 +31,7 @@ namespace Phonon namespace MMF { /** + * @short Wrapper over MMF video client utility * * See * How to @@ -42,16 +43,18 @@ namespace Phonon Q_OBJECT public: VideoPlayer(); + explicit VideoPlayer(const AbstractPlayer& player); virtual ~VideoPlayer(); // AbstractPlayer virtual void doPlay(); virtual void doPause(); virtual void doStop(); - virtual int doSetVolume(int mmfVolume); + virtual int doSetMmfVolume(int mmfVolume); virtual int openFile(RFile& file); virtual void close(); + // MediaObjectInterface virtual void seek(qint64 milliseconds); virtual bool hasVideo() const; virtual qint64 currentTime() const; @@ -71,6 +74,9 @@ namespace Phonon void finished(); private: + void construct(); + + private: CVideoPlayerUtility* m_player; QScopedPointer m_widget; diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index a196930..99aa4a4 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -27,6 +27,7 @@ HEADERS += \ $$PHONON_MMF_DIR/audiooutput.h \ $$PHONON_MMF_DIR/audioplayer.h \ $$PHONON_MMF_DIR/backend.h \ + $$PHONON_MMF_DIR/defs.h \ $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/utils.h \ @@ -34,6 +35,7 @@ HEADERS += \ $$PHONON_MMF_DIR/volumecontrolinterface.h SOURCES += \ + $$PHONON_MMF_DIR/abstractplayer.cpp \ $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ $$PHONON_MMF_DIR/audiooutput.cpp \ $$PHONON_MMF_DIR/audioplayer.cpp \ -- cgit v0.12 From ee990e2ed366a16605afb6a13edd9c59b1bcc33d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 20 Aug 2009 14:54:39 +0100 Subject: Added stub VideoWidget implementation --- src/3rdparty/phonon/mmf/audiooutput.h | 7 +- src/3rdparty/phonon/mmf/videoplayer.h | 5 +- src/3rdparty/phonon/mmf/videowidget.cpp | 130 ++++++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/videowidget.h | 67 ++++++++++++++++ src/plugins/phonon/mmf/mmf.pro | 4 +- 5 files changed, 205 insertions(+), 8 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/videowidget.cpp create mode 100644 src/3rdparty/phonon/mmf/videowidget.h diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 016ec8e..ad39626 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -67,13 +67,10 @@ namespace Phonon */ virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); - void setVolumeControl(VolumeControlInterface *volumeControl); - /** - * Called by MediaObject to pass initial volume when clip has been - * successfully opened + * Called by backend when nodes are connected. */ - //void triggerVolumeChanged(qreal volume); + void setVolumeControl(VolumeControlInterface *volumeControl); Q_SIGNALS: void volumeChanged(qreal volume); diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index 9bf2622..b4cfa69 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -37,10 +37,11 @@ namespace Phonon * How to * play a video file using CVideoPlayerUtility */ - class VideoPlayer : public AbstractMediaPlayer - , public MVideoPlayerUtilityObserver + class VideoPlayer : public AbstractMediaPlayer + , public MVideoPlayerUtilityObserver { Q_OBJECT + public: VideoPlayer(); explicit VideoPlayer(const AbstractPlayer& player); diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp new file mode 100644 index 0000000..3628470 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -0,0 +1,130 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "videowidget.h" + + +using namespace Phonon; +using namespace Phonon::MMF; + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio = + Phonon::VideoWidget::AspectRatioAuto; +static const qreal DefaultBrightness = 1.0; +static const Phonon::VideoWidget::ScaleMode DefaultScaleMode = + Phonon::VideoWidget::FitInView; +static const qreal DefaultContrast = 1.0; +static const qreal DefaultHue = 1.0; +static const qreal DefaultSaturation = 1.0; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::VideoWidget::VideoWidget() + : m_aspectRatio(DefaultAspectRatio) + , m_brightness(DefaultBrightness) + , m_scaleMode(DefaultScaleMode) + , m_contrast(DefaultContrast) + , m_hue(DefaultHue) + , m_saturation(DefaultSaturation) +{ + +} + +MMF::VideoWidget::~VideoWidget() +{ + +} + + +//----------------------------------------------------------------------------- +// VideoWidgetInterface +//----------------------------------------------------------------------------- + +Phonon::VideoWidget::AspectRatio MMF::VideoWidget::aspectRatio() const +{ + return m_aspectRatio; +} + +void MMF::VideoWidget::setAspectRatio + (Phonon::VideoWidget::AspectRatio aspectRatio) +{ + m_aspectRatio = aspectRatio; +} + +qreal MMF::VideoWidget::brightness() const +{ + return m_brightness; +} + +void MMF::VideoWidget::setBrightness(qreal brightness) +{ + m_brightness = brightness; +} + +Phonon::VideoWidget::ScaleMode MMF::VideoWidget::scaleMode() const +{ + return m_scaleMode; +} + +void MMF::VideoWidget::setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode) +{ + m_scaleMode = scaleMode; +} + +qreal MMF::VideoWidget::contrast() const +{ + return m_contrast; +} + +void MMF::VideoWidget::setContrast(qreal contrast) +{ + m_contrast = contrast; +} + +qreal MMF::VideoWidget::hue() const +{ + return m_hue; +} + +void MMF::VideoWidget::setHue(qreal hue) +{ + m_hue = hue; +} + +qreal MMF::VideoWidget::saturation() const +{ + return m_saturation; +} + +void MMF::VideoWidget::setSaturation(qreal saturation) +{ + m_saturation = saturation; +} + +QWidget* MMF::VideoWidget::widget() +{ + return this; +} + + diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h new file mode 100644 index 0000000..1ed23e2 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -0,0 +1,67 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_VIDEOWIDGET_H +#define PHONON_MMF_VIDEOWIDGET_H + +#include +#include +#include + +namespace Phonon +{ + namespace MMF + { + class VideoWidget : public QWidget + , public Phonon::VideoWidgetInterface + { + Q_OBJECT + Q_INTERFACES(Phonon::VideoWidgetInterface) + + public: + VideoWidget(); + ~VideoWidget(); + + // VideoWidgetInterface + virtual Phonon::VideoWidget::AspectRatio aspectRatio() const; + virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio aspectRatio); + virtual qreal brightness() const; + virtual void setBrightness(qreal brightness); + virtual Phonon::VideoWidget::ScaleMode scaleMode() const; + virtual void setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode); + virtual qreal contrast() const; + virtual void setContrast(qreal constrast); + virtual qreal hue() const; + virtual void setHue(qreal hue); + virtual qreal saturation() const; + virtual void setSaturation(qreal saturation); + virtual QWidget *widget(); + + private: + Phonon::VideoWidget::AspectRatio m_aspectRatio; + qreal m_brightness; + Phonon::VideoWidget::ScaleMode m_scaleMode; + qreal m_contrast; + qreal m_hue; + qreal m_saturation; + + }; + } +} + +#endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 99aa4a4..bb614b4 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -32,6 +32,7 @@ HEADERS += \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/utils.h \ $$PHONON_MMF_DIR/videoplayer.h \ + $$PHONON_MMF_DIR/videowidget.h \ $$PHONON_MMF_DIR/volumecontrolinterface.h SOURCES += \ @@ -43,7 +44,8 @@ SOURCES += \ $$PHONON_MMF_DIR/dummyplayer.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/utils.cpp \ - $$PHONON_MMF_DIR/videoplayer.cpp + $$PHONON_MMF_DIR/videoplayer.cpp \ + $$PHONON_MMF_DIR/videowidget.cpp LIBS += -lmediaclientvideo.lib # For CVideoPlayerUtility LIBS += -lcone.lib # For CCoeEnv -- cgit v0.12 From 2150242ddbe66c5d4c440599f1282580be013e61 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 20 Aug 2009 17:24:55 +0100 Subject: Started fleshing out the VideoPlayer implementation Now loads, prepares and plays a clip, but the video is not visible because it's not yet wired up to a VideoWidget. Video 'playback' can be tested using the demos/mediaplayer application, but the menus are not displayed properly, so a video clip filename must be hardcoded in main.cpp and passed to the MediaPlayer constructor. --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 34 ++++++++-- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 7 ++ src/3rdparty/phonon/mmf/audioplayer.cpp | 9 ++- src/3rdparty/phonon/mmf/backend.cpp | 9 ++- src/3rdparty/phonon/mmf/mediaobject.cpp | 4 +- src/3rdparty/phonon/mmf/videoplayer.cpp | 88 ++++++++++++++++++++----- src/3rdparty/phonon/mmf/videowidget.cpp | 5 +- src/3rdparty/phonon/mmf/videowidget.h | 2 +- 8 files changed, 118 insertions(+), 40 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index a86f634..dbb4d2d 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -70,12 +70,15 @@ void MMF::AbstractMediaPlayer::play() switch(m_state) { case GroundState: - case LoadingState: // Is this the correct error? Really we want 'NotReadyError' m_error = NormalError; changeState(ErrorState); break; - + + case LoadingState: + m_playPending = true; + break; + case StoppedState: case PausedState: doPlay(); @@ -102,6 +105,8 @@ void MMF::AbstractMediaPlayer::pause() TRACE_CONTEXT(AbstractMediaPlayer::pause, EAudioApi); TRACE_ENTRY("state %d", m_state); + m_playPending = false; + switch(m_state) { case GroundState: @@ -132,6 +137,8 @@ void MMF::AbstractMediaPlayer::stop() TRACE_CONTEXT(AbstractMediaPlayer::stop, EAudioApi); TRACE_ENTRY("state %d", m_state); + m_playPending = false; + switch(m_state) { case GroundState: @@ -375,16 +382,29 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) // TODO: add some invariants to check that the transition is valid - const Phonon::State currentPhononState = phononState(m_state); + const Phonon::State oldPhononState = phononState(m_state); const Phonon::State newPhononState = phononState(newState); - if(currentPhononState != newPhononState) + if(oldPhononState != newPhononState) { - TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState); - emit stateChanged(newPhononState, currentPhononState); + TRACE("emit stateChanged(%d, %d)", newPhononState, oldPhononState); + emit stateChanged(newPhononState, oldPhononState); } m_state = newState; - + + // Check whether play() was called while clip was being loaded. If so, + // playback should be started now + if( + LoadingState == oldPhononState + and StoppedState == newPhononState + and m_playPending + ) + { + TRACE("Play was called while loading; starting playback now"); + m_playPending = false; + play(); + } + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 0c233c9..9e0d3c8 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -127,6 +127,13 @@ namespace Phonon PrivateState m_state; Phonon::ErrorType m_error; + /** + * This flag is set to true if play is called when the object is + * in a Loading state. Once loading is complete, playback will + * be started. + */ + bool m_playPending; + QScopedPointer m_tickTimer; int m_mmfMaxVolume; diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index f7ab0df..8d8eb53 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -124,9 +124,7 @@ void MMF::AudioPlayer::seek(qint64 ms) bool MMF::AudioPlayer::hasVideo() const { - TRACE_CONTEXT(AudioPlayer::hasVideo, EAudioApi); - TRACE_ENTRY("state %d", state()); - TRACE_RETURN("%d", false); + return false; } qint64 MMF::AudioPlayer::currentTime() const @@ -137,9 +135,10 @@ qint64 MMF::AudioPlayer::currentTime() const TTimeIntervalMicroSeconds us; const TInt err = m_player->GetPosition(us); - qint64 result = -1; + qint64 result = 0; - if(KErrNone == err) { + if(KErrNone == err) + { result = toMilliSeconds(us); } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 7a0f3f5..9494c65 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -22,6 +22,7 @@ along with this library. If not, see . #include "backend.h" #include "audiooutput.h" #include "mediaobject.h" +#include "videowidget.h" using namespace Phonon; using namespace Phonon::MMF; @@ -55,15 +56,13 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const break; case VolumeFaderEffectClass: - /* Fallthrough. */ case VisualizationClass: - /* Fallthrough. */ case VideoDataOutputClass: - /* Fallthrough. */ case EffectClass: - /* Fallthrough. */ + break; + case VideoWidgetClass: - result = NULL; + result = new VideoWidget(qobject_cast(parent)); break; default: diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 0336109..8ac9441 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -30,7 +30,7 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::MediaObject::MediaObject(QObject *parent) : QObject::QObject(parent) +MMF::MediaObject::MediaObject(QObject *parent) : QObject(parent) , m_recognizerOpened(false) { m_player.reset(new DummyPlayer()); @@ -224,7 +224,7 @@ void MMF::MediaObject::setSource(const MediaSource &source) void MMF::MediaObject::createPlayer(const MediaSource &source) { - TRACE_CONTEXT(AudioPlayer::createPlayer, EAudioApi); + TRACE_CONTEXT(MediaObject::createPlayer, EAudioApi); TRACE_ENTRY("state %d source.type %d", state(), source.type()); TRACE_ENTRY("source.type %d", source.type()); diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index b0c786b..6e6bcb2 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -97,42 +97,53 @@ MMF::VideoPlayer::~VideoPlayer() void MMF::VideoPlayer::doPlay() { - // TODO + m_player->Play(); } void MMF::VideoPlayer::doPause() { - // TODO + TRAPD(err, m_player->PauseL()); + if(KErrNone != err) + { + setError(NormalError); + } } void MMF::VideoPlayer::doStop() { - // TODO + m_player->Stop(); } int MMF::VideoPlayer::doSetMmfVolume(int mmfVolume) { - // TODO - Q_UNUSED(mmfVolume); - return KErrNotSupported; + TRAPD(err, m_player->SetVolumeL(mmfVolume)); + return err; } int MMF::VideoPlayer::openFile(RFile& file) { - // TODO - Q_UNUSED(file); - return KErrNotSupported; + TRAPD(err, m_player->OpenFileL(file)); + return err; } void MMF::VideoPlayer::close() { - + m_player->Close(); } void MMF::VideoPlayer::seek(qint64 ms) { - // TODO - Q_UNUSED(ms); + TRACE_CONTEXT(VideoPlayer::seek, EAudioApi); + TRACE_ENTRY("state %d pos %Ld", state(), ms); + + TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms))); + + if(KErrNone != err) + { + setError(NormalError); + } + + TRACE_EXIT_0(); } bool MMF::VideoPlayer::hasVideo() const @@ -142,14 +153,32 @@ bool MMF::VideoPlayer::hasVideo() const qint64 MMF::VideoPlayer::currentTime() const { - // TODO - return 0; + TTimeIntervalMicroSeconds us; + TRAPD(err, us = m_player->PositionL()) + + qint64 result = 0; + + if(KErrNone == err) + { + result = toMilliSeconds(us); + } + + return result; } qint64 MMF::VideoPlayer::totalTime() const { - // TODO - return 0; + qint64 result = 0; + TRAPD(err, result = toMilliSeconds(m_player->DurationL())); + + if(KErrNone != err) + { + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast(this)->setError(NormalError); + } + + return result; } @@ -162,7 +191,17 @@ void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); TRACE_ENTRY("state %d error %d", state(), aError); - // TODO + __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); + + if(KErrNone == aError) + { + m_player->Prepare(); + } + else + { + // TODO: set different error states according to value of aError? + setError(NormalError); + } TRACE_EXIT_0(); } @@ -172,7 +211,20 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); TRACE_ENTRY("state %d error %d", state(), aError); - // TODO + __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); + + if(KErrNone == aError) + { + initVolume(m_player->MaxVolume()); + + emit totalTimeChanged(); + changeState(StoppedState); + } + else + { + // TODO: set different error states according to value of aError? + setError(NormalError); + } TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 3628470..3438aaa 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -40,8 +40,9 @@ static const qreal DefaultSaturation = 1.0; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoWidget::VideoWidget() - : m_aspectRatio(DefaultAspectRatio) +MMF::VideoWidget::VideoWidget(QWidget* parent) + : QWidget(parent) + , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) , m_contrast(DefaultContrast) diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 1ed23e2..3c33a56 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -34,7 +34,7 @@ namespace Phonon Q_INTERFACES(Phonon::VideoWidgetInterface) public: - VideoWidget(); + VideoWidget(QWidget* parent); ~VideoWidget(); // VideoWidgetInterface -- cgit v0.12 From 932c48658656fa328507b16e39c3a6cc820ef15e Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 21 Aug 2009 09:09:45 +0100 Subject: Tidied up trace statements --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 27 ++++++----------- src/3rdparty/phonon/mmf/audioplayer.cpp | 18 ++++++----- src/3rdparty/phonon/mmf/backend.cpp | 40 +++++++++++++++++-------- src/3rdparty/phonon/mmf/mediaobject.cpp | 17 +++++++++++ src/3rdparty/phonon/mmf/utils.cpp | 4 +-- src/3rdparty/phonon/mmf/utils.h | 14 ++++++--- src/3rdparty/phonon/mmf/videoplayer.cpp | 26 ++++++++++++++-- src/3rdparty/phonon/mmf/videowidget.cpp | 30 +++++++++++++++++-- 8 files changed, 125 insertions(+), 51 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index dbb4d2d..be34fef 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -188,10 +188,6 @@ Phonon::ErrorType MMF::AbstractMediaPlayer::errorType() const QString MMF::AbstractMediaPlayer::errorString() const { - TRACE_CONTEXT(AbstractMediaPlayer::errorString, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - TRACE_EXIT_0(); // TODO: put in proper error strings QString result; return result; @@ -199,12 +195,7 @@ QString MMF::AbstractMediaPlayer::errorString() const Phonon::State MMF::AbstractMediaPlayer::state() const { - TRACE_CONTEXT(AbstractMediaPlayer::state, EAudioApi); - TRACE_ENTRY("state %d", m_state); - - const Phonon::State result = phononState(m_state); - - TRACE_RETURN("%d", result); + return phononState(m_state); } MediaSource MMF::AbstractMediaPlayer::source() const @@ -214,7 +205,7 @@ MediaSource MMF::AbstractMediaPlayer::source() const void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& file) { - TRACE_CONTEXT(AudioPlayer::setSource, EAudioApi); + TRACE_CONTEXT(AbstractMediaPlayer::setFileSource, EAudioApi); TRACE_ENTRY("state %d source.type %d", m_state, source.type()); close(); @@ -247,6 +238,7 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f case MediaSource::Url: { + TRACE_0("Source type not supported"); // TODO: support opening URLs symbianErr = KErrNotSupported; break; @@ -255,10 +247,12 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f case MediaSource::Invalid: case MediaSource::Disc: case MediaSource::Stream: + TRACE_0("Source type not supported"); symbianErr = KErrNotSupported; break; case MediaSource::Empty: + TRACE_0("Empty source - doing nothing"); TRACE_EXIT_0(); return; @@ -273,6 +267,8 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f } else { + TRACE("error %d", symbianErr) + // TODO: do something with the value of symbianErr? m_error = NormalError; changeState(ErrorState); @@ -336,7 +332,7 @@ bool MMF::AbstractMediaPlayer::doSetVolume(qreal volume) TRACE_PANIC(InvalidStatePanic); } - return result; + TRACE_RETURN("%d", result); } @@ -400,7 +396,7 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) and m_playPending ) { - TRACE("Play was called while loading; starting playback now"); + TRACE_0("Play was called while loading; starting playback now"); m_playPending = false; play(); } @@ -431,12 +427,7 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds void MMF::AbstractMediaPlayer::tick() { - TRACE_CONTEXT(AbstractMediaPlayer::tick, EAudioInternal); - TRACE_ENTRY("state %d", m_state); - emit tick(currentTime()); - - TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 8d8eb53..e812af5 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -130,7 +130,6 @@ bool MMF::AudioPlayer::hasVideo() const qint64 MMF::AudioPlayer::currentTime() const { TRACE_CONTEXT(AudioPlayer::currentTime, EAudioApi); - TRACE_ENTRY("state %d", state()); TTimeIntervalMicroSeconds us; const TInt err = m_player->GetPosition(us); @@ -141,18 +140,21 @@ qint64 MMF::AudioPlayer::currentTime() const { result = toMilliSeconds(us); } + else + { + TRACE("GetPosition err %d", err); + + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast(this)->setError(NormalError); + } - TRACE_RETURN("%Ld", result); + return result; } qint64 MMF::AudioPlayer::totalTime() const { - TRACE_CONTEXT(AudioPlayer::totalTime, EAudioApi); - TRACE_ENTRY("state %d", state()); - - const qint64 result = toMilliSeconds(m_player->Duration()); - - TRACE_RETURN("%Ld", result); + return toMilliSeconds(m_player->Duration()); } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 9494c65..f610b60 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -22,6 +22,7 @@ along with this library. If not, see . #include "backend.h" #include "audiooutput.h" #include "mediaobject.h" +#include "utils.h" #include "videowidget.h" using namespace Phonon; @@ -29,19 +30,22 @@ using namespace Phonon::MMF; Backend::Backend(QObject *parent) : QObject(parent) { - // TODO: replace this with logging macros as per rest of the module - qDebug() << Q_FUNC_INFO; + TRACE_CONTEXT(Backend::Backend, EBackend); + TRACE_ENTRY_0(); setProperty("identifier", QLatin1String("phonon_mmf")); setProperty("backendName", QLatin1String("MMF")); setProperty("backendComment", QLatin1String("Backend using Symbian Multimedia Framework (MMF)")); setProperty("backendVersion", QLatin1String("0.1")); setProperty("backendWebsite", QLatin1String("http://www.qtsoftware.com/")); + + TRACE_EXIT_0(); } QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &) { - // TODO: add trace + TRACE_CONTEXT(Backend::createObject, EBackend); + TRACE_ENTRY("class %d", c); QObject* result = NULL; @@ -66,10 +70,10 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const break; default: - Q_ASSERT_X(false, Q_FUNC_INFO, "This line should never be reached."); + TRACE_PANIC(InvalidBackendInterfaceClass); } - return result; + TRACE_RETURN("0x%08x", result); } QList Backend::objectDescriptionIndexes(ObjectDescriptionType) const @@ -89,26 +93,36 @@ bool Backend::startConnectionChange(QSet) bool Backend::connectNodes(QObject *source, QObject *target) { - // TODO: add trace + TRACE_CONTEXT(Backend::connectNodes, EBackend); + TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); MediaObject *const mediaObject = qobject_cast(source); AudioOutput *const audioOutput = qobject_cast(target); + bool result = false; + if(mediaObject and audioOutput) { + TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); + audioOutput->setVolumeControl(mediaObject); - return true; + result = true; } - // Node types not recognised - return false; + TRACE_RETURN("%d", result); } -bool Backend::disconnectNodes(QObject *, QObject *) +bool Backend::disconnectNodes(QObject *source, QObject *target) { - // TODO: add trace - - return true; + TRACE_CONTEXT(Backend::disconnectNodes, EBackend); + TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); + + Q_UNUSED(source); // silence warnings in release builds + Q_UNUSED(target); // silence warnings in release builds + + bool result = true; + + TRACE_RETURN("%d", result); } bool Backend::endConnectionChange(QSet) diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 8ac9441..4b5c4f0 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -62,17 +62,21 @@ MMF::MediaObject::~MediaObject() bool MMF::MediaObject::openRecognizer() { + TRACE_CONTEXT(MediaObject::openRecognizer, EAudioInternal); + if(!m_recognizerOpened) { TInt err = m_recognizer.Connect(); if(KErrNone != err) { + TRACE("RApaLsSession::Connect error %d", err); return false; } err = m_fileServer.Connect(); if(KErrNone != err) { + TRACE("RFs::Connect error %d", err); return false; } @@ -81,6 +85,7 @@ bool MMF::MediaObject::openRecognizer() err = m_fileServer.ShareProtected(); if(KErrNone != err) { + TRACE("RFs::ShareProtected error %d", err); return false; } @@ -114,6 +119,8 @@ MMF::MediaObject::MediaType MMF::MediaObject::mimeTypeToMediaType(const TDesC& m MMF::MediaObject::MediaType MMF::MediaObject::fileMediaType (const QString& fileName) { + TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal); + MediaType result = MediaTypeUnknown; if(openRecognizer()) @@ -132,6 +139,14 @@ MMF::MediaObject::MediaType MMF::MediaObject::fileMediaType const TPtrC mimeType = recognizerResult.iDataType.Des(); result = mimeTypeToMediaType(mimeType); } + else + { + TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err); + } + } + else + { + TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err); } } @@ -322,6 +337,8 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); + + TRACE_EXIT_0(); } void MMF::MediaObject::setNextSource(const MediaSource &source) diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index aa87310..ada4800 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -25,9 +25,9 @@ using namespace Phonon::MMF; _LIT(PanicCategory, "Phonon::MMF"); void MMF::Utils::panic(PanicCode code) - { +{ User::Panic(PanicCategory, code); - } +} QHBufC MMF::Utils::symbianFilename(const QString& qtFilename) { diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index e3e7317..ff9eedd 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -31,8 +31,9 @@ namespace Phonon */ enum PanicCode { - InvalidStatePanic, - InvalidMediaTypePanic + InvalidStatePanic = 1, + InvalidMediaTypePanic = 2, + InvalidBackendInterfaceClass = 3 }; namespace Utils @@ -58,14 +59,19 @@ namespace Phonon enum TTraceCategory { /** + * Backend + */ + EBackend = 0x00000001, + + /** * Functions which map directly to the public Phonon audio API */ - EAudioApi = 0x00000001, + EAudioApi = 0x00000010, /** * Internal functions in the audio implementation */ - EAudioInternal = 0x00000002, + EAudioInternal = 0x00000020, /** * Functions which map directly to the public Phonon video API diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 6e6bcb2..45d4f65 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -47,7 +47,7 @@ MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) void MMF::VideoPlayer::construct() { - TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi); + TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); TRACE_ENTRY_0(); CCoeControl* control = m_widget->winId(); @@ -102,9 +102,12 @@ void MMF::VideoPlayer::doPlay() void MMF::VideoPlayer::doPause() { + TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); + TRAPD(err, m_player->PauseL()); if(KErrNone != err) { + TRACE("PauseL error %d", err); setError(NormalError); } } @@ -133,13 +136,14 @@ void MMF::VideoPlayer::close() void MMF::VideoPlayer::seek(qint64 ms) { - TRACE_CONTEXT(VideoPlayer::seek, EAudioApi); + TRACE_CONTEXT(VideoPlayer::seek, EVideoApi); TRACE_ENTRY("state %d pos %Ld", state(), ms); TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms))); if(KErrNone != err) { + TRACE("SetPositionL error %d", err); setError(NormalError); } @@ -153,6 +157,8 @@ bool MMF::VideoPlayer::hasVideo() const qint64 MMF::VideoPlayer::currentTime() const { + TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); + TTimeIntervalMicroSeconds us; TRAPD(err, us = m_player->PositionL()) @@ -162,17 +168,29 @@ qint64 MMF::VideoPlayer::currentTime() const { result = toMilliSeconds(us); } + else + { + TRACE("PositionL error %d", err); + + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast(this)->setError(NormalError); + } return result; } qint64 MMF::VideoPlayer::totalTime() const { + TRACE_CONTEXT(VideoPlayer::totalTime, EVideoApi); + qint64 result = 0; TRAPD(err, result = toMilliSeconds(m_player->DurationL())); if(KErrNone != err) { + TRACE("DurationL error %d", err); + // If we don't cast away constness here, we simply have to ignore // the error. const_cast(this)->setError(NormalError); @@ -198,7 +216,7 @@ void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) m_player->Prepare(); } else - { + { // TODO: set different error states according to value of aError? setError(NormalError); } @@ -236,6 +254,7 @@ void MMF::VideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) // TODO Q_UNUSED(aFrame); + Q_UNUSED(aError); // suppress warnings in release builds TRACE_EXIT_0(); } @@ -246,6 +265,7 @@ void MMF::VideoPlayer::MvpuoPlayComplete(TInt aError) TRACE_ENTRY("state %d error %d", state(), aError); // TODO + Q_UNUSED(aError); // suppress warnings in release builds TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 3438aaa..194c885 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -16,9 +16,9 @@ along with this library. If not, see . */ +#include "utils.h" #include "videowidget.h" - using namespace Phonon; using namespace Phonon::MMF; @@ -49,12 +49,18 @@ MMF::VideoWidget::VideoWidget(QWidget* parent) , m_hue(DefaultHue) , m_saturation(DefaultSaturation) { - + TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } MMF::VideoWidget::~VideoWidget() { - + TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } @@ -70,6 +76,9 @@ Phonon::VideoWidget::AspectRatio MMF::VideoWidget::aspectRatio() const void MMF::VideoWidget::setAspectRatio (Phonon::VideoWidget::AspectRatio aspectRatio) { + TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi); + TRACE("aspectRatio %d", aspectRatio); + m_aspectRatio = aspectRatio; } @@ -80,6 +89,9 @@ qreal MMF::VideoWidget::brightness() const void MMF::VideoWidget::setBrightness(qreal brightness) { + TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi); + TRACE("brightness %f", brightness); + m_brightness = brightness; } @@ -90,6 +102,9 @@ Phonon::VideoWidget::ScaleMode MMF::VideoWidget::scaleMode() const void MMF::VideoWidget::setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode) { + TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi); + TRACE("setScaleMode %d", setScaleMode); + m_scaleMode = scaleMode; } @@ -100,6 +115,9 @@ qreal MMF::VideoWidget::contrast() const void MMF::VideoWidget::setContrast(qreal contrast) { + TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi); + TRACE("contrast %f", contrast); + m_contrast = contrast; } @@ -110,6 +128,9 @@ qreal MMF::VideoWidget::hue() const void MMF::VideoWidget::setHue(qreal hue) { + TRACE_CONTEXT(VideoWidget::setHue, EVideoApi); + TRACE("hue %f", hue); + m_hue = hue; } @@ -120,6 +141,9 @@ qreal MMF::VideoWidget::saturation() const void MMF::VideoWidget::setSaturation(qreal saturation) { + TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi); + TRACE("saturation %f", saturation); + m_saturation = saturation; } -- cgit v0.12 From 3f39d630d3dcc161c4a85127129274ca7ea857a2 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 21 Aug 2009 11:39:36 +0100 Subject: Further tidied up volume handling --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 75 +++++++++++++----------- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 13 +++- src/3rdparty/phonon/mmf/abstractplayer.cpp | 34 ++--------- src/3rdparty/phonon/mmf/abstractplayer.h | 18 ++---- src/3rdparty/phonon/mmf/audiooutput.cpp | 36 +++++------- src/3rdparty/phonon/mmf/audiooutput.h | 16 +++-- src/3rdparty/phonon/mmf/audioplayer.cpp | 4 +- src/3rdparty/phonon/mmf/audioplayer.h | 2 +- src/3rdparty/phonon/mmf/backend.cpp | 13 +++- src/3rdparty/phonon/mmf/dummyplayer.cpp | 14 +++-- src/3rdparty/phonon/mmf/dummyplayer.h | 4 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 12 ++-- src/3rdparty/phonon/mmf/mediaobject.h | 24 ++++---- src/3rdparty/phonon/mmf/videooutput.cpp | 45 ++++++++++++++ src/3rdparty/phonon/mmf/videooutput.h | 42 +++++++++++++ src/3rdparty/phonon/mmf/videoplayer.cpp | 8 +-- src/3rdparty/phonon/mmf/videoplayer.h | 6 +- src/3rdparty/phonon/mmf/videowidget.cpp | 5 +- src/3rdparty/phonon/mmf/videowidget.h | 5 +- src/3rdparty/phonon/mmf/volumecontrolinterface.h | 48 --------------- src/3rdparty/phonon/mmf/volumeobserver.h | 40 +++++++++++++ src/plugins/phonon/mmf/mmf.pro | 4 +- 22 files changed, 269 insertions(+), 199 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/videooutput.cpp create mode 100644 src/3rdparty/phonon/mmf/videooutput.h delete mode 100644 src/3rdparty/phonon/mmf/volumecontrolinterface.h create mode 100644 src/3rdparty/phonon/mmf/volumeobserver.h diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index be34fef..6342f37 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -17,6 +17,7 @@ along with this library. If not, see . */ #include "abstractmediaplayer.h" +#include "defs.h" #include "utils.h" using namespace Phonon; @@ -36,7 +37,9 @@ const int NullMaxVolume = -1; MMF::AbstractMediaPlayer::AbstractMediaPlayer() : m_state(GroundState) , m_error(NoError) + , m_playPending(false) , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) , m_mmfMaxVolume(NullMaxVolume) { connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); @@ -46,7 +49,9 @@ MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) : AbstractPlayer(player) , m_state(GroundState) , m_error(NoError) + , m_playPending(false) , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) , m_mmfMaxVolume(NullMaxVolume) { connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); @@ -292,47 +297,51 @@ void MMF::AbstractMediaPlayer::setNextSource(const MediaSource &source) //----------------------------------------------------------------------------- -// VolumeControlInterface +// VolumeObserver //----------------------------------------------------------------------------- -bool MMF::AbstractMediaPlayer::doSetVolume(qreal volume) +void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) { - TRACE_CONTEXT(AbstractMediaPlayer::doSetVolume, EAudioInternal); + TRACE_CONTEXT(AbstractMediaPlayer::volumeChanged, EAudioInternal); TRACE_ENTRY("state %d", m_state); - - bool result = true; - switch(m_state) - { - case GroundState: - case LoadingState: - case ErrorState: + m_volume = volume; + doVolumeChanged(); + + TRACE_EXIT_0(); +} + + +void MMF::AbstractMediaPlayer::doVolumeChanged() +{ + switch(m_state) + { + case GroundState: + case LoadingState: + case ErrorState: // Do nothing - break; + break; - case StoppedState: - case PausedState: - case PlayingState: - case BufferingState: - { - const int err = doSetMmfVolume(volume * m_mmfMaxVolume); - - if(KErrNone != err) - { + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: + { + const int err = setDeviceVolume(m_volume * m_mmfMaxVolume); + + if(KErrNone != err) + { m_error = NormalError; changeState(ErrorState); - result = false; - } - break; - } + } + break; + } - // Protection against adding new states and forgetting to update this - // switch - default: - TRACE_PANIC(InvalidStatePanic); - } - - TRACE_RETURN("%d", result); + // Protection against adding new states and forgetting to update this + // switch + default: + Utils::panic(InvalidStatePanic); + } } @@ -350,10 +359,10 @@ void MMF::AbstractMediaPlayer::stopTickTimer() m_tickTimer->stop(); } -void MMF::AbstractMediaPlayer::initVolume(int mmfMaxVolume) +void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) { m_mmfMaxVolume = mmfMaxVolume; - doSetVolume(volume() * m_mmfMaxVolume); + doVolumeChanged(); } Phonon::State MMF::AbstractMediaPlayer::phononState() const diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 9e0d3c8..58aca84 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -57,24 +57,26 @@ namespace Phonon virtual MediaSource source() const; virtual void setFileSource(const Phonon::MediaSource&, RFile&); virtual void setNextSource(const MediaSource &source); + + // VolumeObserver + virtual void volumeChanged(qreal volume); protected: // AbstractPlayer virtual void doSetTickInterval(qint32 interval); - virtual bool doSetVolume(qreal volume); protected: virtual void doPlay() = 0; virtual void doPause() = 0; virtual void doStop() = 0; - virtual int doSetMmfVolume(int mmfVolume) = 0; + virtual int setDeviceVolume(int mmfVolume) = 0; virtual int openFile(RFile& file) = 0; virtual void close() = 0; protected: void startTickTimer(); void stopTickTimer(); - void initVolume(int maxVolume); + void maxVolumeChanged(int maxVolume); /** * Defined private state enumeration in order to add GroundState @@ -111,6 +113,9 @@ namespace Phonon void setError(Phonon::ErrorType error); static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + + private: + void doVolumeChanged(); Q_SIGNALS: void tick(qint64 time); @@ -135,6 +140,8 @@ namespace Phonon bool m_playPending; QScopedPointer m_tickTimer; + + qreal m_volume; int m_mmfMaxVolume; MediaSource m_source; diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 7786d8b..870b50f 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -27,18 +27,16 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AbstractPlayer::AbstractPlayer() : - m_tickInterval(DefaultTickInterval) - , m_volume(InitialVolume) +MMF::AbstractPlayer::AbstractPlayer() + : m_tickInterval(DefaultTickInterval) , m_transitionTime(0) , m_prefinishMark(0) { } -MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) : - m_tickInterval(player.tickInterval()) - , m_volume(player.volume()) +MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) + : m_tickInterval(player.tickInterval()) , m_transitionTime(player.transitionTime()) , m_prefinishMark(player.prefinishMark()) { @@ -81,27 +79,3 @@ void MMF::AbstractPlayer::setTransitionTime(qint32 time) } -//----------------------------------------------------------------------------- -// VolumeControlInterface -//----------------------------------------------------------------------------- - -qreal MMF::AbstractPlayer::volume() const -{ - return m_volume; -} - -bool MMF::AbstractPlayer::setVolume(qreal volume) -{ - bool result = false; - if(volume != m_volume) - { - result = doSetVolume(volume); - if(result) - { - m_volume = volume; - } - } - return result; -} - - diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 546d929..4b899d2 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -23,7 +23,7 @@ along with this library. If not, see . #include #include -#include "volumecontrolinterface.h" +#include "volumeobserver.h" class RFile; @@ -44,7 +44,7 @@ namespace Phonon * - Video, in which case the implementation is VideoPlayer */ class AbstractPlayer : public QObject - , public VolumeControlInterface + , public VolumeObserver { // Required although this class has no signals or slots // Without this, qobject_cast will fail @@ -81,19 +81,13 @@ namespace Phonon virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; virtual void setNextSource(const Phonon::MediaSource &) = 0; - // VolumeControlInterface - qreal volume() const; - bool setVolume(qreal volume); - private: virtual void doSetTickInterval(qint32 interval) = 0; - virtual bool doSetVolume(qreal volume) = 0; - private: - qint32 m_tickInterval; - qreal m_volume; - qint32 m_transitionTime; - qint32 m_prefinishMark; + private: + qint32 m_tickInterval; + qint32 m_transitionTime; + qint32 m_prefinishMark; }; } diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 2e5cbc6..13b953d 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -21,7 +21,7 @@ along with this library. If not, see . #include "audiooutput.h" #include "defs.h" #include "utils.h" -#include "volumecontrolinterface.h" +#include "volumeobserver.h" using namespace Phonon; using namespace Phonon::MMF; @@ -33,7 +33,7 @@ using namespace Phonon::MMF; MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) , m_volume(InitialVolume) - , m_volumeControl(NULL) + , m_observer(NULL) { } @@ -45,32 +45,26 @@ MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) qreal MMF::AudioOutput::volume() const { - TRACE_CONTEXT(AudioOutput::volume, EAudioApi); - TRACE_ENTRY("control 0x%08x ", m_volumeControl); - - const qreal result = m_volumeControl ? m_volumeControl->volume() : m_volume; - - TRACE_RETURN("%f", result); + return m_volume; } void MMF::AudioOutput::setVolume(qreal volume) { TRACE_CONTEXT(AudioOutput::setVolume, EAudioApi); - TRACE_ENTRY("control 0x%08x volume %f", m_volumeControl, volume); + TRACE_ENTRY("observer 0x%08x volume %f", m_observer, volume); - if(m_volumeControl) + if(volume != m_volume) { - if(m_volumeControl->setVolume(volume)) + if(m_observer) { - TRACE("emit volumeChanged(%f)", volume) - emit volumeChanged(volume); + m_observer->volumeChanged(volume); } - } - else - { + m_volume = volume; + TRACE("emit volumeChanged(%f)", volume) + emit volumeChanged(volume); } - + TRACE_EXIT_0(); } @@ -89,10 +83,10 @@ bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) return true; } -void MMF::AudioOutput::setVolumeControl(VolumeControlInterface *volumeControl) +void MMF::AudioOutput::setVolumeObserver(VolumeObserver& observer) { - Q_ASSERT(!m_volumeControl); - m_volumeControl = volumeControl; - m_volumeControl->setVolume(m_volume); + Q_ASSERT(!m_observer); + m_observer = &observer; + m_observer->volumeChanged(m_volume); } diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index ad39626..38623a8 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -19,19 +19,19 @@ along with this library. If not, see . #ifndef PHONON_MMF_AUDIOOUTPUT_H #define PHONON_MMF_AUDIOOUTPUT_H -#include +#include namespace Phonon { namespace MMF { class Backend; - class VolumeControlInterface; + class VolumeObserver; /** * @short AudioOutputInterface implementation for MMF. * - * Forwards volume commands to the VolumeControlInterface instance, + * Forwards volume commands to the VolumeObserver instance, * which is provided by the backend when MediaNode objects are * connected. * @@ -70,19 +70,17 @@ namespace Phonon /** * Called by backend when nodes are connected. */ - void setVolumeControl(VolumeControlInterface *volumeControl); + void setVolumeObserver(VolumeObserver& observer); Q_SIGNALS: void volumeChanged(qreal volume); void audioDeviceFailed(); private: - /** - * This value is used when m_volumeControl is NULL. - */ - qreal m_volume; + qreal m_volume; - VolumeControlInterface * m_volumeControl; + // Not owned + VolumeObserver* m_observer; }; } } diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index e812af5..67ed7a5 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -84,7 +84,7 @@ void MMF::AudioPlayer::doStop() m_player->Stop(); } -int MMF::AudioPlayer::doSetMmfVolume(int mmfVolume) +int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) { return m_player->SetVolume(mmfVolume); } @@ -177,7 +177,7 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, if(KErrNone == aError) { - initVolume(m_player->MaxVolume()); + maxVolumeChanged(m_player->MaxVolume()); emit totalTimeChanged(); changeState(StoppedState); diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index b73ea44..29ed12e 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -58,7 +58,7 @@ namespace Phonon virtual void doPlay(); virtual void doPause(); virtual void doStop(); - virtual int doSetMmfVolume(int mmfVolume); + virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); virtual void close(); diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index f610b60..ad60046 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -98,17 +98,24 @@ bool Backend::connectNodes(QObject *source, QObject *target) MediaObject *const mediaObject = qobject_cast(source); AudioOutput *const audioOutput = qobject_cast(target); - + VideoWidget *const videoWidget = qobject_cast(target); + bool result = false; if(mediaObject and audioOutput) { TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); - - audioOutput->setVolumeControl(mediaObject); + audioOutput->setVolumeObserver(*mediaObject); result = true; } + if(mediaObject and videoWidget) + { + TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); + // TODO: the actual connection :) + result = true; + } + TRACE_RETURN("%d", result); } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index 737af78..9154984 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -113,19 +113,25 @@ void MMF::DummyPlayer::setNextSource(const MediaSource &) //----------------------------------------------------------------------------- -// AbstractPlayer +// VolumeObserver //----------------------------------------------------------------------------- -void MMF::DummyPlayer::doSetTickInterval(qint32) +void MMF::DummyPlayer::volumeChanged(qreal) { } -bool MMF::DummyPlayer::doSetVolume(qreal) + +//----------------------------------------------------------------------------- +// AbstractPlayer +//----------------------------------------------------------------------------- + +void MMF::DummyPlayer::doSetTickInterval(qint32) { - return true; + } + diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 6a2ad73..5846d88 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -60,9 +60,11 @@ namespace Phonon virtual void setFileSource(const Phonon::MediaSource&, RFile&); virtual void setNextSource(const MediaSource &source); + // VolumeObserver + virtual void volumeChanged(qreal volume); + // AbstractPlayer virtual void doSetTickInterval(qint32 interval); - virtual bool doSetVolume(qreal volume); }; } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 4b5c4f0..bf0356e 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -366,18 +366,14 @@ void MMF::MediaObject::setTransitionTime(qint32 time) m_player->setTransitionTime(time); } + //----------------------------------------------------------------------------- -// VolumeControlInterface +// VolumeObserver //----------------------------------------------------------------------------- -qreal MMF::MediaObject::volume() const -{ - return m_player->volume(); -} - -bool MMF::MediaObject::setVolume(qreal volume) +void MMF::MediaObject::volumeChanged(qreal volume) { - return m_player->setVolume(volume); + m_player->volumeChanged(volume); } diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index a6d932d..2e12b72 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -27,7 +27,7 @@ along with this library. If not, see . // For recognizer #include -#include "volumecontrolinterface.h" +#include "volumeobserver.h" namespace Phonon { @@ -35,13 +35,13 @@ namespace Phonon { class AbstractPlayer; class AudioOutput; - + /** * @short Facade class which wraps MMF client utility instance */ class MediaObject : public QObject , public MediaObjectInterface - , public VolumeControlInterface + , public VolumeObserver { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface) @@ -71,10 +71,9 @@ namespace Phonon virtual void setPrefinishMark(qint32); virtual qint32 transitionTime() const; virtual void setTransitionTime(qint32); - - // VolumeControlInterface - qreal volume() const; - bool setVolume(qreal volume); + + // VolumeObserver + void volumeChanged(qreal volume); Q_SIGNALS: void totalTimeChanged(); @@ -97,15 +96,16 @@ namespace Phonon private: // Audio / video media type recognition - bool m_recognizerOpened; - RApaLsSession m_recognizer; - RFs m_fileServer; + bool m_recognizerOpened; + RApaLsSession m_recognizer; + RFs m_fileServer; // Storing the file handle here to work around KErrInUse error // from MMF player utility OpenFileL functions - RFile m_file; + RFile m_file; - QScopedPointer m_player; + QScopedPointer m_player; + }; } } diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp new file mode 100644 index 0000000..5e32b28 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -0,0 +1,45 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "utils.h" +#include "videooutput.h" + +using namespace Phonon; +using namespace Phonon::MMF; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::VideoOutput::VideoOutput(QWidget* parent) + : QWidget(parent) +{ + +} + +MMF::VideoOutput::~VideoOutput() +{ + +} + + +//----------------------------------------------------------------------------- +// Public API +//----------------------------------------------------------------------------- + diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h new file mode 100644 index 0000000..8b08402 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -0,0 +1,42 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_VIDEOOUTPUT_H +#define PHONON_MMF_VIDEOOUTPUT_H + +#include + +namespace Phonon +{ + namespace MMF + { + class VideoOutput : public QWidget + { + Q_OBJECT + + public: + VideoOutput(QWidget* parent); + ~VideoOutput(); + + private: + + }; + } +} + +#endif diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 45d4f65..3868672 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -33,14 +33,14 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoPlayer::VideoPlayer() : m_widget(new QWidget()) +MMF::VideoPlayer::VideoPlayer() : m_widget(new VideoOutput(NULL)) { construct(); } MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) : AbstractMediaPlayer(player) - , m_widget(new QWidget()) + , m_widget(new VideoOutput(NULL)) // TODO: copy?? { construct(); } @@ -117,7 +117,7 @@ void MMF::VideoPlayer::doStop() m_player->Stop(); } -int MMF::VideoPlayer::doSetMmfVolume(int mmfVolume) +int MMF::VideoPlayer::setDeviceVolume(int mmfVolume) { TRAPD(err, m_player->SetVolumeL(mmfVolume)); return err; @@ -233,7 +233,7 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) if(KErrNone == aError) { - initVolume(m_player->MaxVolume()); + maxVolumeChanged(m_player->MaxVolume()); emit totalTimeChanged(); changeState(StoppedState); diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index b4cfa69..ce3b3ac 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -22,9 +22,9 @@ along with this library. If not, see . #include #include "abstractmediaplayer.h" +#include "videooutput.h" class CVideoPlayerUtility; -class QSymbianControl; namespace Phonon { @@ -51,7 +51,7 @@ namespace Phonon virtual void doPlay(); virtual void doPause(); virtual void doStop(); - virtual int doSetMmfVolume(int mmfVolume); + virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); virtual void close(); @@ -79,7 +79,7 @@ namespace Phonon private: CVideoPlayerUtility* m_player; - QScopedPointer m_widget; + QScopedPointer m_widget; }; } diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 194c885..e08fcea 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -41,7 +41,7 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : QWidget(parent) + : m_widget(new VideoOutput(parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) @@ -149,7 +149,6 @@ void MMF::VideoWidget::setSaturation(qreal saturation) QWidget* MMF::VideoWidget::widget() { - return this; + return m_widget.data(); } - diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 3c33a56..6967f7e 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -22,12 +22,13 @@ along with this library. If not, see . #include #include #include +#include "videooutput.h" namespace Phonon { namespace MMF { - class VideoWidget : public QWidget + class VideoWidget : public QObject , public Phonon::VideoWidgetInterface { Q_OBJECT @@ -53,6 +54,8 @@ namespace Phonon virtual QWidget *widget(); private: + QScopedPointer m_widget; + Phonon::VideoWidget::AspectRatio m_aspectRatio; qreal m_brightness; Phonon::VideoWidget::ScaleMode m_scaleMode; diff --git a/src/3rdparty/phonon/mmf/volumecontrolinterface.h b/src/3rdparty/phonon/mmf/volumecontrolinterface.h deleted file mode 100644 index 7965dd4..0000000 --- a/src/3rdparty/phonon/mmf/volumecontrolinterface.h +++ /dev/null @@ -1,48 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#ifndef PHONON_MMF_VOLUMECONTROLINTERFACE_H -#define PHONON_MMF_VOLUMECONTROLINTERFACE_H - -#include - -namespace Phonon -{ - namespace MMF - { - /** - * Interface used by AudioOutput to pass volume control commands - * back along the audio path to the MediaObject. - */ - class VolumeControlInterface - { - public: - virtual qreal volume() const = 0; - - /** - * Returns true if the volume of the underlying audio stack is - * changed as a result of this call. The return value is used - * by the AudioDevice to determine whether to emit a - * volumeChanged signal. - */ - virtual bool setVolume(qreal volume) = 0; - }; - } -} - -#endif diff --git a/src/3rdparty/phonon/mmf/volumeobserver.h b/src/3rdparty/phonon/mmf/volumeobserver.h new file mode 100644 index 0000000..11ee960 --- /dev/null +++ b/src/3rdparty/phonon/mmf/volumeobserver.h @@ -0,0 +1,40 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_VOLUMEOBSERVER_H +#define PHONON_MMF_VOLUMEOBSERVER_H + +#include + +namespace Phonon +{ + namespace MMF + { + /** + * Interface used by AudioOutput to pass volume control commands + * back along the audio path to the MediaObject. + */ + class VolumeObserver + { + public: + virtual void volumeChanged(qreal volume) = 0; + }; + } +} + +#endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index bb614b4..cc46894 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -31,9 +31,10 @@ HEADERS += \ $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/utils.h \ + $$PHONON_MMF_DIR/videooutput.h \ $$PHONON_MMF_DIR/videoplayer.h \ $$PHONON_MMF_DIR/videowidget.h \ - $$PHONON_MMF_DIR/volumecontrolinterface.h + $$PHONON_MMF_DIR/volumeobserver.h SOURCES += \ $$PHONON_MMF_DIR/abstractplayer.cpp \ @@ -44,6 +45,7 @@ SOURCES += \ $$PHONON_MMF_DIR/dummyplayer.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/utils.cpp \ + $$PHONON_MMF_DIR/videooutput.cpp \ $$PHONON_MMF_DIR/videoplayer.cpp \ $$PHONON_MMF_DIR/videowidget.cpp -- cgit v0.12 From 0761ebabf9f3cf6c968f4ce86e31c323dc8fe9c8 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 21 Aug 2009 12:58:45 +0100 Subject: Implemented connection between MediaOutput and VideoWidget Video is still not visible; need to debug the initialization of the VideoOutput object to determine whether DSA is being aborted. --- src/3rdparty/phonon/mmf/abstractplayer.cpp | 21 +++++- src/3rdparty/phonon/mmf/abstractplayer.h | 18 ++++- src/3rdparty/phonon/mmf/audiooutput.cpp | 10 +-- src/3rdparty/phonon/mmf/audiooutput.h | 2 +- src/3rdparty/phonon/mmf/audioplayer.cpp | 3 +- src/3rdparty/phonon/mmf/backend.cpp | 11 +-- src/3rdparty/phonon/mmf/mediaobject.cpp | 10 +++ src/3rdparty/phonon/mmf/mediaobject.h | 8 ++- src/3rdparty/phonon/mmf/videooutput.cpp | 10 ++- src/3rdparty/phonon/mmf/videoplayer.cpp | 112 +++++++++++++++++++++++++---- src/3rdparty/phonon/mmf/videoplayer.h | 16 ++++- src/3rdparty/phonon/mmf/videowidget.cpp | 10 ++- src/3rdparty/phonon/mmf/videowidget.h | 7 +- 13 files changed, 198 insertions(+), 40 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 870b50f..9027f08 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -28,7 +28,8 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::AbstractPlayer::AbstractPlayer() - : m_tickInterval(DefaultTickInterval) + : m_videoOutput(NULL) + , m_tickInterval(DefaultTickInterval) , m_transitionTime(0) , m_prefinishMark(0) { @@ -36,7 +37,8 @@ MMF::AbstractPlayer::AbstractPlayer() } MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) - : m_tickInterval(player.tickInterval()) + : m_videoOutput(player.m_videoOutput) + , m_tickInterval(player.tickInterval()) , m_transitionTime(player.transitionTime()) , m_prefinishMark(player.prefinishMark()) { @@ -79,3 +81,18 @@ void MMF::AbstractPlayer::setTransitionTime(qint32 time) } +//----------------------------------------------------------------------------- +// Video output +//----------------------------------------------------------------------------- + +void MMF::AbstractPlayer::setVideoOutput(VideoOutput* videoOutput) +{ + m_videoOutput = videoOutput; + videoOutputChanged(); +} + +void MMF::AbstractPlayer::videoOutputChanged() +{ + // Default behaviour is empty - overridden by VideoPlayer +} + diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 4b899d2..1c9ef9b 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -19,19 +19,22 @@ along with this library. If not, see . #ifndef PHONON_MMF_ABSTRACTPLAYER_H #define PHONON_MMF_ABSTRACTPLAYER_H -#include #include #include +#include + #include "volumeobserver.h" +#include "videooutput.h" + class RFile; namespace Phonon { namespace MMF { - class AudioOutput; + class VideoOutput; /** * @short Interface which abstracts from MediaObject the current @@ -81,10 +84,19 @@ namespace Phonon virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; virtual void setNextSource(const Phonon::MediaSource &) = 0; + void setVideoOutput(VideoOutput* videoOutput); + + protected: + virtual void videoOutputChanged(); + private: virtual void doSetTickInterval(qint32 interval) = 0; - private: + protected: + // Not owned + VideoOutput* m_videoOutput; + + private: qint32 m_tickInterval; qint32 m_transitionTime; qint32 m_prefinishMark; diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 13b953d..82b2b82 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -83,10 +83,12 @@ bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) return true; } -void MMF::AudioOutput::setVolumeObserver(VolumeObserver& observer) +void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer) { - Q_ASSERT(!m_observer); - m_observer = &observer; - m_observer->volumeChanged(m_volume); + m_observer = observer; + if(m_observer) + { + m_observer->volumeChanged(m_volume); + } } diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 38623a8..5ecfc0d 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -70,7 +70,7 @@ namespace Phonon /** * Called by backend when nodes are connected. */ - void setVolumeObserver(VolumeObserver& observer); + void setVolumeObserver(VolumeObserver* observer); Q_SIGNALS: void volumeChanged(qreal volume); diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 67ed7a5..d4ae1a8 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -45,7 +45,8 @@ void MMF::AudioPlayer::construct() TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); TRACE_ENTRY_0(); - // TODO: is this the correct way to handle errors in constructing Symbian objects? + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); if(KErrNone != err) { diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index ad60046..5b360f2 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -105,14 +105,14 @@ bool Backend::connectNodes(QObject *source, QObject *target) if(mediaObject and audioOutput) { TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); - audioOutput->setVolumeObserver(*mediaObject); + audioOutput->setVolumeObserver(mediaObject); result = true; } if(mediaObject and videoWidget) { TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); - // TODO: the actual connection :) + mediaObject->setVideoOutput(&videoWidget->videoOutput()); result = true; } @@ -124,11 +124,14 @@ bool Backend::disconnectNodes(QObject *source, QObject *target) TRACE_CONTEXT(Backend::disconnectNodes, EBackend); TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - Q_UNUSED(source); // silence warnings in release builds - Q_UNUSED(target); // silence warnings in release builds + MediaObject *const mediaObject = qobject_cast(source); + AudioOutput *const audioOutput = qobject_cast(target); + VideoWidget *const videoWidget = qobject_cast(target); bool result = true; + // TODO: disconnection + TRACE_RETURN("%d", result); } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index bf0356e..82c671c 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -377,3 +377,13 @@ void MMF::MediaObject::volumeChanged(qreal volume) } +//----------------------------------------------------------------------------- +// Video output +//----------------------------------------------------------------------------- + +void MMF::MediaObject::setVideoOutput(VideoOutput* videoOutput) +{ + m_player->setVideoOutput(videoOutput); +} + + diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 2e12b72..130b7e1 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -33,8 +33,8 @@ namespace Phonon { namespace MMF { - class AbstractPlayer; - class AudioOutput; + class AbstractPlayer; + class VideoOutput; /** * @short Facade class which wraps MMF client utility instance @@ -73,7 +73,9 @@ namespace Phonon virtual void setTransitionTime(qint32); // VolumeObserver - void volumeChanged(qreal volume); + void volumeChanged(qreal volume); + + void setVideoOutput(VideoOutput* videoOutput); Q_SIGNALS: void totalTimeChanged(); diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 5e32b28..3079668 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -30,12 +30,18 @@ using namespace Phonon::MMF; MMF::VideoOutput::VideoOutput(QWidget* parent) : QWidget(parent) { - + TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); + TRACE_ENTRY("parent 0x%08x", parent); + + TRACE_EXIT_0(); } MMF::VideoOutput::~VideoOutput() { - + TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 3868672..4bffce3 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -33,14 +33,19 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoPlayer::VideoPlayer() : m_widget(new VideoOutput(NULL)) +MMF::VideoPlayer::VideoPlayer() + : m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) { construct(); } MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) - , m_widget(new VideoOutput(NULL)) // TODO: copy?? + : AbstractMediaPlayer(player) + , m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) { construct(); } @@ -50,26 +55,26 @@ void MMF::VideoPlayer::construct() TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); TRACE_ENTRY_0(); - CCoeControl* control = m_widget->winId(); - CCoeEnv* coeEnv = control->ControlEnv(); + if(!m_videoOutput) + { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } const TInt priority = 0; const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; - RWsSession& wsSession = coeEnv->WsSession(); - CWsScreenDevice& screenDevice = *(coeEnv->ScreenDevice()); - RDrawableWindow& window = *(control->DrawableWindow()); - const TRect screenRect = control->Rect(); - const TRect clipRect = control->Rect(); - // TODO: is this the correct way to handle errors in constructing Symbian objects? + getNativeWindowSystemHandles(); + + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? TRAPD(err, m_player = CVideoPlayerUtility::NewL ( *this, priority, preference, - wsSession, screenDevice, - window, - screenRect, clipRect + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect ) ); @@ -282,4 +287,83 @@ void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) } +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- +VideoOutput& MMF::VideoPlayer::videoOutput() +{ + TRACE_CONTEXT(VideoPlayer::videoOutput, EVideoInternal); + TRACE("videoOutput 0x%08x dummy 0x%08x", m_videoOutput, m_dummyVideoOutput.data()); + + return m_videoOutput ? *m_videoOutput : *m_dummyVideoOutput; +} + +void MMF::VideoPlayer::videoOutputChanged() +{ + TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); + TRACE_ENTRY_0(); + + // Lazily construct a dummy output if needed here + if(!m_videoOutput and m_dummyVideoOutput.isNull()) + { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } + + getNativeWindowSystemHandles(); + + TRAPD(err, + m_player->SetDisplayWindowL + ( + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect + ) + ); + + if(KErrNone != err) + { + TRACE("SetDisplayWindowL error %d", err); + setError(NormalError); + } + + TRACE_EXIT_0(); +} + +void MMF::VideoPlayer::getNativeWindowSystemHandles() +{ + TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); + + CCoeControl* const control = videoOutput().winId(); + + TRACE("control 0x%08x", control); + TRACE("control isVisible %d", control->IsVisible()); + TRACE("control isDimmed %d", control->IsDimmed()); + TRACE("control hasBorder %d", control->HasBorder()); + TRACE("control position %d %d", + control->Position().iX, control->Position().iY); + TRACE("control rect %d %d - %d %d", + control->Rect().iTl.iX, control->Rect().iTl.iY, + control->Rect().iBr.iX, control->Rect().iBr.iY); + + CCoeEnv* const coeEnv = control->ControlEnv(); + + m_wsSession = &(coeEnv->WsSession()); + + TRACE("session handle %d", m_wsSession->Handle()); + + m_screenDevice = coeEnv->ScreenDevice(); + + TRACE("device srv handle %d", m_screenDevice->WsHandle()); + + m_window = control->DrawableWindow(); + + TRACE("window cli handle %d", m_window->ClientHandle()); + TRACE("window srv handle %d", m_window->WsHandle()); + TRACE("window group %d", m_window->WindowGroupId()); + TRACE("window position %d %d", + m_window->Position().iX, m_window->Position().iY); + + m_windowRect = control->Rect(); + m_clipRect = control->Rect(); +} diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index ce3b3ac..e784812 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -24,7 +24,6 @@ along with this library. If not, see . #include "abstractmediaplayer.h" #include "videooutput.h" -class CVideoPlayerUtility; namespace Phonon { @@ -76,11 +75,24 @@ namespace Phonon private: void construct(); + VideoOutput& videoOutput(); + + // AbstractPlayer + virtual void videoOutputChanged(); + + void getNativeWindowSystemHandles(); private: CVideoPlayerUtility* m_player; - QScopedPointer m_widget; + QScopedPointer m_dummyVideoOutput; + // Not owned + RWsSession* m_wsSession; + CWsScreenDevice* m_screenDevice; + RWindowBase* m_window; + TRect m_windowRect; + TRect m_clipRect; + }; } } diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index e08fcea..7849109 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -17,6 +17,7 @@ along with this library. If not, see . */ #include "utils.h" +#include "videooutput.h" #include "videowidget.h" using namespace Phonon; @@ -41,7 +42,7 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : m_widget(new VideoOutput(parent)) + : m_videoOutput(new VideoOutput(parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) @@ -149,6 +150,11 @@ void MMF::VideoWidget::setSaturation(qreal saturation) QWidget* MMF::VideoWidget::widget() { - return m_widget.data(); + return m_videoOutput.data(); +} + +VideoOutput& MMF::VideoWidget::videoOutput() +{ + return *m_videoOutput; } diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 6967f7e..5c27c7f 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -22,12 +22,13 @@ along with this library. If not, see . #include #include #include -#include "videooutput.h" namespace Phonon { namespace MMF { + class VideoOutput; + class VideoWidget : public QObject , public Phonon::VideoWidgetInterface { @@ -53,8 +54,10 @@ namespace Phonon virtual void setSaturation(qreal saturation); virtual QWidget *widget(); + VideoOutput& videoOutput(); + private: - QScopedPointer m_widget; + QScopedPointer m_videoOutput; Phonon::VideoWidget::AspectRatio m_aspectRatio; qreal m_brightness; -- cgit v0.12 From fdea3d7621493f4945b48e5015ccb11aff0ec16a Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 24 Aug 2009 09:29:34 +0100 Subject: Added spaces to trace output for better alignment --- src/3rdparty/phonon/mmf/utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index ff9eedd..8895a93 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -134,8 +134,8 @@ namespace Phonon #define TRACE_EXIT(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } #define TRACE_RETURN(string, result) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "r Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, result); } return result; #define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code); - #define TRACE_0(string) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); } - #define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } + #define TRACE_0(string) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); } + #define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } #else #define TRACE_CONTEXT(_fn, _cat) #define TRACE_ENTRY_0() -- cgit v0.12 From 00bbc3a5f382e188c8e381054293ca4d214b2da2 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 24 Aug 2009 15:43:16 +0100 Subject: Added TODO list --- src/3rdparty/phonon/mmf/TODO.txt | 58 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/3rdparty/phonon/mmf/TODO.txt diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt new file mode 100644 index 0000000..fc1cfa5 --- /dev/null +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -0,0 +1,58 @@ +TODO list for MMF Phonon backend +-------------------------------- + +The following items are in rough order of priority. + + +* Work out why video is not visible + +* On-target testing +1. Ensure that Phonon front- and back-end libraries are included in the SIS file. +2. Add musicplayer.exe and mediaplayer.exe to the FluidLauncher +3. Ensure that both apps can be launched, and that we can somehow get trace output from the MMF backend onto the PC for analysis. + +* Trace for on-target testing +Do we need to connect up the TRACE_* macros to another logging output (e.g. file / Flogger / UTrace etc)? + +* Fix position slider in audio test app (musicplayer.exe) +The slider is enabled when playing, but does not move and cannot be dragged. This means that we can't easily test seeking. + +* Fix track list in audio test app (musicplayer.exe) +After loading a single clip, we get two entries in the list box: the first is blank and the second has the name of the clip we just loaded. However, clicking on the first (blank) opens the clip, while clicking on the second (correct filename) has no effect. + +* Implement audio effects + +* Support for network streaming playback +The main question here is how best to implement the MIME type detection for streams. The OpenUrlL functions only take a URL, whereas the corresponding OpenFileL functions have overloads for filenames and for open RFile handles. This is because files support random access whereas streams do not. A naieve approach to MIME type detection for streams is as follows; is there a more efficient approach? + 1. Open network connection + 2. Download header + 3. Detect MIME type and create AbstractMediaPlayer instance + 4. Close network connection + 5. Pass URL to MMF client utility, which will then re-open the stream + +* Performance analysis +Compare video frame rate obtained using default S60 media player and Qt demo apps + +* Implement MMF::Backend::availableMimeTypes + +* Implement MMF::Backend::disconnectNodes +This should probably be left for now, particularly until audio effects have been implemented. This is because the node connection mechanism may need to be refactored slightly once we start building up longer graphs (e.g. MediaObject -> Effect -> Effect -> AudioOutput). + +* Namespace macros +For consistency with other backends, the code should be wrapped in QT_BEGIN_NAMESPACE / QT_END_NAMESPACE macros. + + + + + +* Fix mediaplayer.exe UI +On Windows, the mediaplayer UI has a drop-down menu (for loading clips etc), start/stop buttons, a position slider and a volume slider. On S60, we just get a blank screen and two blank softkeys, so no clip can be loaded (unless main.cpp is hacked by adding a hard-coded path). + + + + + + + + + -- cgit v0.12 From d4efe766d35aa8150f67f67cd16cfc00ba4f9723 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 24 Aug 2009 17:37:38 +0100 Subject: Fixed problem which caused duplicate entries to appear in media player file list. This was due to the backend returning an incorrect initial state value. Phonon::MMF::AbstractMediaPlayer::GroundState is now correctly mapped to Phonon::LoadingState. (Previously it mapped to Phonon::StoppedState). --- src/3rdparty/phonon/mmf/TODO.txt | 14 -------------- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 2 +- src/3rdparty/phonon/mmf/dummyplayer.cpp | 2 +- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index fc1cfa5..d866aea 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -17,9 +17,6 @@ Do we need to connect up the TRACE_* macros to another logging output (e.g. file * Fix position slider in audio test app (musicplayer.exe) The slider is enabled when playing, but does not move and cannot be dragged. This means that we can't easily test seeking. -* Fix track list in audio test app (musicplayer.exe) -After loading a single clip, we get two entries in the list box: the first is blank and the second has the name of the clip we just loaded. However, clicking on the first (blank) opens the clip, while clicking on the second (correct filename) has no effect. - * Implement audio effects * Support for network streaming playback @@ -41,18 +38,7 @@ This should probably be left for now, particularly until audio effects have been * Namespace macros For consistency with other backends, the code should be wrapped in QT_BEGIN_NAMESPACE / QT_END_NAMESPACE macros. - - - - * Fix mediaplayer.exe UI On Windows, the mediaplayer UI has a drop-down menu (for loading clips etc), start/stop buttons, a position slider and a volume slider. On S60, we just get a blank screen and two blank softkeys, so no clip can be loaded (unless main.cpp is hacked by adding a hard-coded path). - - - - - - - diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 6342f37..ccb94c4 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -374,7 +374,7 @@ Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) { const Phonon::State phononState = GroundState == state - ? Phonon::StoppedState + ? Phonon::LoadingState : static_cast(state); return phononState; diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index 9154984..d9e836d 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -73,7 +73,7 @@ bool MMF::DummyPlayer::isSeekable() const Phonon::State MMF::DummyPlayer::state() const { - return Phonon::StoppedState; + return Phonon::LoadingState; } qint64 MMF::DummyPlayer::currentTime() const -- cgit v0.12 From ca8f0c669142d27091873c108ffe21b4285e3087 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 25 Aug 2009 08:46:08 +0100 Subject: Implemented Backend::availableMimeTypes --- src/3rdparty/phonon/mmf/TODO.txt | 2 -- src/3rdparty/phonon/mmf/backend.cpp | 39 +++++++++++++++++++++++++++++++-- src/3rdparty/phonon/mmf/defs.h | 8 ++++++- src/3rdparty/phonon/mmf/mediaobject.cpp | 26 +++------------------- src/3rdparty/phonon/mmf/mediaobject.h | 5 ++--- src/3rdparty/phonon/mmf/utils.cpp | 21 ++++++++++++++++++ src/3rdparty/phonon/mmf/utils.h | 14 +++++++++--- 7 files changed, 81 insertions(+), 34 deletions(-) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index d866aea..4b140dd 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -30,8 +30,6 @@ The main question here is how best to implement the MIME type detection for stre * Performance analysis Compare video frame rate obtained using default S60 media player and Qt demo apps -* Implement MMF::Backend::availableMimeTypes - * Implement MMF::Backend::disconnectNodes This should probably be left for now, particularly until audio effects have been implemented. This is because the node connection mechanism may need to be refactored slightly once we start building up longer graphs (e.g. MediaObject -> Effect -> Effect -> AudioOutput). diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 5b360f2..010562e 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -19,6 +19,10 @@ along with this library. If not, see . #include #include +#include // for RApaLsSession +#include // for CDataTypeArray +#include // for TDataType + #include "backend.h" #include "audiooutput.h" #include "mediaobject.h" @@ -140,11 +144,42 @@ bool Backend::endConnectionChange(QSet) return true; } +void getAvailableMimeTypesL(QStringList& result) +{ + RApaLsSession apaSession; + User::LeaveIfError(apaSession.Connect()); + CleanupClosePushL(apaSession); + + static const TInt DataTypeArrayGranularity = 8; + CDataTypeArray* array = new (ELeave) CDataTypeArray(DataTypeArrayGranularity); + CleanupStack::PushL(array); + + apaSession.GetSupportedDataTypesL(*array); + + for(TInt i=0; iCount(); ++i) + { + const TPtrC mimeType = array->At(i).Des(); + const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType); + if(MediaTypeAudio == mediaType or MediaTypeVideo == mediaType) + { + result.append(qt_TDesC2QString(mimeType)); + } + } + + CleanupStack::PopAndDestroy(2); // apaSession, array +} + QStringList Backend::availableMimeTypes() const { - // TODO: query MMF for available MIME types + QStringList result; + + // There is no way to return an error from this function, so we just + // have to trap and ignore exceptions... + TRAP_IGNORE(getAvailableMimeTypesL(result)); - return QStringList(); + result.sort(); + + return result; } Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend); diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index d31cabb..0f2f31f 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -27,7 +27,13 @@ namespace Phonon { static const qint32 DefaultTickInterval = 20; static const qreal InitialVolume = 0.5; - + + enum MediaType + { + MediaTypeUnknown, + MediaTypeAudio, + MediaTypeVideo + }; } } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 82c671c..fec5441 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -17,6 +17,7 @@ along with this library. If not, see . */ #include "audioplayer.h" +#include "defs.h" #include "dummyplayer.h" #include "mediaobject.h" #include "utils.h" @@ -95,28 +96,7 @@ bool MMF::MediaObject::openRecognizer() return true; } -const TInt KMimePrefixLength = 6; // either "audio/" or "video/" -_LIT(KMimePrefixAudio, "audio/"); -_LIT(KMimePrefixVideo, "video/"); - -MMF::MediaObject::MediaType MMF::MediaObject::mimeTypeToMediaType(const TDesC& mimeType) -{ - MediaType result = MediaTypeUnknown; - - if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) - { - result = MediaTypeAudio; - } - else if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) - { - result = MediaTypeVideo; - } - - return result; -} - - -MMF::MediaObject::MediaType MMF::MediaObject::fileMediaType +MMF::MediaType MMF::MediaObject::fileMediaType (const QString& fileName) { TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal); @@ -137,7 +117,7 @@ MMF::MediaObject::MediaType MMF::MediaObject::fileMediaType if(KErrNone == err) { const TPtrC mimeType = recognizerResult.iDataType.Des(); - result = mimeTypeToMediaType(mimeType); + result = Utils::mimeTypeToMediaType(mimeType); } else { diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 130b7e1..99223c3 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -27,6 +27,7 @@ along with this library. If not, see . // For recognizer #include +#include "defs.h" #include "volumeobserver.h" namespace Phonon @@ -88,9 +89,7 @@ namespace Phonon void createPlayer(const MediaSource &source); bool openRecognizer(); - // Audio / video media type recognition - enum MediaType { MediaTypeUnknown, MediaTypeAudio, MediaTypeVideo }; - MediaType mimeTypeToMediaType(const TDesC& mimeType); + // Audio / video media type recognition MediaType fileMediaType(const QString& fileName); // TODO: urlMediaType function diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index ada4800..2655962 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -44,3 +44,24 @@ QHBufC MMF::Utils::symbianFilename(const QString& qtFilename) return result; } + + +static const TInt KMimePrefixLength = 6; // either "audio/" or "video/" +_LIT(KMimePrefixAudio, "audio/"); +_LIT(KMimePrefixVideo, "video/"); + +MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) +{ + MediaType result = MediaTypeUnknown; + + if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) + { + result = MediaTypeAudio; + } + else if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) + { + result = MediaTypeVideo; + } + + return result; +} diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index 8895a93..2df7e48 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -22,6 +22,8 @@ along with this library. If not, see . #include #include // for RDebug +#include "defs.h" + namespace Phonon { namespace MMF @@ -30,12 +32,12 @@ namespace Phonon * Panic codes for fatal errors */ enum PanicCode - { + { InvalidStatePanic = 1, InvalidMediaTypePanic = 2, InvalidBackendInterfaceClass = 3 - }; - + }; + namespace Utils { /** @@ -51,6 +53,12 @@ namespace Phonon * determined. */ QHBufC symbianFilename(const QString& qtFilename); + + /** + * Determines whether the provided MIME type is an audio or video + * type. If it is neither, the function returns MediaTypeUnknown. + */ + MediaType mimeTypeToMediaType(const TDesC& mimeType); } /** -- cgit v0.12 From 028298f77b7a8cb1c15e68f3135dcb36fcaeadd6 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 25 Aug 2009 09:02:03 +0100 Subject: Removed 'fix mediaplayer.exe UI' from the TODO list --- src/3rdparty/phonon/mmf/TODO.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 4b140dd..1910079 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -36,7 +36,4 @@ This should probably be left for now, particularly until audio effects have been * Namespace macros For consistency with other backends, the code should be wrapped in QT_BEGIN_NAMESPACE / QT_END_NAMESPACE macros. -* Fix mediaplayer.exe UI -On Windows, the mediaplayer UI has a drop-down menu (for loading clips etc), start/stop buttons, a position slider and a volume slider. On S60, we just get a blank screen and two blank softkeys, so no clip can be loaded (unless main.cpp is hacked by adding a hard-coded path). - -- cgit v0.12 From 4135d048eb7999927dc39a73df138922d4ba6278 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 25 Aug 2009 09:14:39 +0100 Subject: Added TODO item for fixing up code indenting / formatting --- src/3rdparty/phonon/mmf/TODO.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 1910079..a9707e0 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -36,4 +36,9 @@ This should probably be left for now, particularly until audio effects have been * Namespace macros For consistency with other backends, the code should be wrapped in QT_BEGIN_NAMESPACE / QT_END_NAMESPACE macros. +* Fix code layout +My editor was set to use tabs for indenting, rather than the Qt standard of 4 spaces. So we can either: + 1. Do "s/\t/ /g" - which will just fix the indenting + 2. Use http://astyle.sourceforge.net/: + astyle --indent=spaces=4 --brackets=linux --indent-labels --pad=oper --unpad=paren --one-line=keep-statements --convert-tabs --indent-preprocessor --recursive ./ -- cgit v0.12 From 9bcdcc33e1abd202a5b0ec156ff22624bd21740c Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 25 Aug 2009 14:18:57 +0100 Subject: Modified video player to call updateGeometry on video display widget; having no effect at present --- src/3rdparty/phonon/mmf/videooutput.cpp | 77 ++++++++++++++++++++++++++++++++- src/3rdparty/phonon/mmf/videooutput.h | 11 +++++ src/3rdparty/phonon/mmf/videoplayer.cpp | 69 +++++++++++++++++------------ src/3rdparty/phonon/mmf/videoplayer.h | 5 +++ 4 files changed, 132 insertions(+), 30 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 3079668..828697c 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -19,10 +19,13 @@ along with this library. If not, see . #include "utils.h" #include "videooutput.h" +#include +#include +#include + using namespace Phonon; using namespace Phonon::MMF; - //----------------------------------------------------------------------------- // Constructor / destructor //----------------------------------------------------------------------------- @@ -33,6 +36,11 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); TRACE_ENTRY("parent 0x%08x", parent); + setPalette(QPalette(Qt::black)); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + setAutoFillBackground(false); + TRACE_EXIT_0(); } @@ -44,8 +52,73 @@ MMF::VideoOutput::~VideoOutput() TRACE_EXIT_0(); } +void MMF::VideoOutput::setFrameSize(const QSize& frameSize) +{ + TRACE_CONTEXT(VideoOutput::setFrameSize, EVideoInternal); + TRACE("oldSize %d %d newSize %d %d", + m_frameSize.width(), m_frameSize.height(), + frameSize.width(), frameSize.height()); + + if(frameSize != m_frameSize) + { + m_frameSize = frameSize; + updateGeometry(); + } +} + //----------------------------------------------------------------------------- -// Public API +// QWidget //----------------------------------------------------------------------------- +QSize MMF::VideoOutput::sizeHint() const +{ + if(m_frameSize.isNull()) + { + // TODO: replace this with a more sensible default + return QSize(320, 240); + } + else + { + return m_frameSize; + } +} + +void MMF::VideoOutput::paintEvent(QPaintEvent* event) +{ + TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); + TRACE("rect %d %d - %d %d", + event->rect().left(), event->rect().top(), + event->rect().right(), event->rect().bottom()); + TRACE("regions %d", event->region().numRects()); + TRACE("type %d", event->type()); +} + +QPaintEngine* MMF::VideoOutput::paintEngine() const +{ + return NULL; +} + +void MMF::VideoOutput::resizeEvent(QResizeEvent* event) +{ + TRACE_CONTEXT(VideoOutput::resizeEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldSize().width(), event->oldSize().height(), + event->size().width(), event->size().height()); +} + +void MMF::VideoOutput::moveEvent(QMoveEvent* event) +{ + TRACE_CONTEXT(VideoOutput::moveEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldPos().x(), event->oldPos().y(), + event->pos().x(), event->pos().y()); +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + + + diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 8b08402..d6cfc6f 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -33,7 +33,18 @@ namespace Phonon VideoOutput(QWidget* parent); ~VideoOutput(); + void setFrameSize(const QSize& size); + + protected: + // QWidget + QSize sizeHint() const; + void paintEvent(QPaintEvent* event); + void resizeEvent(QResizeEvent* event); + void moveEvent(QMoveEvent* event); + QPaintEngine* paintEngine() const; + private: + QSize m_frameSize; }; } diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 4bffce3..1e9522c 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -37,6 +37,7 @@ MMF::VideoPlayer::VideoPlayer() : m_wsSession(NULL) , m_screenDevice(NULL) , m_window(NULL) + , m_totalTime(0) { construct(); } @@ -46,6 +47,7 @@ MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) , m_wsSession(NULL) , m_screenDevice(NULL) , m_window(NULL) + , m_totalTime(0) { construct(); } @@ -187,21 +189,7 @@ qint64 MMF::VideoPlayer::currentTime() const qint64 MMF::VideoPlayer::totalTime() const { - TRACE_CONTEXT(VideoPlayer::totalTime, EVideoApi); - - qint64 result = 0; - TRAPD(err, result = toMilliSeconds(m_player->DurationL())); - - if(KErrNone != err) - { - TRACE("DurationL error %d", err); - - // If we don't cast away constness here, we simply have to ignore - // the error. - const_cast(this)->setError(NormalError); - } - - return result; + return m_totalTime; } @@ -235,23 +223,41 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) TRACE_ENTRY("state %d error %d", state(), aError); __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - - if(KErrNone == aError) + + TRAPD(err, doPrepareCompleteL(aError)); + + if(KErrNone == err) { maxVolumeChanged(m_player->MaxVolume()); + + videoOutput().setFrameSize(m_frameSize); - emit totalTimeChanged(); - changeState(StoppedState); + emit totalTimeChanged(); + changeState(StoppedState); } - else + else { - // TODO: set different error states according to value of aError? - setError(NormalError); + // TODO: set different error states according to value of aError? + setError(NormalError); } TRACE_EXIT_0(); } +void MMF::VideoPlayer::doPrepareCompleteL(TInt aError) +{ + User::LeaveIfError(aError); + + // Get frame size + TSize size; + m_player->VideoFrameSizeL(size); + m_frameSize = QSize(size.iWidth, size.iHeight); + + // Get duration + m_totalTime = toMilliSeconds(m_player->DurationL()); +} + + void MMF::VideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) { TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); @@ -310,6 +316,8 @@ void MMF::VideoPlayer::videoOutputChanged() m_dummyVideoOutput.reset(new VideoOutput(NULL)); } + videoOutput().setFrameSize(m_frameSize); + getNativeWindowSystemHandles(); TRAPD(err, @@ -334,7 +342,8 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() { TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); - CCoeControl* const control = videoOutput().winId(); + VideoOutput& output = videoOutput(); + CCoeControl* const control = output.winId(); TRACE("control 0x%08x", control); TRACE("control isVisible %d", control->IsVisible()); @@ -350,20 +359,24 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() m_wsSession = &(coeEnv->WsSession()); - TRACE("session handle %d", m_wsSession->Handle()); + TRACE("session handle 0x%08x", m_wsSession->Handle()); m_screenDevice = coeEnv->ScreenDevice(); - TRACE("device srv handle %d", m_screenDevice->WsHandle()); + TRACE("device srv handle 0x%08x", m_screenDevice->WsHandle()); m_window = control->DrawableWindow(); - TRACE("window cli handle %d", m_window->ClientHandle()); - TRACE("window srv handle %d", m_window->WsHandle()); + TRACE("window cli handle 0x%08x", m_window->ClientHandle()); + TRACE("window srv handle 0x%08x", m_window->WsHandle()); TRACE("window group %d", m_window->WindowGroupId()); TRACE("window position %d %d", m_window->Position().iX, m_window->Position().iY); + TRACE("window abs_pos %d %d", + m_window->AbsPosition().iX, m_window->AbsPosition().iY); + TRACE("window size %d %d", + m_window->Size().iWidth, m_window->Size().iHeight); m_windowRect = control->Rect(); - m_clipRect = control->Rect(); + m_clipRect = m_windowRect; } diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index e784812..8b5c467 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -77,6 +77,8 @@ namespace Phonon void construct(); VideoOutput& videoOutput(); + void doPrepareCompleteL(TInt aError); + // AbstractPlayer virtual void videoOutputChanged(); @@ -93,6 +95,9 @@ namespace Phonon TRect m_windowRect; TRect m_clipRect; + QSize m_frameSize; + qint64 m_totalTime; + }; } } -- cgit v0.12 From f3defb60f21cfe2456ace1148afcce43112f9c51 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 25 Aug 2009 15:19:11 +0100 Subject: Added some missing signals in MediaObject; fixed seek slider in musicplayer.exe --- src/3rdparty/phonon/mmf/TODO.txt | 3 --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 20 ++++++++++++++++ src/3rdparty/phonon/mmf/abstractmediaplayer.h | 5 +++- src/3rdparty/phonon/mmf/audioplayer.cpp | 17 +++++--------- src/3rdparty/phonon/mmf/audioplayer.h | 4 ++-- src/3rdparty/phonon/mmf/defs.h | 2 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 22 +++++++++++++++++- src/3rdparty/phonon/mmf/mediaobject.h | 13 ++++++++++- src/3rdparty/phonon/mmf/videooutput.cpp | 20 +++++++++------- src/3rdparty/phonon/mmf/videoplayer.cpp | 31 +++++++++++-------------- src/3rdparty/phonon/mmf/videoplayer.h | 4 ++-- 11 files changed, 94 insertions(+), 47 deletions(-) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index a9707e0..84dd52d 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -14,9 +14,6 @@ The following items are in rough order of priority. * Trace for on-target testing Do we need to connect up the TRACE_* macros to another logging output (e.g. file / Flogger / UTrace etc)? -* Fix position slider in audio test app (musicplayer.exe) -The slider is enabled when playing, but does not move and cannot be dragged. This means that we can't easily test seeking. - * Implement audio effects * Support for network streaming playback diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index ccb94c4..114ba13 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -169,6 +169,26 @@ void MMF::AbstractMediaPlayer::stop() TRACE_EXIT("state %d", m_state); } +void MMF::AbstractMediaPlayer::seek(qint64 ms) +{ + TRACE_CONTEXT(AbstractMediaPlayer::seek, EAudioApi); + TRACE_ENTRY("state %d pos %Ld", state(), ms); + + // TODO: put a state guard in here + + const bool tickTimerWasRunning = m_tickTimer->isActive(); + stopTickTimer(); + + doSeek(ms); + + if(tickTimerWasRunning) + { + startTickTimer(); + } + + TRACE_EXIT_0(); +} + bool MMF::AbstractMediaPlayer::isSeekable() const { return true; diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 58aca84..7f53a2d 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -50,6 +50,7 @@ namespace Phonon virtual void play(); virtual void pause(); virtual void stop(); + virtual void seek(qint64 milliseconds); virtual bool isSeekable() const; virtual Phonon::ErrorType errorType() const; virtual QString errorString() const; @@ -69,12 +70,14 @@ namespace Phonon virtual void doPlay() = 0; virtual void doPause() = 0; virtual void doStop() = 0; + virtual void doSeek(qint64 pos) = 0; virtual int setDeviceVolume(int mmfVolume) = 0; virtual int openFile(RFile& file) = 0; virtual void close() = 0; protected: - void startTickTimer(); + bool tickTimerRunning() const; + void startTickTimer(); void stopTickTimer(); void maxVolumeChanged(int maxVolume); diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index d4ae1a8..41fedb4 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -85,6 +85,11 @@ void MMF::AudioPlayer::doStop() m_player->Stop(); } +void MMF::AudioPlayer::doSeek(qint64 ms) +{ + m_player->SetPosition(TTimeIntervalMicroSeconds(ms * 1000)); +} + int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) { return m_player->SetVolume(mmfVolume); @@ -113,16 +118,6 @@ void MMF::AudioPlayer::close() m_player->Close(); } -void MMF::AudioPlayer::seek(qint64 ms) -{ - TRACE_CONTEXT(AudioPlayer::seek, EAudioApi); - TRACE_ENTRY("state %d pos %Ld", state(), ms); - - m_player->SetPosition(TTimeIntervalMicroSeconds(ms)); - - TRACE_EXIT_0(); -} - bool MMF::AudioPlayer::hasVideo() const { return false; @@ -180,7 +175,7 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, { maxVolumeChanged(m_player->MaxVolume()); - emit totalTimeChanged(); + emit totalTimeChanged(totalTime()); changeState(StoppedState); } else diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 29ed12e..8d29547 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -58,12 +58,12 @@ namespace Phonon virtual void doPlay(); virtual void doPause(); virtual void doStop(); + virtual void doSeek(qint64 milliseconds); virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); virtual void close(); // MediaObjectInterface - virtual void seek(qint64 milliseconds); virtual bool hasVideo() const; virtual qint64 currentTime() const; virtual qint64 totalTime() const; @@ -85,7 +85,7 @@ namespace Phonon #endif Q_SIGNALS: - void totalTimeChanged(); + void totalTimeChanged(qint64 length); void finished(); private: diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 0f2f31f..b377ee5 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -25,7 +25,7 @@ namespace Phonon { namespace MMF { - static const qint32 DefaultTickInterval = 20; + static const qint32 DefaultTickInterval = 10; static const qreal InitialVolume = 0.5; enum MediaType diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index fec5441..396f658 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -156,6 +156,11 @@ void MMF::MediaObject::stop() void MMF::MediaObject::seek(qint64 ms) { m_player->seek(ms); + + if(state() == PausedState or state() == PlayingState) + { + emit tick(currentTime()); + } } qint32 MMF::MediaObject::tickInterval() const @@ -215,6 +220,8 @@ void MMF::MediaObject::setSource(const MediaSource &source) // This is a hack to work around KErrInUse from MMF client utility // OpenFileL calls m_player->setFileSource(source, m_file); + + emit currentSourceChanged(source); } void MMF::MediaObject::createPlayer(const MediaSource &source) @@ -227,6 +234,9 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) AbstractPlayer* oldPlayer = m_player.data(); + const bool oldPlayerHasVideo = oldPlayer->hasVideo(); + const bool oldPlayerSeekable = oldPlayer->isSeekable(); + // Determine media type switch(source.type()) { @@ -313,11 +323,21 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) m_player.reset(newPlayer); - connect(m_player.data(), SIGNAL(totalTimeChanged()), SIGNAL(totalTimeChanged())); + connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64))); connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); + if(oldPlayerHasVideo != hasVideo()) + { + emit hasVideoChanged(hasVideo()); + } + + if(oldPlayerSeekable != isSeekable()) + { + emit seekableChanged(isSeekable()); + } + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 99223c3..f62f4f5 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -79,7 +79,18 @@ namespace Phonon void setVideoOutput(VideoOutput* videoOutput); Q_SIGNALS: - void totalTimeChanged(); + void totalTimeChanged(qint64 length); + void hasVideoChanged(bool hasVideo); + void seekableChanged(bool seekable); + // TODO: emit bufferStatus from MediaObject + void bufferStatus(int); + // TODO: emit aboutToFinish from MediaObject + void aboutToFinish(); + // TODO: emit prefinishMarkReached from MediaObject + void prefinishMarkReached(qint32); + // TODO: emit metaDataChanged from MediaObject + void metaDataChanged(const QMultiMap& metaData); + void currentSourceChanged(const MediaSource& source); void stateChanged(Phonon::State oldState, Phonon::State newState); void finished(); diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 828697c..30bf531 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -73,15 +73,18 @@ void MMF::VideoOutput::setFrameSize(const QSize& frameSize) QSize MMF::VideoOutput::sizeHint() const { - if(m_frameSize.isNull()) - { - // TODO: replace this with a more sensible default - return QSize(320, 240); - } - else + TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); + + // TODO: replace this with a more sensible default + QSize result(320, 240); + + if(!m_frameSize.isNull()) { - return m_frameSize; + result = m_frameSize; } + + TRACE(" result %d %d", result.width(), result.height()); + return result; } void MMF::VideoOutput::paintEvent(QPaintEvent* event) @@ -96,7 +99,8 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) QPaintEngine* MMF::VideoOutput::paintEngine() const { - return NULL; + TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); + TRACE_RETURN("0x%08x", NULL); } void MMF::VideoOutput::resizeEvent(QResizeEvent* event) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 1e9522c..002c6f6 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -124,6 +124,19 @@ void MMF::VideoPlayer::doStop() m_player->Stop(); } +void MMF::VideoPlayer::doSeek(qint64 ms) +{ + TRACE_CONTEXT(VideoPlayer::doSeek, EVideoApi); + + TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms * 1000))); + + if(KErrNone != err) + { + TRACE("SetPositionL error %d", err); + setError(NormalError); + } +} + int MMF::VideoPlayer::setDeviceVolume(int mmfVolume) { TRAPD(err, m_player->SetVolumeL(mmfVolume)); @@ -141,22 +154,6 @@ void MMF::VideoPlayer::close() m_player->Close(); } -void MMF::VideoPlayer::seek(qint64 ms) -{ - TRACE_CONTEXT(VideoPlayer::seek, EVideoApi); - TRACE_ENTRY("state %d pos %Ld", state(), ms); - - TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms))); - - if(KErrNone != err) - { - TRACE("SetPositionL error %d", err); - setError(NormalError); - } - - TRACE_EXIT_0(); -} - bool MMF::VideoPlayer::hasVideo() const { return true; @@ -232,7 +229,7 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) videoOutput().setFrameSize(m_frameSize); - emit totalTimeChanged(); + emit totalTimeChanged(totalTime()); changeState(StoppedState); } else diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index 8b5c467..bacec0b 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -50,12 +50,12 @@ namespace Phonon virtual void doPlay(); virtual void doPause(); virtual void doStop(); + virtual void doSeek(qint64 milliseconds); virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); virtual void close(); // MediaObjectInterface - virtual void seek(qint64 milliseconds); virtual bool hasVideo() const; virtual qint64 currentTime() const; virtual qint64 totalTime() const; @@ -68,7 +68,7 @@ namespace Phonon virtual void MvpuoEvent(const TMMFEvent &aEvent); Q_SIGNALS: - void totalTimeChanged(); + void totalTimeChanged(qint64 length); void stateChanged(Phonon::State oldState, Phonon::State newState); void finished(); -- cgit v0.12 From 55dcdac49aeaf9a7af9d420140e7629682fa4573 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 25 Aug 2009 18:10:58 +0100 Subject: Made video playback visible using a couple of hacks These hacks, which are enabled using macros in defs.h, are: PHONON_MMF_HARD_CODE_VIDEO_RECT VideoPlayer should obtain the screen rectangle into which video rendering will occur, using the CoeControl associated with the video widget (i.e. the VideoOutput object). However, this control always has co-ordinates (relative to its parent) of (0,0)-(100,30), regardless of whether updateGeometry() and show() are called on the widget. So, this macro just hard-codes the screen rectangle to a value which works when the breakfast.mp4 clip is used for testing. PHONON_MMF_EXPLICITLY_SHOW_VIDEO_WIDGET In order that the video region does not overwrite the slider and buttons below it, the parent widget of the VideoObject instance must be appropriately re-sized. Debugging showed that both the parent and grandparent of VideoObject are in fact invisible at the time playback begins, so for now we just manually call show() on the grandparent. Clearly both of these are only temporary measures, for use until the underlying cause of the problem has been determined. --- src/3rdparty/phonon/mmf/defs.h | 15 +++++++ src/3rdparty/phonon/mmf/mediaobject.h | 2 +- src/3rdparty/phonon/mmf/videooutput.cpp | 69 ++++++++++++++++++++++++++++++++- src/3rdparty/phonon/mmf/videooutput.h | 9 ++++- src/3rdparty/phonon/mmf/videoplayer.cpp | 23 ++++++++++- src/3rdparty/phonon/mmf/videowidget.h | 4 +- 6 files changed, 115 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index b377ee5..adf2882 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -21,6 +21,21 @@ along with this library. If not, see . #include +// The following macros are for switching on / off various bits of code, +// in order to debug the current problems with video visibility. + +// If this is defined, then VideoOutput is essentially just a typedef for +// QWidget +#define PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + +// Use hard-coded rectangle coordinates, rather than using CCoeControl +// rect, i.e. QWidget::winId()->Rect() +#define PHONON_MMF_HARD_CODE_VIDEO_RECT + +// If this is defined, show() is called on the grandparent of the widget +// on which video will be rendered. +#define PHONON_MMF_EXPLICITLY_SHOW_VIDEO_WIDGET + namespace Phonon { namespace MMF diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index f62f4f5..5bbca96 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -81,7 +81,7 @@ namespace Phonon Q_SIGNALS: void totalTimeChanged(qint64 length); void hasVideoChanged(bool hasVideo); - void seekableChanged(bool seekable); + void seekableChanged(bool seekable); // TODO: emit bufferStatus from MediaObject void bufferStatus(int); // TODO: emit aboutToFinish from MediaObject diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 30bf531..482d944 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -35,15 +35,63 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) { TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); TRACE_ENTRY("parent 0x%08x", parent); - + +#ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET setPalette(QPalette(Qt::black)); setAttribute(Qt::WA_OpaquePaintEvent, true); setAttribute(Qt::WA_NoSystemBackground, true); setAutoFillBackground(false); +#endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + + dump(); TRACE_EXIT_0(); } +// Debugging video visibility +void VideoOutput::dump() +{ + TRACE_CONTEXT(VideoOutput::dump, EVideoInternal); + TRACE_ENTRY_0(); + + TRACE("dumpObjectInfo this 0x%08x", this); + this->dumpObjectInfo(); + + TRACE_0("Traversing up object tree ..."); + QObject* node = this; + QObject* root = this; + while(node) + { + QWidget* widget = qobject_cast(node); + const bool visible = widget ? widget->isVisible() : false; + TRACE("node 0x%08x widget 0x%08x visible %d", node, widget, visible); + + root = node; + node = node->parent(); + } + + TRACE("dumpObjectInfo root 0x%08x", root); + root->dumpObjectInfo(); + TRACE_0("+ dumpObjectTree"); + root->dumpObjectTree(); + TRACE_0("- dumpObjectTree"); + + TRACE("isVisible %d", isVisible()); + TRACE("pos %d %d", x(), y()); + TRACE("size %d %d", size().width(), size().height()); + TRACE("maxSize %d %d", maximumWidth(), maximumHeight()); + TRACE("sizeHint %d %d", sizeHint().width(), sizeHint().height()); + + QWidget& parentWidget = *qobject_cast(parent()); + TRACE("parent.isVisible %d", parentWidget.isVisible()); + TRACE("parent.pos %d %d", parentWidget.x(), parentWidget.y()); + TRACE("parent.size %d %d", parentWidget.size().width(), parentWidget.size().height()); + TRACE("parent.maxSize %d %d", parentWidget.maximumWidth(), parentWidget.maximumHeight()); + TRACE("parent.sizeHint %d %d", parentWidget.sizeHint().width(), parentWidget.sizeHint().height()); + + TRACE_EXIT_0(); +} + MMF::VideoOutput::~VideoOutput() { TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); @@ -54,6 +102,9 @@ MMF::VideoOutput::~VideoOutput() void MMF::VideoOutput::setFrameSize(const QSize& frameSize) { +#ifdef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + Q_UNUSED(frameSize); +#else TRACE_CONTEXT(VideoOutput::setFrameSize, EVideoInternal); TRACE("oldSize %d %d newSize %d %d", m_frameSize.width(), m_frameSize.height(), @@ -64,6 +115,7 @@ void MMF::VideoOutput::setFrameSize(const QSize& frameSize) m_frameSize = frameSize; updateGeometry(); } +#endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET } @@ -71,6 +123,8 @@ void MMF::VideoOutput::setFrameSize(const QSize& frameSize) // QWidget //----------------------------------------------------------------------------- +#ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + QSize MMF::VideoOutput::sizeHint() const { TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); @@ -95,12 +149,17 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) event->rect().right(), event->rect().bottom()); TRACE("regions %d", event->region().numRects()); TRACE("type %d", event->type()); + + QWidget::paintEvent(event); } QPaintEngine* MMF::VideoOutput::paintEngine() const { TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); - TRACE_RETURN("0x%08x", NULL); + + QPaintEngine* const engine = QWidget::paintEngine(); + + TRACE_RETURN("0x%08x", engine); } void MMF::VideoOutput::resizeEvent(QResizeEvent* event) @@ -109,6 +168,8 @@ void MMF::VideoOutput::resizeEvent(QResizeEvent* event) TRACE("%d %d -> %d %d", event->oldSize().width(), event->oldSize().height(), event->size().width(), event->size().height()); + + QWidget::resizeEvent(event); } void MMF::VideoOutput::moveEvent(QMoveEvent* event) @@ -117,8 +178,12 @@ void MMF::VideoOutput::moveEvent(QMoveEvent* event) TRACE("%d %d -> %d %d", event->oldPos().x(), event->oldPos().y(), event->pos().x(), event->pos().y()); + + QWidget::moveEvent(event); } +#endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + //----------------------------------------------------------------------------- // Private functions diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index d6cfc6f..39ebe00 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -20,6 +20,7 @@ along with this library. If not, see . #define PHONON_MMF_VIDEOOUTPUT_H #include +#include "defs.h" namespace Phonon { @@ -36,12 +37,18 @@ namespace Phonon void setFrameSize(const QSize& size); protected: - // QWidget + #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + // Override QWidget functions QSize sizeHint() const; void paintEvent(QPaintEvent* event); void resizeEvent(QResizeEvent* event); void moveEvent(QMoveEvent* event); QPaintEngine* paintEngine() const; + #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + + // Debugging video visibility + public: + void dump(); private: QSize m_frameSize; diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 002c6f6..584a4f0 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -103,7 +103,7 @@ MMF::VideoPlayer::~VideoPlayer() //----------------------------------------------------------------------------- void MMF::VideoPlayer::doPlay() -{ +{ m_player->Play(); } @@ -228,6 +228,20 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) maxVolumeChanged(m_player->MaxVolume()); videoOutput().setFrameSize(m_frameSize); + + // Debugging video visibility + videoOutput().dump(); + +#ifdef PHONON_MMF_EXPLICITLY_SHOW_VIDEO_WIDGET + // HACK: why do we need to explicitly show() the grandparent...? + static_cast(videoOutput().parent()->parent())->show(); + videoOutput().updateGeometry(); + videoOutput().update(); +#endif + + videoOutput().dump(); + + videoOutputChanged(); emit totalTimeChanged(totalTime()); changeState(StoppedState); @@ -374,6 +388,13 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() TRACE("window size %d %d", m_window->Size().iWidth, m_window->Size().iHeight); +#ifdef PHONON_MMF_HARD_CODE_VIDEO_RECT + // HACK: why isn't control->Rect updated following a call to + // updateGeometry on the parent widget? + m_windowRect = TRect(0,100,320,250); +#else m_windowRect = control->Rect(); +#endif + m_clipRect = m_windowRect; } diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 5c27c7f..e8fc603 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -57,8 +57,8 @@ namespace Phonon VideoOutput& videoOutput(); private: - QScopedPointer m_videoOutput; - + QScopedPointer m_widget; + Phonon::VideoWidget::AspectRatio m_aspectRatio; qreal m_brightness; Phonon::VideoWidget::ScaleMode m_scaleMode; -- cgit v0.12 From 8076ee4317333112a529b9df5e7ab0a44e101d16 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 26 Aug 2009 09:38:13 +0100 Subject: Added a bit more tracing for debugging video visibility --- src/3rdparty/phonon/mmf/defs.h | 26 ++++++++++++++------------ src/3rdparty/phonon/mmf/videooutput.cpp | 3 ++- src/3rdparty/phonon/mmf/videoplayer.cpp | 6 +++++- src/3rdparty/phonon/mmf/videowidget.cpp | 8 ++++---- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index adf2882..0a9a683 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -25,8 +25,10 @@ along with this library. If not, see . // in order to debug the current problems with video visibility. // If this is defined, then VideoOutput is essentially just a typedef for -// QWidget -#define PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET +// QWidget. This is to allow us to test whether the QWidget function +// overrides present in VideoOutput (e.g. sizeHint, paintEvent etc) may +// be the cause of the visibility problems. +//#define PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET // Use hard-coded rectangle coordinates, rather than using CCoeControl // rect, i.e. QWidget::winId()->Rect() @@ -40,16 +42,16 @@ namespace Phonon { namespace MMF { - static const qint32 DefaultTickInterval = 10; - static const qreal InitialVolume = 0.5; - - enum MediaType - { - MediaTypeUnknown, - MediaTypeAudio, - MediaTypeVideo - }; + static const qint32 DefaultTickInterval = 10; + static const qreal InitialVolume = 0.5; + + enum MediaType + { + MediaTypeUnknown, + MediaTypeAudio, + MediaTypeVideo + }; } } -#endif +#endif // PHONON_MMF_DEFS_H diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 482d944..2652844 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -64,7 +64,8 @@ void VideoOutput::dump() { QWidget* widget = qobject_cast(node); const bool visible = widget ? widget->isVisible() : false; - TRACE("node 0x%08x widget 0x%08x visible %d", node, widget, visible); + const QHBufC name(node->objectName()); + TRACE("node 0x%08x name %S widget 0x%08x visible %d", node, name.data(), widget, visible); root = node; node = node->parent(); diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 584a4f0..419c83c 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -234,8 +234,12 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) #ifdef PHONON_MMF_EXPLICITLY_SHOW_VIDEO_WIDGET // HACK: why do we need to explicitly show() the grandparent...? - static_cast(videoOutput().parent()->parent())->show(); + QWidget* grandparent = static_cast(videoOutput().parent()->parent()); + TRACE("Calling grandparent[0x%08x]->show()", grandparent); + grandparent->show(); + TRACE_0("Calling videoOutput().updateGeometry()"); videoOutput().updateGeometry(); + TRACE_0("Calling videoOutput().update()"); videoOutput().update(); #endif diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 7849109..515f04e 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -42,7 +42,7 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : m_videoOutput(new VideoOutput(parent)) + : m_widget(new VideoOutput(parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) @@ -51,7 +51,7 @@ MMF::VideoWidget::VideoWidget(QWidget* parent) , m_saturation(DefaultSaturation) { TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); - TRACE_ENTRY_0(); + TRACE_ENTRY_0(); TRACE_EXIT_0(); } @@ -150,11 +150,11 @@ void MMF::VideoWidget::setSaturation(qreal saturation) QWidget* MMF::VideoWidget::widget() { - return m_videoOutput.data(); + return m_widget.data(); } VideoOutput& MMF::VideoWidget::videoOutput() { - return *m_videoOutput; + return *static_cast(widget()); } -- cgit v0.12 From 0f893c8e1147d759b81cbd9ad121d7715c333bf6 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 26 Aug 2009 10:13:46 +0100 Subject: Updated the TODO list --- src/3rdparty/phonon/mmf/TODO.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 84dd52d..49e8074 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -6,6 +6,15 @@ The following items are in rough order of priority. * Work out why video is not visible +* Write a test app which allows the following: + - Dragging of the video widget + - Resizing of the video widget + - Dragging of other widgets on top of / underneath the video widget +These will allow the video widget's moveEvent / resizeEvent implementations to be tested. + +* Write / modify a test app which allows audio effects to be enabled / disabled. + - In the simplest case, this could just be a command-line app which allows effects to be specified using flags. + * On-target testing 1. Ensure that Phonon front- and back-end libraries are included in the SIS file. 2. Add musicplayer.exe and mediaplayer.exe to the FluidLauncher @@ -23,6 +32,7 @@ The main question here is how best to implement the MIME type detection for stre 3. Detect MIME type and create AbstractMediaPlayer instance 4. Close network connection 5. Pass URL to MMF client utility, which will then re-open the stream +An alternative approach is to always create a VideoPlayer when passed an RTSP URL, and then modify VideoPlayer::hasVideo to check CVideoPlayerUtility::VideoMimeTypeL before returning. This way, we would always use CVideoPlayerUtility for RTSP streaming, whether the source is audio or video. Well-behaved client apps, however, should check MediaObject::hasVideo before creating the UI - and therefore the VideoWidget would only be connected if the source is actually a video stream. * Performance analysis Compare video frame rate obtained using default S60 media player and Qt demo apps -- cgit v0.12 From 520780e1655a4855dbfc1ababd1925686a20960d Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 26 Aug 2009 11:30:44 +0200 Subject: Rename mediaplayer to qmediaplayer, and make it an example on Symbian. We rename mediaplayer to qmediaplayer to avoid it clashing with Symbian's default media player. We also install it as an example, in order to be able to show case Phonon. --- demos/embedded/fluidlauncher/config_s60/config.xml | 7 +++++++ demos/embedded/fluidlauncher/fluidlauncher.pro | 14 ++++++++++++-- demos/mediaplayer/mediaplayer.pro | 2 +- demos/qtdemo/xml/examples.xml | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index 95e96bd..acd14cb 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -14,6 +14,13 @@ + + + + + + + diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index 3eff37b..892a4ba 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -92,9 +92,14 @@ symbian { $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/fridgemagnets_reg.rsc \ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/drilldown_reg.rsc \ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/softkeys_reg.rsc + contains(QT_CONFIG, webkit) { reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/anomaly_reg.rsc - } + } + + contains(QT_CONFIG, phonon) { + reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/qmediaplayer_reg.rsc + } reg_resource.path = $$REG_RESOURCE_IMPORT_DIR @@ -110,11 +115,16 @@ symbian { $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/desktopservices.rsc \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/fridgemagnets.rsc \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/drilldown.rsc \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/softkeys.rsc + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/softkeys.rsc \ + contains(QT_CONFIG, webkit) { resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.rsc } + contains(QT_CONFIG, phonon) { + resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/qmediaplayer.rsc + } + resource.path = $$APP_RESOURCE_DIR mifs.sources = \ diff --git a/demos/mediaplayer/mediaplayer.pro b/demos/mediaplayer/mediaplayer.pro index ef07a3f..8e38c0c 100644 --- a/demos/mediaplayer/mediaplayer.pro +++ b/demos/mediaplayer/mediaplayer.pro @@ -3,7 +3,7 @@ ###################################################################### TEMPLATE = app -TARGET = +TARGET = qmediaplayer DEPENDPATH += . build src ui QT += phonon diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml index 6c8ddb0..ed04198 100644 --- a/demos/qtdemo/xml/examples.xml +++ b/demos/qtdemo/xml/examples.xml @@ -16,7 +16,7 @@ - + -- cgit v0.12 From 95a4f173b9ad6aa3b0009d4431bcc31e991a54d1 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 26 Aug 2009 12:03:48 +0100 Subject: Removed over-riding signal declaration from VideoPlayer. This was causing the stateChanged signal not to propagate up to the Phonon client. In the case of the mediaplayer demo, this causes the app not to show() the ancestor of the VideoWidget, resulting in the layout not being updated when the clip has been loaded. This means that the hack to explicitly call show() on this ancestor from the backend has been removed. Now the layout is correctly updated, but the size of VideoOutput::winId()->Rect() is still incorrect, so the hack to hard-code the screen rectangle passed to CVideoPlayerUtility is left in place. --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 2 +- src/3rdparty/phonon/mmf/defs.h | 4 ---- src/3rdparty/phonon/mmf/mediaobject.cpp | 12 ++++++------ src/3rdparty/phonon/mmf/videoplayer.cpp | 13 ------------- src/3rdparty/phonon/mmf/videoplayer.h | 2 -- 5 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 114ba13..7849d87 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -425,7 +425,7 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) and m_playPending ) { - TRACE_0("Play was called while loading; starting playback now"); + TRACE_0("play was called while loading; starting playback now"); m_playPending = false; play(); } diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 0a9a683..be8401d 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -34,10 +34,6 @@ along with this library. If not, see . // rect, i.e. QWidget::winId()->Rect() #define PHONON_MMF_HARD_CODE_VIDEO_RECT -// If this is defined, show() is called on the grandparent of the widget -// on which video will be rendered. -#define PHONON_MMF_EXPLICITLY_SHOW_VIDEO_WIDGET - namespace Phonon { namespace MMF diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 396f658..04b7dc7 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -322,12 +322,7 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) } m_player.reset(newPlayer); - - connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64))); - connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); - connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); - connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); - + if(oldPlayerHasVideo != hasVideo()) { emit hasVideoChanged(hasVideo()); @@ -338,6 +333,11 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) emit seekableChanged(isSeekable()); } + connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64))); + connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); + connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); + connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 419c83c..75db551 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -231,19 +231,6 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) // Debugging video visibility videoOutput().dump(); - -#ifdef PHONON_MMF_EXPLICITLY_SHOW_VIDEO_WIDGET - // HACK: why do we need to explicitly show() the grandparent...? - QWidget* grandparent = static_cast(videoOutput().parent()->parent()); - TRACE("Calling grandparent[0x%08x]->show()", grandparent); - grandparent->show(); - TRACE_0("Calling videoOutput().updateGeometry()"); - videoOutput().updateGeometry(); - TRACE_0("Calling videoOutput().update()"); - videoOutput().update(); -#endif - - videoOutput().dump(); videoOutputChanged(); diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index bacec0b..5d6baa4 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -69,8 +69,6 @@ namespace Phonon Q_SIGNALS: void totalTimeChanged(qint64 length); - void stateChanged(Phonon::State oldState, - Phonon::State newState); void finished(); private: -- cgit v0.12 From 7104201d87b965a01c2983cd44ef2e0f465030bf Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 26 Aug 2009 12:57:47 +0100 Subject: Added VideoOutputObserver, to propagate screen region updates back to VideoPlayer --- src/3rdparty/phonon/mmf/defs.h | 2 +- src/3rdparty/phonon/mmf/videooutput.cpp | 22 +++++++++- src/3rdparty/phonon/mmf/videooutput.h | 6 +++ src/3rdparty/phonon/mmf/videooutputobserver.h | 40 ++++++++++++++++++ src/3rdparty/phonon/mmf/videoplayer.cpp | 60 +++++++++++++++++---------- src/3rdparty/phonon/mmf/videoplayer.h | 5 +++ src/plugins/phonon/mmf/mmf.pro | 1 + 7 files changed, 112 insertions(+), 24 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/videooutputobserver.h diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index be8401d..90c647f 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -32,7 +32,7 @@ along with this library. If not, see . // Use hard-coded rectangle coordinates, rather than using CCoeControl // rect, i.e. QWidget::winId()->Rect() -#define PHONON_MMF_HARD_CODE_VIDEO_RECT +//#define PHONON_MMF_HARD_CODE_VIDEO_RECT namespace Phonon { diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 2652844..fd8a80b 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -18,6 +18,7 @@ along with this library. If not, see . #include "utils.h" #include "videooutput.h" +#include "videooutputobserver.h" #include #include @@ -32,13 +33,14 @@ using namespace Phonon::MMF; MMF::VideoOutput::VideoOutput(QWidget* parent) : QWidget(parent) + , m_observer(NULL) { TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); TRACE_ENTRY("parent 0x%08x", parent); #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET setPalette(QPalette(Qt::black)); - setAttribute(Qt::WA_OpaquePaintEvent, true); + //setAttribute(Qt::WA_OpaquePaintEvent, true); setAttribute(Qt::WA_NoSystemBackground, true); setAutoFillBackground(false); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET @@ -119,6 +121,14 @@ void MMF::VideoOutput::setFrameSize(const QSize& frameSize) #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET } +void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) +{ + TRACE_CONTEXT(VideoOutput::setObserver, EVideoInternal); + TRACE("observer 0x%08x", observer); + + m_observer = observer; +} + //----------------------------------------------------------------------------- // QWidget @@ -171,6 +181,11 @@ void MMF::VideoOutput::resizeEvent(QResizeEvent* event) event->size().width(), event->size().height()); QWidget::resizeEvent(event); + + if(m_observer) + { + m_observer->videoOutputRegionChanged(); + } } void MMF::VideoOutput::moveEvent(QMoveEvent* event) @@ -181,6 +196,11 @@ void MMF::VideoOutput::moveEvent(QMoveEvent* event) event->pos().x(), event->pos().y()); QWidget::moveEvent(event); + + if(m_observer) + { + m_observer->videoOutputRegionChanged(); + } } #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 39ebe00..90709aa 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -26,6 +26,8 @@ namespace Phonon { namespace MMF { + class VideoOutputObserver; + class VideoOutput : public QWidget { Q_OBJECT @@ -36,6 +38,8 @@ namespace Phonon void setFrameSize(const QSize& size); + void setObserver(VideoOutputObserver* observer); + protected: #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET // Override QWidget functions @@ -53,6 +57,8 @@ namespace Phonon private: QSize m_frameSize; + // Not owned + VideoOutputObserver* m_observer; }; } } diff --git a/src/3rdparty/phonon/mmf/videooutputobserver.h b/src/3rdparty/phonon/mmf/videooutputobserver.h new file mode 100644 index 0000000..30fb3e0 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutputobserver.h @@ -0,0 +1,40 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_VIDEOOUTPUTOBSERVER_H +#define PHONON_MMF_VIDEOOUTPUTOBSERVER_H + +#include + +namespace Phonon +{ + namespace MMF + { + /** + * Interface via which VideoOutput notifies VideoPlayer of changes to the + * video output screen region. + */ + class VideoOutputObserver + { + public: + virtual void videoOutputRegionChanged() = 0; + }; + } +} + +#endif diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 75db551..fd8425d 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -62,6 +62,8 @@ void MMF::VideoPlayer::construct() m_dummyVideoOutput.reset(new VideoOutput(NULL)); } + videoOutput().setObserver(this); + const TInt priority = 0; const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; @@ -227,12 +229,7 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) { maxVolumeChanged(m_player->MaxVolume()); - videoOutput().setFrameSize(m_frameSize); - - // Debugging video visibility - videoOutput().dump(); - - videoOutputChanged(); + videoOutput().setFrameSize(m_frameSize); emit totalTimeChanged(totalTime()); changeState(StoppedState); @@ -296,6 +293,38 @@ void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) //----------------------------------------------------------------------------- +// VideoOutputObserver +//----------------------------------------------------------------------------- + +void MMF::VideoPlayer::videoOutputRegionChanged() +{ + TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); + TRACE_ENTRY_0(); + + videoOutput().dump(); + + getNativeWindowSystemHandles(); + + TRAPD(err, + m_player->SetDisplayWindowL + ( + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect + ) + ); + + if(KErrNone != err) + { + TRACE("SetDisplayWindowL error %d", err); + setError(NormalError); + } + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- // Private functions //----------------------------------------------------------------------------- @@ -318,24 +347,11 @@ void MMF::VideoPlayer::videoOutputChanged() m_dummyVideoOutput.reset(new VideoOutput(NULL)); } - videoOutput().setFrameSize(m_frameSize); - - getNativeWindowSystemHandles(); + videoOutput().setObserver(this); - TRAPD(err, - m_player->SetDisplayWindowL - ( - *m_wsSession, *m_screenDevice, - *m_window, - m_windowRect, m_clipRect - ) - ); + videoOutput().setFrameSize(m_frameSize); - if(KErrNone != err) - { - TRACE("SetDisplayWindowL error %d", err); - setError(NormalError); - } + videoOutputRegionChanged(); TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index 5d6baa4..a6f069f 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -23,6 +23,7 @@ along with this library. If not, see . #include "abstractmediaplayer.h" #include "videooutput.h" +#include "videooutputobserver.h" namespace Phonon @@ -38,6 +39,7 @@ namespace Phonon */ class VideoPlayer : public AbstractMediaPlayer , public MVideoPlayerUtilityObserver + , public VideoOutputObserver { Q_OBJECT @@ -67,6 +69,9 @@ namespace Phonon virtual void MvpuoPlayComplete(TInt aError); virtual void MvpuoEvent(const TMMFEvent &aEvent); + // VideoOutputObserver + virtual void videoOutputRegionChanged(); + Q_SIGNALS: void totalTimeChanged(qint64 length); void finished(); diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index cc46894..1d9910b 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -32,6 +32,7 @@ HEADERS += \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/utils.h \ $$PHONON_MMF_DIR/videooutput.h \ + $$PHONON_MMF_DIR/videooutputobserver.h \ $$PHONON_MMF_DIR/videoplayer.h \ $$PHONON_MMF_DIR/videowidget.h \ $$PHONON_MMF_DIR/volumeobserver.h -- cgit v0.12 From 13d35977cb4fa6a94b5cc8b3ebd230c7ef41acc9 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 26 Aug 2009 13:01:15 +0100 Subject: Wrapped VideoOuput::dump() in a macro for easier removal later on --- src/3rdparty/phonon/mmf/defs.h | 2 ++ src/3rdparty/phonon/mmf/videooutput.cpp | 5 ++++- src/3rdparty/phonon/mmf/videooutput.h | 3 ++- src/3rdparty/phonon/mmf/videoplayer.cpp | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 90c647f..12b8785 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -34,6 +34,8 @@ along with this library. If not, see . // rect, i.e. QWidget::winId()->Rect() //#define PHONON_MMF_HARD_CODE_VIDEO_RECT +#define PHONON_MMF_DEBUG_VIDEO_OUTPUT + namespace Phonon { namespace MMF diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index fd8a80b..171565b 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -45,12 +45,14 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) setAutoFillBackground(false); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET +#ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT dump(); +#endif TRACE_EXIT_0(); } -// Debugging video visibility +#ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT void VideoOutput::dump() { TRACE_CONTEXT(VideoOutput::dump, EVideoInternal); @@ -94,6 +96,7 @@ void VideoOutput::dump() TRACE_EXIT_0(); } +#endif // PHONON_MMF_DEBUG_VIDEO_OUTPUT MMF::VideoOutput::~VideoOutput() { diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 90709aa..6d1e4a0 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -50,9 +50,10 @@ namespace Phonon QPaintEngine* paintEngine() const; #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - // Debugging video visibility +#ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT public: void dump(); +#endif private: QSize m_frameSize; diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index fd8425d..df922ec 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -301,7 +301,9 @@ void MMF::VideoPlayer::videoOutputRegionChanged() TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); TRACE_ENTRY_0(); +#ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT videoOutput().dump(); +#endif getNativeWindowSystemHandles(); -- cgit v0.12 From b43b58fc1f56df12459fcfa2a586760ab78f9c89 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 08:50:55 +0100 Subject: Added more tracing to VideoPlayer --- src/3rdparty/phonon/mmf/videoplayer.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index df922ec..546f761 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -365,36 +365,37 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() VideoOutput& output = videoOutput(); CCoeControl* const control = output.winId(); - TRACE("control 0x%08x", control); - TRACE("control isVisible %d", control->IsVisible()); - TRACE("control isDimmed %d", control->IsDimmed()); - TRACE("control hasBorder %d", control->HasBorder()); - TRACE("control position %d %d", + TRACE("control 0x%08x", control); + TRACE("control IsVisible %d", control->IsVisible()); + TRACE("control IsDimmed %d", control->IsDimmed()); + TRACE("control HasBorder %d", control->HasBorder()); + TRACE("control Position %d %d", control->Position().iX, control->Position().iY); - TRACE("control rect %d %d - %d %d", + TRACE("control Rect %d %d - %d %d", control->Rect().iTl.iX, control->Rect().iTl.iY, control->Rect().iBr.iX, control->Rect().iBr.iY); + TRACE("control OwnsWindow %d", control->OwnsWindow()); CCoeEnv* const coeEnv = control->ControlEnv(); m_wsSession = &(coeEnv->WsSession()); - TRACE("session handle 0x%08x", m_wsSession->Handle()); + TRACE("session Handle 0x%08x", m_wsSession->Handle()); m_screenDevice = coeEnv->ScreenDevice(); - TRACE("device srv handle 0x%08x", m_screenDevice->WsHandle()); + TRACE("device WsHandle 0x%08x", m_screenDevice->WsHandle()); m_window = control->DrawableWindow(); - TRACE("window cli handle 0x%08x", m_window->ClientHandle()); - TRACE("window srv handle 0x%08x", m_window->WsHandle()); - TRACE("window group %d", m_window->WindowGroupId()); - TRACE("window position %d %d", + TRACE("window ClientHandle 0x%08x", m_window->ClientHandle()); + TRACE("window WsHandle 0x%08x", m_window->WsHandle()); + TRACE("window WindowGroupId %d", m_window->WindowGroupId()); + TRACE("window Position %d %d", m_window->Position().iX, m_window->Position().iY); - TRACE("window abs_pos %d %d", + TRACE("window AbsPosition %d %d", m_window->AbsPosition().iX, m_window->AbsPosition().iY); - TRACE("window size %d %d", + TRACE("window Size %d %d", m_window->Size().iWidth, m_window->Size().iHeight); #ifdef PHONON_MMF_HARD_CODE_VIDEO_RECT -- cgit v0.12 From 1794e95cfb8ccb77bc90c3395ddb0636ae12e8ce Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 13:27:15 +0100 Subject: Wrapped code using QT_BEGIN/END_NAMESPACE macros --- src/3rdparty/phonon/mmf/TODO.txt | 6 ------ src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 6 +++--- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 4 ++++ src/3rdparty/phonon/mmf/abstractplayer.cpp | 5 +++++ src/3rdparty/phonon/mmf/abstractplayer.h | 4 ++++ src/3rdparty/phonon/mmf/audiooutput.cpp | 4 ++++ src/3rdparty/phonon/mmf/audiooutput.h | 4 ++++ src/3rdparty/phonon/mmf/audioplayer.cpp | 16 +++------------- src/3rdparty/phonon/mmf/audioplayer.h | 4 ++++ src/3rdparty/phonon/mmf/backend.cpp | 4 ++++ src/3rdparty/phonon/mmf/backend.h | 4 ++++ src/3rdparty/phonon/mmf/defs.h | 4 ++++ src/3rdparty/phonon/mmf/dummyplayer.cpp | 5 +++-- src/3rdparty/phonon/mmf/dummyplayer.h | 4 ++++ src/3rdparty/phonon/mmf/mediaobject.cpp | 3 +++ src/3rdparty/phonon/mmf/mediaobject.h | 4 ++++ src/3rdparty/phonon/mmf/utils.cpp | 6 ++++++ src/3rdparty/phonon/mmf/utils.h | 4 ++++ src/3rdparty/phonon/mmf/videooutput.cpp | 18 ++++++++++++------ src/3rdparty/phonon/mmf/videooutput.h | 7 +++++-- src/3rdparty/phonon/mmf/videooutputobserver.h | 4 ++++ src/3rdparty/phonon/mmf/videoplayer.cpp | 6 ++++++ src/3rdparty/phonon/mmf/videoplayer.h | 3 +++ src/3rdparty/phonon/mmf/videowidget.cpp | 8 +++++++- src/3rdparty/phonon/mmf/videowidget.h | 4 ++++ src/3rdparty/phonon/mmf/volumeobserver.h | 4 ++++ 26 files changed, 112 insertions(+), 33 deletions(-) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 49e8074..7f20793 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -12,9 +12,6 @@ The following items are in rough order of priority. - Dragging of other widgets on top of / underneath the video widget These will allow the video widget's moveEvent / resizeEvent implementations to be tested. -* Write / modify a test app which allows audio effects to be enabled / disabled. - - In the simplest case, this could just be a command-line app which allows effects to be specified using flags. - * On-target testing 1. Ensure that Phonon front- and back-end libraries are included in the SIS file. 2. Add musicplayer.exe and mediaplayer.exe to the FluidLauncher @@ -40,9 +37,6 @@ Compare video frame rate obtained using default S60 media player and Qt demo app * Implement MMF::Backend::disconnectNodes This should probably be left for now, particularly until audio effects have been implemented. This is because the node connection mechanism may need to be refactored slightly once we start building up longer graphs (e.g. MediaObject -> Effect -> Effect -> AudioOutput). -* Namespace macros -For consistency with other backends, the code should be wrapped in QT_BEGIN_NAMESPACE / QT_END_NAMESPACE macros. - * Fix code layout My editor was set to use tabs for indenting, rather than the Qt standard of 4 spaces. So we can either: 1. Do "s/\t/ /g" - which will just fix the indenting diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 7849d87..7883709 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -20,6 +20,8 @@ along with this library. If not, see . #include "defs.h" #include "utils.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -459,7 +461,5 @@ void MMF::AbstractMediaPlayer::tick() emit tick(currentTime()); } - - - +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 7f53a2d..51935a3 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -26,6 +26,8 @@ along with this library. If not, see . class RFile; +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -154,5 +156,7 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 9027f08..328ab37 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -19,6 +19,8 @@ along with this library. If not, see . #include "abstractplayer.h" #include "defs.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -96,3 +98,6 @@ void MMF::AbstractPlayer::videoOutputChanged() // Default behaviour is empty - overridden by VideoPlayer } + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 1c9ef9b..399cd5d 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -30,6 +30,8 @@ along with this library. If not, see . class RFile; +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -105,5 +107,7 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 82b2b82..099c899 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -23,6 +23,8 @@ along with this library. If not, see . #include "utils.h" #include "volumeobserver.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -92,3 +94,5 @@ void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer) } } + +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 5ecfc0d..ab90c44 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -21,6 +21,8 @@ along with this library. If not, see . #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -85,4 +87,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 41fedb4..50048c8 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -21,6 +21,8 @@ along with this library. If not, see . #include "audioplayer.h" #include "utils.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -242,17 +244,5 @@ void MMF::AudioPlayer::MaloLoadingComplete() #endif // QT_PHONON_MMF_AUDIO_DRM - - - - - - - - - - - - - +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 8d29547..cdb6cb9 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -34,6 +34,8 @@ typedef CMdaAudioPlayerUtility CPlayerType; typedef MMdaAudioPlayerCallback MPlayerObserverType; #endif +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -102,4 +104,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 010562e..236ef28 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -29,6 +29,8 @@ along with this library. If not, see . #include "utils.h" #include "videowidget.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -184,3 +186,5 @@ QStringList Backend::availableMimeTypes() const Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend); +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index 4fff204..b448187 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -22,6 +22,8 @@ along with this library. If not, see . #include #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -49,4 +51,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 12b8785..37a25d1 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -36,6 +36,8 @@ along with this library. If not, see . #define PHONON_MMF_DEBUG_VIDEO_OUTPUT +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -52,4 +54,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif // PHONON_MMF_DEFS_H diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index d9e836d..dc7f8d1 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -18,6 +18,8 @@ along with this library. If not, see . #include "dummyplayer.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -132,6 +134,5 @@ void MMF::DummyPlayer::doSetTickInterval(qint32) } - - +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 5846d88..12e3bd8 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -21,6 +21,8 @@ along with this library. If not, see . #include "abstractplayer.h" +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -70,4 +72,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 04b7dc7..91ed859 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -23,6 +23,7 @@ along with this library. If not, see . #include "utils.h" #include "videoplayer.h" +QT_BEGIN_NAMESPACE using namespace Phonon; using namespace Phonon::MMF; @@ -387,3 +388,5 @@ void MMF::MediaObject::setVideoOutput(VideoOutput* videoOutput) } +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 5bbca96..d9c32ce 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -30,6 +30,8 @@ along with this library. If not, see . #include "defs.h" #include "volumeobserver.h" +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -122,4 +124,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index 2655962..eb367f6 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -19,6 +19,8 @@ along with this library. If not, see . #include "utils.h" #include +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -65,3 +67,7 @@ MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) return result; } + + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index 2df7e48..e2b5e59 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -24,6 +24,8 @@ along with this library. If not, see . #include "defs.h" +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -158,4 +160,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 171565b..6534b7b 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -24,6 +24,8 @@ along with this library. If not, see . #include #include +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -87,12 +89,15 @@ void VideoOutput::dump() TRACE("maxSize %d %d", maximumWidth(), maximumHeight()); TRACE("sizeHint %d %d", sizeHint().width(), sizeHint().height()); - QWidget& parentWidget = *qobject_cast(parent()); - TRACE("parent.isVisible %d", parentWidget.isVisible()); - TRACE("parent.pos %d %d", parentWidget.x(), parentWidget.y()); - TRACE("parent.size %d %d", parentWidget.size().width(), parentWidget.size().height()); - TRACE("parent.maxSize %d %d", parentWidget.maximumWidth(), parentWidget.maximumHeight()); - TRACE("parent.sizeHint %d %d", parentWidget.sizeHint().width(), parentWidget.sizeHint().height()); + QWidget* parentWidget = qobject_cast(parent()); + if(parentWidget) + { + TRACE("parent.isVisible %d", parentWidget->isVisible()); + TRACE("parent.pos %d %d", parentWidget->x(), parentWidget->y()); + TRACE("parent.size %d %d", parentWidget->size().width(), parentWidget->size().height()); + TRACE("parent.maxSize %d %d", parentWidget->maximumWidth(), parentWidget->maximumHeight()); + TRACE("parent.sizeHint %d %d", parentWidget->sizeHint().width(), parentWidget->sizeHint().height()); + } TRACE_EXIT_0(); } @@ -214,4 +219,5 @@ void MMF::VideoOutput::moveEvent(QMoveEvent* event) //----------------------------------------------------------------------------- +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 6d1e4a0..b8e22ca 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -22,6 +22,8 @@ along with this library. If not, see . #include #include "defs.h" +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -33,11 +35,10 @@ namespace Phonon Q_OBJECT public: - VideoOutput(QWidget* parent); + explicit VideoOutput(QWidget* parent); ~VideoOutput(); void setFrameSize(const QSize& size); - void setObserver(VideoOutputObserver* observer); protected: @@ -64,4 +65,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/videooutputobserver.h b/src/3rdparty/phonon/mmf/videooutputobserver.h index 30fb3e0..d38ff87 100644 --- a/src/3rdparty/phonon/mmf/videooutputobserver.h +++ b/src/3rdparty/phonon/mmf/videooutputobserver.h @@ -21,6 +21,8 @@ along with this library. If not, see . #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -37,4 +39,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 546f761..ba06379 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -26,6 +26,8 @@ along with this library. If not, see . #include "videoplayer.h" #include "utils.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -408,3 +410,7 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() m_clipRect = m_windowRect; } + + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index a6f069f..f8b1486 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -25,6 +25,7 @@ along with this library. If not, see . #include "videooutput.h" #include "videooutputobserver.h" +QT_BEGIN_NAMESPACE namespace Phonon { @@ -105,4 +106,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 515f04e..ae94e5e 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -20,6 +20,8 @@ along with this library. If not, see . #include "videooutput.h" #include "videowidget.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -42,7 +44,8 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : m_widget(new VideoOutput(parent)) + : QObject(parent) + , m_widget(new VideoOutput(parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) @@ -158,3 +161,6 @@ VideoOutput& MMF::VideoWidget::videoOutput() return *static_cast(widget()); } + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index e8fc603..799121b 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -23,6 +23,8 @@ along with this library. If not, see . #include #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -70,4 +72,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/volumeobserver.h b/src/3rdparty/phonon/mmf/volumeobserver.h index 11ee960..d6717cba 100644 --- a/src/3rdparty/phonon/mmf/volumeobserver.h +++ b/src/3rdparty/phonon/mmf/volumeobserver.h @@ -21,6 +21,8 @@ along with this library. If not, see . #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -37,4 +39,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif -- cgit v0.12 From 29c5a03e374aa5d1a7ea289108fb5f7548cbf997 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 13:51:35 +0100 Subject: Reformatted code to comply with Qt style --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 347 ++++++++++---------- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 247 +++++++------- src/3rdparty/phonon/mmf/abstractplayer.cpp | 24 +- src/3rdparty/phonon/mmf/abstractplayer.h | 142 ++++----- src/3rdparty/phonon/mmf/audiooutput.cpp | 33 +- src/3rdparty/phonon/mmf/audiooutput.h | 120 +++---- src/3rdparty/phonon/mmf/audioplayer.cpp | 127 ++++---- src/3rdparty/phonon/mmf/audioplayer.h | 114 +++---- src/3rdparty/phonon/mmf/backend.cpp | 177 +++++------ src/3rdparty/phonon/mmf/backend.h | 46 +-- src/3rdparty/phonon/mmf/defs.h | 27 +- src/3rdparty/phonon/mmf/dummyplayer.cpp | 6 +- src/3rdparty/phonon/mmf/dummyplayer.h | 90 +++--- src/3rdparty/phonon/mmf/mediaobject.cpp | 343 +++++++++----------- src/3rdparty/phonon/mmf/mediaobject.h | 176 +++++----- src/3rdparty/phonon/mmf/utils.cpp | 24 +- src/3rdparty/phonon/mmf/utils.h | 250 +++++++-------- src/3rdparty/phonon/mmf/videooutput.cpp | 126 ++++---- src/3rdparty/phonon/mmf/videooutput.h | 68 ++-- src/3rdparty/phonon/mmf/videooutputobserver.h | 24 +- src/3rdparty/phonon/mmf/videoplayer.cpp | 407 ++++++++++++------------ src/3rdparty/phonon/mmf/videoplayer.h | 150 ++++----- src/3rdparty/phonon/mmf/videowidget.cpp | 94 +++--- src/3rdparty/phonon/mmf/videowidget.h | 86 ++--- src/3rdparty/phonon/mmf/volumeobserver.h | 24 +- 25 files changed, 1591 insertions(+), 1681 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 7883709..1e032f3 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -29,7 +29,7 @@ using namespace Phonon::MMF; // Constants //----------------------------------------------------------------------------- -const int NullMaxVolume = -1; +const int NullMaxVolume = -1; //----------------------------------------------------------------------------- @@ -37,31 +37,31 @@ const int NullMaxVolume = -1; //----------------------------------------------------------------------------- MMF::AbstractMediaPlayer::AbstractMediaPlayer() : - m_state(GroundState) - , m_error(NoError) - , m_playPending(false) - , m_tickTimer(new QTimer(this)) - , m_volume(InitialVolume) - , m_mmfMaxVolume(NullMaxVolume) + m_state(GroundState) + , m_error(NoError) + , m_playPending(false) + , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) + , m_mmfMaxVolume(NullMaxVolume) { - connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); } MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) : - AbstractPlayer(player) - , m_state(GroundState) - , m_error(NoError) - , m_playPending(false) - , m_tickTimer(new QTimer(this)) - , m_volume(InitialVolume) - , m_mmfMaxVolume(NullMaxVolume) + AbstractPlayer(player) + , m_state(GroundState) + , m_error(NoError) + , m_playPending(false) + , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) + , m_mmfMaxVolume(NullMaxVolume) { - connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); } MMF::AbstractMediaPlayer::~AbstractMediaPlayer() { - + } @@ -74,34 +74,33 @@ void MMF::AbstractMediaPlayer::play() TRACE_CONTEXT(AbstractMediaPlayer::play, EAudioApi); TRACE_ENTRY("state %d", m_state); - switch(m_state) - { - case GroundState: - // Is this the correct error? Really we want 'NotReadyError' - m_error = NormalError; - changeState(ErrorState); - break; - - case LoadingState: - m_playPending = true; - break; - - case StoppedState: - case PausedState: - doPlay(); - startTickTimer(); - changeState(PlayingState); - break; - - case PlayingState: - case BufferingState: - case ErrorState: - // Do nothing - break; + switch (m_state) { + case GroundState: + // Is this the correct error? Really we want 'NotReadyError' + m_error = NormalError; + changeState(ErrorState); + break; + + case LoadingState: + m_playPending = true; + break; + + case StoppedState: + case PausedState: + doPlay(); + startTickTimer(); + changeState(PlayingState); + break; + + case PlayingState: + case BufferingState: + case ErrorState: + // Do nothing + break; // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); + default: + TRACE_PANIC(InvalidStatePanic); } TRACE_EXIT("state %d", m_state); @@ -113,27 +112,26 @@ void MMF::AbstractMediaPlayer::pause() TRACE_ENTRY("state %d", m_state); m_playPending = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case PausedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - doPause(); - stopTickTimer(); - changeState(PausedState); - break; + + switch (m_state) { + case GroundState: + case LoadingState: + case StoppedState: + case PausedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + doPause(); + stopTickTimer(); + changeState(PausedState); + break; // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); + default: + TRACE_PANIC(InvalidStatePanic); } TRACE_EXIT("state %d", m_state); @@ -145,27 +143,26 @@ void MMF::AbstractMediaPlayer::stop() TRACE_ENTRY("state %d", m_state); m_playPending = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - case PausedState: - doStop(); - stopTickTimer(); - changeState(StoppedState); - break; + + switch (m_state) { + case GroundState: + case LoadingState: + case StoppedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + case PausedState: + doStop(); + stopTickTimer(); + changeState(StoppedState); + break; // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); + default: + TRACE_PANIC(InvalidStatePanic); } TRACE_EXIT("state %d", m_state); @@ -177,23 +174,22 @@ void MMF::AbstractMediaPlayer::seek(qint64 ms) TRACE_ENTRY("state %d pos %Ld", state(), ms); // TODO: put a state guard in here - + const bool tickTimerWasRunning = m_tickTimer->isActive(); stopTickTimer(); - + doSeek(ms); - - if(tickTimerWasRunning) - { + + if (tickTimerWasRunning) { startTickTimer(); } - + TRACE_EXIT_0(); } bool MMF::AbstractMediaPlayer::isSeekable() const { - return true; + return true; } void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) @@ -209,7 +205,7 @@ void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) Phonon::ErrorType MMF::AbstractMediaPlayer::errorType() const { const Phonon::ErrorType result = (ErrorState == m_state) - ? m_error : NoError; + ? m_error : NoError; return result; } @@ -244,58 +240,52 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f TInt symbianErr = KErrNone; - switch(m_source.type()) - { - case MediaSource::LocalFile: - { - // TODO: work out whose responsibility it is to ensure that paths - // are Symbian-style, i.e. have backslashes for path delimiters. - // Until then, use this utility function... - //const QHBufC filename = Utils::symbianFilename(m_source.fileName()); - //TRAP(symbianErr, m_player->OpenFileL(*filename)); - - // Open using shared filehandle - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //TRAP(symbianErr, m_player->OpenFileL(file)); - - symbianErr = openFile(file); - break; - } + switch (m_source.type()) { + case MediaSource::LocalFile: { + // TODO: work out whose responsibility it is to ensure that paths + // are Symbian-style, i.e. have backslashes for path delimiters. + // Until then, use this utility function... + //const QHBufC filename = Utils::symbianFilename(m_source.fileName()); + //TRAP(symbianErr, m_player->OpenFileL(*filename)); + + // Open using shared filehandle + // This is a temporary hack to work around KErrInUse from MMF + // client utility OpenFileL calls + //TRAP(symbianErr, m_player->OpenFileL(file)); + + symbianErr = openFile(file); + break; + } - case MediaSource::Url: - { - TRACE_0("Source type not supported"); - // TODO: support opening URLs - symbianErr = KErrNotSupported; - break; - } + case MediaSource::Url: { + TRACE_0("Source type not supported"); + // TODO: support opening URLs + symbianErr = KErrNotSupported; + break; + } - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - TRACE_0("Source type not supported"); - symbianErr = KErrNotSupported; - break; + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + TRACE_0("Source type not supported"); + symbianErr = KErrNotSupported; + break; - case MediaSource::Empty: - TRACE_0("Empty source - doing nothing"); - TRACE_EXIT_0(); - return; + case MediaSource::Empty: + TRACE_0("Empty source - doing nothing"); + TRACE_EXIT_0(); + return; // Protection against adding new media types and forgetting to update this switch - default: - TRACE_PANIC(InvalidMediaTypePanic); + default: + TRACE_PANIC(InvalidMediaTypePanic); } - if(KErrNone == symbianErr) - { + if (KErrNone == symbianErr) { changeState(LoadingState); - } - else - { - TRACE("error %d", symbianErr) - + } else { + TRACE("error %d", symbianErr) + // TODO: do something with the value of symbianErr? m_error = NormalError; changeState(ErrorState); @@ -326,44 +316,41 @@ void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) { TRACE_CONTEXT(AbstractMediaPlayer::volumeChanged, EAudioInternal); TRACE_ENTRY("state %d", m_state); - + m_volume = volume; doVolumeChanged(); - + TRACE_EXIT_0(); } void MMF::AbstractMediaPlayer::doVolumeChanged() { - switch(m_state) - { - case GroundState: - case LoadingState: - case ErrorState: - // Do nothing - break; - - case StoppedState: - case PausedState: - case PlayingState: - case BufferingState: - { - const int err = setDeviceVolume(m_volume * m_mmfMaxVolume); - - if(KErrNone != err) - { - m_error = NormalError; - changeState(ErrorState); - } - break; - } - - // Protection against adding new states and forgetting to update this - // switch - default: - Utils::panic(InvalidStatePanic); - } + switch (m_state) { + case GroundState: + case LoadingState: + case ErrorState: + // Do nothing + break; + + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: { + const int err = setDeviceVolume(m_volume * m_mmfMaxVolume); + + if (KErrNone != err) { + m_error = NormalError; + changeState(ErrorState); + } + break; + } + + // Protection against adding new states and forgetting to update this + // switch + default: + Utils::panic(InvalidStatePanic); + } } @@ -373,23 +360,23 @@ void MMF::AbstractMediaPlayer::doVolumeChanged() void MMF::AbstractMediaPlayer::startTickTimer() { - m_tickTimer->start(tickInterval()); + m_tickTimer->start(tickInterval()); } void MMF::AbstractMediaPlayer::stopTickTimer() { - m_tickTimer->stop(); + m_tickTimer->stop(); } void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) { - m_mmfMaxVolume = mmfMaxVolume; - doVolumeChanged(); + m_mmfMaxVolume = mmfMaxVolume; + doVolumeChanged(); } Phonon::State MMF::AbstractMediaPlayer::phononState() const { - return phononState(m_state); + return phononState(m_state); } Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) @@ -411,27 +398,25 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) const Phonon::State oldPhononState = phononState(m_state); const Phonon::State newPhononState = phononState(newState); - if(oldPhononState != newPhononState) - { + if (oldPhononState != newPhononState) { TRACE("emit stateChanged(%d, %d)", newPhononState, oldPhononState); emit stateChanged(newPhononState, oldPhononState); } m_state = newState; - + // Check whether play() was called while clip was being loaded. If so, // playback should be started now - if( - LoadingState == oldPhononState - and StoppedState == newPhononState - and m_playPending - ) - { - TRACE_0("play was called while loading; starting playback now"); - m_playPending = false; - play(); + if ( + LoadingState == oldPhononState + and StoppedState == newPhononState + and m_playPending + ) { + TRACE_0("play was called while loading; starting playback now"); + m_playPending = false; + play(); } - + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 51935a3..f11b559 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -30,130 +30,129 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class AudioOutput; - - /** - * Interface via which MMF client APIs for both audio and video can be - * accessed. - */ - class AbstractMediaPlayer : public AbstractPlayer - { - Q_OBJECT - - protected: - AbstractMediaPlayer(); - explicit AbstractMediaPlayer(const AbstractPlayer& player); - ~AbstractMediaPlayer(); - - public: - // MediaObjectInterface - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual bool isSeekable() const; - virtual Phonon::ErrorType errorType() const; - virtual QString errorString() const; - virtual Phonon::State state() const; - virtual MediaSource source() const; - virtual void setFileSource(const Phonon::MediaSource&, RFile&); - virtual void setNextSource(const MediaSource &source); - - // VolumeObserver - virtual void volumeChanged(qreal volume); - - protected: - // AbstractPlayer - virtual void doSetTickInterval(qint32 interval); - - protected: - virtual void doPlay() = 0; - virtual void doPause() = 0; - virtual void doStop() = 0; - virtual void doSeek(qint64 pos) = 0; - virtual int setDeviceVolume(int mmfVolume) = 0; - virtual int openFile(RFile& file) = 0; - virtual void close() = 0; - - protected: - bool tickTimerRunning() const; - void startTickTimer(); - void stopTickTimer(); - void maxVolumeChanged(int maxVolume); - - /** - * Defined private state enumeration in order to add GroundState - */ - enum PrivateState - { - LoadingState = Phonon::LoadingState, - StoppedState = Phonon::StoppedState, - PlayingState = Phonon::PlayingState, - BufferingState = Phonon::BufferingState, - PausedState = Phonon::PausedState, - ErrorState = Phonon::ErrorState, - GroundState - }; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - Phonon::State phononState() const; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - static Phonon::State phononState(PrivateState state); - - /** - * Changes state and emits stateChanged() - */ - void changeState(PrivateState newState); - - /** - * Records error and changes state to ErrorState - */ - void setError(Phonon::ErrorType error); - - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - private: - void doVolumeChanged(); - - Q_SIGNALS: - void tick(qint64 time); - void stateChanged(Phonon::State oldState, - Phonon::State newState); - - private Q_SLOTS: - /** - * Receives signal from m_tickTimer - */ - void tick(); - - private: - PrivateState m_state; - Phonon::ErrorType m_error; - - /** - * This flag is set to true if play is called when the object is - * in a Loading state. Once loading is complete, playback will - * be started. - */ - bool m_playPending; - - QScopedPointer m_tickTimer; - - qreal m_volume; - int m_mmfMaxVolume; - - MediaSource m_source; - MediaSource m_nextSource; - - }; - } +namespace MMF +{ +class AudioOutput; + +/** + * Interface via which MMF client APIs for both audio and video can be + * accessed. + */ +class AbstractMediaPlayer : public AbstractPlayer +{ + Q_OBJECT + +protected: + AbstractMediaPlayer(); + explicit AbstractMediaPlayer(const AbstractPlayer& player); + ~AbstractMediaPlayer(); + +public: + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual bool isSeekable() const; + virtual Phonon::ErrorType errorType() const; + virtual QString errorString() const; + virtual Phonon::State state() const; + virtual MediaSource source() const; + virtual void setFileSource(const Phonon::MediaSource&, RFile&); + virtual void setNextSource(const MediaSource &source); + + // VolumeObserver + virtual void volumeChanged(qreal volume); + +protected: + // AbstractPlayer + virtual void doSetTickInterval(qint32 interval); + +protected: + virtual void doPlay() = 0; + virtual void doPause() = 0; + virtual void doStop() = 0; + virtual void doSeek(qint64 pos) = 0; + virtual int setDeviceVolume(int mmfVolume) = 0; + virtual int openFile(RFile& file) = 0; + virtual void close() = 0; + +protected: + bool tickTimerRunning() const; + void startTickTimer(); + void stopTickTimer(); + void maxVolumeChanged(int maxVolume); + + /** + * Defined private state enumeration in order to add GroundState + */ + enum PrivateState { + LoadingState = Phonon::LoadingState, + StoppedState = Phonon::StoppedState, + PlayingState = Phonon::PlayingState, + BufferingState = Phonon::BufferingState, + PausedState = Phonon::PausedState, + ErrorState = Phonon::ErrorState, + GroundState + }; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + Phonon::State phononState() const; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + static Phonon::State phononState(PrivateState state); + + /** + * Changes state and emits stateChanged() + */ + void changeState(PrivateState newState); + + /** + * Records error and changes state to ErrorState + */ + void setError(Phonon::ErrorType error); + + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + +private: + void doVolumeChanged(); + +Q_SIGNALS: + void tick(qint64 time); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + +private Q_SLOTS: + /** + * Receives signal from m_tickTimer + */ + void tick(); + +private: + PrivateState m_state; + Phonon::ErrorType m_error; + + /** + * This flag is set to true if play is called when the object is + * in a Loading state. Once loading is complete, playback will + * be started. + */ + bool m_playPending; + + QScopedPointer m_tickTimer; + + qreal m_volume; + int m_mmfMaxVolume; + + MediaSource m_source; + MediaSource m_nextSource; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 328ab37..c6f0f6b 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -30,19 +30,19 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::AbstractPlayer::AbstractPlayer() - : m_videoOutput(NULL) - , m_tickInterval(DefaultTickInterval) - , m_transitionTime(0) - , m_prefinishMark(0) + : m_videoOutput(NULL) + , m_tickInterval(DefaultTickInterval) + , m_transitionTime(0) + , m_prefinishMark(0) { } MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) - : m_videoOutput(player.m_videoOutput) - , m_tickInterval(player.tickInterval()) - , m_transitionTime(player.transitionTime()) - , m_prefinishMark(player.prefinishMark()) + : m_videoOutput(player.m_videoOutput) + , m_tickInterval(player.tickInterval()) + , m_transitionTime(player.transitionTime()) + , m_prefinishMark(player.prefinishMark()) { } @@ -64,17 +64,17 @@ void MMF::AbstractPlayer::setTickInterval(qint32 interval) qint32 MMF::AbstractPlayer::prefinishMark() const { - return m_prefinishMark; + return m_prefinishMark; } void MMF::AbstractPlayer::setPrefinishMark(qint32 mark) { - m_prefinishMark = mark; + m_prefinishMark = mark; } qint32 MMF::AbstractPlayer::transitionTime() const { - return m_transitionTime; + return m_transitionTime; } void MMF::AbstractPlayer::setTransitionTime(qint32 time) @@ -95,7 +95,7 @@ void MMF::AbstractPlayer::setVideoOutput(VideoOutput* videoOutput) void MMF::AbstractPlayer::videoOutputChanged() { - // Default behaviour is empty - overridden by VideoPlayer + // Default behaviour is empty - overridden by VideoPlayer } diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 399cd5d..da0fe51 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -34,77 +34,77 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class VideoOutput; - - /** - * @short Interface which abstracts from MediaObject the current - * media type - * - * This may be: - * - Nothing, in which case this interface is implemented by - * DummyPlayer - * - Audio, in which case the implementation is AudioPlayer - * - Video, in which case the implementation is VideoPlayer - */ - class AbstractPlayer : public QObject - , public VolumeObserver - { - // Required although this class has no signals or slots - // Without this, qobject_cast will fail - Q_OBJECT - - public: - AbstractPlayer(); - explicit AbstractPlayer(const AbstractPlayer& player); - - // MediaObjectInterface (implemented) - qint32 tickInterval() const; - void setTickInterval(qint32); - void setTransitionTime(qint32); - qint32 transitionTime() const; - void setPrefinishMark(qint32); - qint32 prefinishMark() const; - - // MediaObjectInterface (abstract) - virtual void play() = 0; - virtual void pause() = 0; - virtual void stop() = 0; - virtual void seek(qint64 milliseconds) = 0; - virtual bool hasVideo() const = 0; - virtual bool isSeekable() const = 0; - virtual qint64 currentTime() const = 0; - virtual Phonon::State state() const = 0; - virtual QString errorString() const = 0; - virtual Phonon::ErrorType errorType() const = 0; - virtual qint64 totalTime() const = 0; - virtual Phonon::MediaSource source() const = 0; - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //virtual void setSource(const Phonon::MediaSource &) = 0; - virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; - virtual void setNextSource(const Phonon::MediaSource &) = 0; - - void setVideoOutput(VideoOutput* videoOutput); - - protected: - virtual void videoOutputChanged(); - - private: - virtual void doSetTickInterval(qint32 interval) = 0; - - protected: - // Not owned - VideoOutput* m_videoOutput; - - private: - qint32 m_tickInterval; - qint32 m_transitionTime; - qint32 m_prefinishMark; - - }; - } +namespace MMF +{ +class VideoOutput; + +/** + * @short Interface which abstracts from MediaObject the current + * media type + * + * This may be: + * - Nothing, in which case this interface is implemented by + * DummyPlayer + * - Audio, in which case the implementation is AudioPlayer + * - Video, in which case the implementation is VideoPlayer + */ +class AbstractPlayer : public QObject + , public VolumeObserver +{ + // Required although this class has no signals or slots + // Without this, qobject_cast will fail + Q_OBJECT + +public: + AbstractPlayer(); + explicit AbstractPlayer(const AbstractPlayer& player); + + // MediaObjectInterface (implemented) + qint32 tickInterval() const; + void setTickInterval(qint32); + void setTransitionTime(qint32); + qint32 transitionTime() const; + void setPrefinishMark(qint32); + qint32 prefinishMark() const; + + // MediaObjectInterface (abstract) + virtual void play() = 0; + virtual void pause() = 0; + virtual void stop() = 0; + virtual void seek(qint64 milliseconds) = 0; + virtual bool hasVideo() const = 0; + virtual bool isSeekable() const = 0; + virtual qint64 currentTime() const = 0; + virtual Phonon::State state() const = 0; + virtual QString errorString() const = 0; + virtual Phonon::ErrorType errorType() const = 0; + virtual qint64 totalTime() const = 0; + virtual Phonon::MediaSource source() const = 0; + // This is a temporary hack to work around KErrInUse from MMF + // client utility OpenFileL calls + //virtual void setSource(const Phonon::MediaSource &) = 0; + virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; + virtual void setNextSource(const Phonon::MediaSource &) = 0; + + void setVideoOutput(VideoOutput* videoOutput); + +protected: + virtual void videoOutputChanged(); + +private: + virtual void doSetTickInterval(qint32 interval) = 0; + +protected: + // Not owned + VideoOutput* m_videoOutput; + +private: + qint32 m_tickInterval; + qint32 m_transitionTime; + qint32 m_prefinishMark; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 099c899..909e568 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -33,9 +33,9 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) - , m_volume(InitialVolume) - , m_observer(NULL) +MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) + , m_volume(InitialVolume) + , m_observer(NULL) { } @@ -47,7 +47,7 @@ MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) qreal MMF::AudioOutput::volume() const { - return m_volume; + return m_volume; } void MMF::AudioOutput::setVolume(qreal volume) @@ -55,18 +55,16 @@ void MMF::AudioOutput::setVolume(qreal volume) TRACE_CONTEXT(AudioOutput::setVolume, EAudioApi); TRACE_ENTRY("observer 0x%08x volume %f", m_observer, volume); - if(volume != m_volume) - { - if(m_observer) - { - m_observer->volumeChanged(volume); - } - - m_volume = volume; - TRACE("emit volumeChanged(%f)", volume) - emit volumeChanged(volume); + if (volume != m_volume) { + if (m_observer) { + m_observer->volumeChanged(volume); + } + + m_volume = volume; + TRACE("emit volumeChanged(%f)", volume) + emit volumeChanged(volume); } - + TRACE_EXIT_0(); } @@ -88,9 +86,8 @@ bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer) { m_observer = observer; - if(m_observer) - { - m_observer->volumeChanged(m_volume); + if (m_observer) { + m_observer->volumeChanged(m_volume); } } diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index ab90c44..001190f 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -25,66 +25,66 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class Backend; - class VolumeObserver; - - /** - * @short AudioOutputInterface implementation for MMF. - * - * Forwards volume commands to the VolumeObserver instance, - * which is provided by the backend when MediaNode objects are - * connected. - * - * \section volume Volume - * - * Phonon's concept on volume is from 0.0 to 1.0, and from 1< it does - * voltage multiplication. CDrmPlayerUtility goes from 1 to - * CDrmPlayerUtility::MaxVolume(). We apply some basic math to convert - * between the two. - * - * @author Frans Englich - */ - class AudioOutput : public QObject - , public AudioOutputInterface - { - Q_OBJECT - Q_INTERFACES(Phonon::AudioOutputInterface) - - public: - AudioOutput(Backend *backend, QObject *parent); - virtual qreal volume() const; - virtual void setVolume(qreal volume); - - virtual int outputDevice() const; - - /** - * Has no effect. - */ - virtual bool setOutputDevice(int); - - /** - * Has no effect. - */ - virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); - - /** - * Called by backend when nodes are connected. - */ - void setVolumeObserver(VolumeObserver* observer); - - Q_SIGNALS: - void volumeChanged(qreal volume); - void audioDeviceFailed(); - - private: - qreal m_volume; - - // Not owned - VolumeObserver* m_observer; - }; - } +namespace MMF +{ +class Backend; +class VolumeObserver; + +/** + * @short AudioOutputInterface implementation for MMF. + * + * Forwards volume commands to the VolumeObserver instance, + * which is provided by the backend when MediaNode objects are + * connected. + * + * \section volume Volume + * + * Phonon's concept on volume is from 0.0 to 1.0, and from 1< it does + * voltage multiplication. CDrmPlayerUtility goes from 1 to + * CDrmPlayerUtility::MaxVolume(). We apply some basic math to convert + * between the two. + * + * @author Frans Englich + */ +class AudioOutput : public QObject + , public AudioOutputInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::AudioOutputInterface) + +public: + AudioOutput(Backend *backend, QObject *parent); + virtual qreal volume() const; + virtual void setVolume(qreal volume); + + virtual int outputDevice() const; + + /** + * Has no effect. + */ + virtual bool setOutputDevice(int); + + /** + * Has no effect. + */ + virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); + + /** + * Called by backend when nodes are connected. + */ + void setVolumeObserver(VolumeObserver* observer); + +Q_SIGNALS: + void volumeChanged(qreal volume); + void audioDeviceFailed(); + +private: + qreal m_volume; + + // Not owned + VolumeObserver* m_observer; +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 50048c8..1229625 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -30,32 +30,31 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioPlayer::AudioPlayer() : m_player(NULL) +MMF::AudioPlayer::AudioPlayer() : m_player(NULL) { - construct(); + construct(); } MMF::AudioPlayer::AudioPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) - , m_player(NULL) + : AbstractMediaPlayer(player) + , m_player(NULL) { - construct(); + construct(); } void MMF::AudioPlayer::construct() { - TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); - TRACE_ENTRY_0(); - - // TODO: is this the correct way to handle errors which occur when - // creating a Symbian object in the constructor of a Qt object? - TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); - if(KErrNone != err) - { - changeState(ErrorState); - } - - TRACE_EXIT_0(); + TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); + TRACE_ENTRY_0(); + + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? + TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); + if (KErrNone != err) { + changeState(ErrorState); + } + + TRACE_EXIT_0(); } MMF::AudioPlayer::~AudioPlayer() @@ -74,17 +73,17 @@ MMF::AudioPlayer::~AudioPlayer() void MMF::AudioPlayer::doPlay() { - m_player->Play(); + m_player->Play(); } void MMF::AudioPlayer::doPause() { - m_player->Pause(); + m_player->Pause(); } void MMF::AudioPlayer::doStop() { - m_player->Stop(); + m_player->Stop(); } void MMF::AudioPlayer::doSeek(qint64 ms) @@ -94,30 +93,29 @@ void MMF::AudioPlayer::doSeek(qint64 ms) int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) { - return m_player->SetVolume(mmfVolume); + return m_player->SetVolume(mmfVolume); } int MMF::AudioPlayer::openFile(RFile& file) { - TRAPD(err, m_player->OpenFileL(file)); - + TRAPD(err, m_player->OpenFileL(file)); + #ifdef QT_PHONON_MMF_AUDIO_DRM - if(KErrNone == err) - { + if (KErrNone == err) { // There appears to be a bug in the CDrmPlayerUtility implementation (at least // in S60 5.x) whereby the player does not check whether the loading observer // pointer is null before dereferencing it. Therefore we must register for // loading notification, even though we do nothing in the callback functions. m_player->RegisterForAudioLoadingNotification(*this); - } + } #endif - - return err; + + return err; } void MMF::AudioPlayer::close() { - m_player->Close(); + m_player->Close(); } bool MMF::AudioPlayer::hasVideo() const @@ -134,17 +132,14 @@ qint64 MMF::AudioPlayer::currentTime() const qint64 result = 0; - if(KErrNone == err) - { + if (KErrNone == err) { result = toMilliSeconds(us); - } - else - { - TRACE("GetPosition err %d", err); - - // If we don't cast away constness here, we simply have to ignore - // the error. - const_cast(this)->setError(NormalError); + } else { + TRACE("GetPosition err %d", err); + + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast(this)->setError(NormalError); } return result; @@ -162,10 +157,10 @@ qint64 MMF::AudioPlayer::totalTime() const #ifdef QT_PHONON_MMF_AUDIO_DRM void MMF::AudioPlayer::MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &) + const TTimeIntervalMicroSeconds &) #else void MMF::AudioPlayer::MapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &) + const TTimeIntervalMicroSeconds &) #endif { TRACE_CONTEXT(AudioPlayer::MapcInitComplete, EAudioInternal); @@ -173,15 +168,12 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - if(KErrNone == aError) - { - maxVolumeChanged(m_player->MaxVolume()); + if (KErrNone == aError) { + maxVolumeChanged(m_player->MaxVolume()); - emit totalTimeChanged(totalTime()); - changeState(StoppedState); - } - else - { + emit totalTimeChanged(totalTime()); + changeState(StoppedState); + } else { // TODO: set different error states according to value of aError? setError(NormalError); } @@ -200,33 +192,30 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) stopTickTimer(); - if(KErrNone == aError) - { + if (KErrNone == aError) { changeState(StoppedState); // TODO: move on to m_nextSource - } - else - { + } else { // TODO: do something with aError? setError(NormalError); } -/* - if(aError == KErrNone) { - if(m_nextSource.type() == MediaSource::Empty) { - emit finished(); - } else { - setSource(m_nextSource); - m_nextSource = MediaSource(); - } + /* + if(aError == KErrNone) { + if(m_nextSource.type() == MediaSource::Empty) { + emit finished(); + } else { + setSource(m_nextSource); + m_nextSource = MediaSource(); + } - changeState(StoppedState); - } - else { - m_error = NormalError; - changeState(ErrorState); - } -*/ + changeState(StoppedState); + } + else { + m_error = NormalError; + changeState(ErrorState); + } + */ TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index cdb6cb9..424985c 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -38,70 +38,70 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * @short Wrapper over MMF audio client utility - */ - class AudioPlayer : public AbstractMediaPlayer - , public MPlayerObserverType // typedef +namespace MMF +{ +/** + * @short Wrapper over MMF audio client utility + */ +class AudioPlayer : public AbstractMediaPlayer + , public MPlayerObserverType // typedef #ifdef QT_PHONON_MMF_AUDIO_DRM - , public MAudioLoadingObserver + , public MAudioLoadingObserver #endif - { - Q_OBJECT - - public: - AudioPlayer(); - explicit AudioPlayer(const AbstractPlayer& player); - virtual ~AudioPlayer(); - - // AbstractMediaPlayer - virtual void doPlay(); - virtual void doPause(); - virtual void doStop(); - virtual void doSeek(qint64 milliseconds); - virtual int setDeviceVolume(int mmfVolume); - virtual int openFile(RFile& file); - virtual void close(); - - // MediaObjectInterface - virtual bool hasVideo() const; - virtual qint64 currentTime() const; - virtual qint64 totalTime() const; +{ + Q_OBJECT + +public: + AudioPlayer(); + explicit AudioPlayer(const AbstractPlayer& player); + virtual ~AudioPlayer(); + + // AbstractMediaPlayer + virtual void doPlay(); + virtual void doPause(); + virtual void doStop(); + virtual void doSeek(qint64 milliseconds); + virtual int setDeviceVolume(int mmfVolume); + virtual int openFile(RFile& file); + virtual void close(); + + // MediaObjectInterface + virtual bool hasVideo() const; + virtual qint64 currentTime() const; + virtual qint64 totalTime() const; #ifdef QT_PHONON_MMF_AUDIO_DRM - // MDrmAudioPlayerCallback - virtual void MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MdapcPlayComplete(TInt aError); - - // MAudioLoadingObserver - virtual void MaloLoadingStarted(); - virtual void MaloLoadingComplete(); + // MDrmAudioPlayerCallback + virtual void MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MdapcPlayComplete(TInt aError); + + // MAudioLoadingObserver + virtual void MaloLoadingStarted(); + virtual void MaloLoadingComplete(); #else - // MMdaAudioPlayerCallback - virtual void MapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MapcPlayComplete(TInt aError); + // MMdaAudioPlayerCallback + virtual void MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MapcPlayComplete(TInt aError); #endif - Q_SIGNALS: - void totalTimeChanged(qint64 length); - void finished(); - - private: - void construct(); - - private: - /** - * Using CPlayerType typedef in order to be able to easily switch between - * CMdaAudioPlayerUtility and CDrmPlayerUtility - */ - CPlayerType* m_player; - - }; - } +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void finished(); + +private: + void construct(); + +private: + /** + * Using CPlayerType typedef in order to be able to easily switch between + * CMdaAudioPlayerUtility and CDrmPlayerUtility + */ + CPlayerType* m_player; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 236ef28..71e51d9 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -34,49 +34,48 @@ QT_BEGIN_NAMESPACE using namespace Phonon; using namespace Phonon::MMF; -Backend::Backend(QObject *parent) : QObject(parent) +Backend::Backend(QObject *parent) : QObject(parent) { - TRACE_CONTEXT(Backend::Backend, EBackend); - TRACE_ENTRY_0(); + TRACE_CONTEXT(Backend::Backend, EBackend); + TRACE_ENTRY_0(); setProperty("identifier", QLatin1String("phonon_mmf")); setProperty("backendName", QLatin1String("MMF")); setProperty("backendComment", QLatin1String("Backend using Symbian Multimedia Framework (MMF)")); setProperty("backendVersion", QLatin1String("0.1")); setProperty("backendWebsite", QLatin1String("http://www.qtsoftware.com/")); - + TRACE_EXIT_0(); } QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &) { - TRACE_CONTEXT(Backend::createObject, EBackend); - TRACE_ENTRY("class %d", c); - - QObject* result = NULL; - - switch(c) - { - case AudioOutputClass: - result = new AudioOutput(this, parent); - break; - - case MediaObjectClass: - result = new MediaObject(parent); - break; - - case VolumeFaderEffectClass: - case VisualizationClass: - case VideoDataOutputClass: - case EffectClass: - break; - - case VideoWidgetClass: - result = new VideoWidget(qobject_cast(parent)); - break; - - default: - TRACE_PANIC(InvalidBackendInterfaceClass); + TRACE_CONTEXT(Backend::createObject, EBackend); + TRACE_ENTRY("class %d", c); + + QObject* result = NULL; + + switch (c) { + case AudioOutputClass: + result = new AudioOutput(this, parent); + break; + + case MediaObjectClass: + result = new MediaObject(parent); + break; + + case VolumeFaderEffectClass: + case VisualizationClass: + case VideoDataOutputClass: + case EffectClass: + break; + + case VideoWidgetClass: + result = new VideoWidget(qobject_cast(parent)); + break; + + default: + TRACE_PANIC(InvalidBackendInterfaceClass); } TRACE_RETURN("0x%08x", result); @@ -99,46 +98,44 @@ bool Backend::startConnectionChange(QSet) bool Backend::connectNodes(QObject *source, QObject *target) { - TRACE_CONTEXT(Backend::connectNodes, EBackend); - TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); + TRACE_CONTEXT(Backend::connectNodes, EBackend); + TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - MediaObject *const mediaObject = qobject_cast(source); + MediaObject *const mediaObject = qobject_cast(source); AudioOutput *const audioOutput = qobject_cast(target); VideoWidget *const videoWidget = qobject_cast(target); - + bool result = false; - - if(mediaObject and audioOutput) - { - TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); - audioOutput->setVolumeObserver(mediaObject); - result = true; + + if (mediaObject and audioOutput) { + TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); + audioOutput->setVolumeObserver(mediaObject); + result = true; } - - if(mediaObject and videoWidget) - { - TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); - mediaObject->setVideoOutput(&videoWidget->videoOutput()); - result = true; - } - + + if (mediaObject and videoWidget) { + TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); + mediaObject->setVideoOutput(&videoWidget->videoOutput()); + result = true; + } + TRACE_RETURN("%d", result); } bool Backend::disconnectNodes(QObject *source, QObject *target) { - TRACE_CONTEXT(Backend::disconnectNodes, EBackend); - TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - - MediaObject *const mediaObject = qobject_cast(source); - AudioOutput *const audioOutput = qobject_cast(target); - VideoWidget *const videoWidget = qobject_cast(target); - - bool result = true; - - // TODO: disconnection - - TRACE_RETURN("%d", result); + TRACE_CONTEXT(Backend::disconnectNodes, EBackend); + TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); + + MediaObject *const mediaObject = qobject_cast(source); + AudioOutput *const audioOutput = qobject_cast(target); + VideoWidget *const videoWidget = qobject_cast(target); + + bool result = true; + + // TODO: disconnection + + TRACE_RETURN("%d", result); } bool Backend::endConnectionChange(QSet) @@ -148,40 +145,38 @@ bool Backend::endConnectionChange(QSet) void getAvailableMimeTypesL(QStringList& result) { - RApaLsSession apaSession; - User::LeaveIfError(apaSession.Connect()); - CleanupClosePushL(apaSession); - - static const TInt DataTypeArrayGranularity = 8; - CDataTypeArray* array = new (ELeave) CDataTypeArray(DataTypeArrayGranularity); - CleanupStack::PushL(array); - - apaSession.GetSupportedDataTypesL(*array); - - for(TInt i=0; iCount(); ++i) - { - const TPtrC mimeType = array->At(i).Des(); - const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType); - if(MediaTypeAudio == mediaType or MediaTypeVideo == mediaType) - { - result.append(qt_TDesC2QString(mimeType)); - } - } - - CleanupStack::PopAndDestroy(2); // apaSession, array + RApaLsSession apaSession; + User::LeaveIfError(apaSession.Connect()); + CleanupClosePushL(apaSession); + + static const TInt DataTypeArrayGranularity = 8; + CDataTypeArray* array = new(ELeave) CDataTypeArray(DataTypeArrayGranularity); + CleanupStack::PushL(array); + + apaSession.GetSupportedDataTypesL(*array); + + for (TInt i = 0; i < array->Count(); ++i) { + const TPtrC mimeType = array->At(i).Des(); + const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType); + if (MediaTypeAudio == mediaType or MediaTypeVideo == mediaType) { + result.append(qt_TDesC2QString(mimeType)); + } + } + + CleanupStack::PopAndDestroy(2); // apaSession, array } QStringList Backend::availableMimeTypes() const { - QStringList result; - - // There is no way to return an error from this function, so we just - // have to trap and ignore exceptions... - TRAP_IGNORE(getAvailableMimeTypesL(result)); - - result.sort(); - - return result; + QStringList result; + + // There is no way to return an error from this function, so we just + // have to trap and ignore exceptions... + TRAP_IGNORE(getAvailableMimeTypesL(result)); + + result.sort(); + + return result; } Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend); diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index b448187..7598fa7 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -26,29 +26,29 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class Backend : public QObject - , public BackendInterface - { - Q_OBJECT - Q_INTERFACES(Phonon::BackendInterface) - public: - Backend(QObject *parent = 0); - - virtual QObject *createObject(BackendInterface::Class c, QObject *parent, const QList &args); - virtual QList objectDescriptionIndexes(ObjectDescriptionType type) const; - virtual QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const; - virtual bool startConnectionChange(QSet); - virtual bool connectNodes(QObject *, QObject *); - virtual bool disconnectNodes(QObject *, QObject *); - virtual bool endConnectionChange(QSet); - virtual QStringList availableMimeTypes() const; - - Q_SIGNALS: - void objectDescriptionChanged(ObjectDescriptionType); - }; - } +namespace MMF +{ +class Backend : public QObject + , public BackendInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::BackendInterface) +public: + Backend(QObject *parent = 0); + + virtual QObject *createObject(BackendInterface::Class c, QObject *parent, const QList &args); + virtual QList objectDescriptionIndexes(ObjectDescriptionType type) const; + virtual QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const; + virtual bool startConnectionChange(QSet); + virtual bool connectNodes(QObject *, QObject *); + virtual bool disconnectNodes(QObject *, QObject *); + virtual bool endConnectionChange(QSet); + virtual QStringList availableMimeTypes() const; + +Q_SIGNALS: + void objectDescriptionChanged(ObjectDescriptionType); +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 37a25d1..674e767 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -21,11 +21,11 @@ along with this library. If not, see . #include -// The following macros are for switching on / off various bits of code, +// The following macros are for switching on / off various bits of code, // in order to debug the current problems with video visibility. // If this is defined, then VideoOutput is essentially just a typedef for -// QWidget. This is to allow us to test whether the QWidget function +// QWidget. This is to allow us to test whether the QWidget function // overrides present in VideoOutput (e.g. sizeHint, paintEvent etc) may // be the cause of the visibility problems. //#define PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET @@ -40,18 +40,17 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - static const qint32 DefaultTickInterval = 10; - static const qreal InitialVolume = 0.5; - - enum MediaType - { - MediaTypeUnknown, - MediaTypeAudio, - MediaTypeVideo - }; - } +namespace MMF +{ +static const qint32 DefaultTickInterval = 10; +static const qreal InitialVolume = 0.5; + +enum MediaType { + MediaTypeUnknown, + MediaTypeAudio, + MediaTypeVideo +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index dc7f8d1..dc55af7 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -29,13 +29,13 @@ using namespace Phonon::MMF; MMF::DummyPlayer::DummyPlayer() { - + } MMF::DummyPlayer::DummyPlayer(const AbstractPlayer& player) - : AbstractPlayer(player) + : AbstractPlayer(player) { - + } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 12e3bd8..b2725df 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -25,51 +25,51 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class AudioOutput; - - /** - * @short Stub implementation of AbstractPlayer. - * - * The functions of this class are: - * - Allow MediaObject to call a subset of the MediaObjectInterface - * API, before SetSource has been called. - * - Cache any parameters which are set in this state (e.g. - * prefinish mark), so that they can be copied into the 'real' - * AbstractPlayer implementation once a source has been loaded. - */ - class DummyPlayer : public AbstractPlayer - { - public: - DummyPlayer(); - DummyPlayer(const AbstractPlayer& player); - - // MediaObjectInterface - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual bool hasVideo() const; - virtual bool isSeekable() const; - virtual qint64 currentTime() const; - virtual Phonon::State state() const; - virtual QString errorString() const; - virtual Phonon::ErrorType errorType() const; - virtual qint64 totalTime() const; - virtual MediaSource source() const; - // virtual void setSource(const MediaSource &); - virtual void setFileSource(const Phonon::MediaSource&, RFile&); - virtual void setNextSource(const MediaSource &source); - - // VolumeObserver - virtual void volumeChanged(qreal volume); - - // AbstractPlayer - virtual void doSetTickInterval(qint32 interval); - - }; - } +namespace MMF +{ +class AudioOutput; + +/** + * @short Stub implementation of AbstractPlayer. + * + * The functions of this class are: + * - Allow MediaObject to call a subset of the MediaObjectInterface + * API, before SetSource has been called. + * - Cache any parameters which are set in this state (e.g. + * prefinish mark), so that they can be copied into the 'real' + * AbstractPlayer implementation once a source has been loaded. + */ +class DummyPlayer : public AbstractPlayer +{ +public: + DummyPlayer(); + DummyPlayer(const AbstractPlayer& player); + + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + // virtual void setSource(const MediaSource &); + virtual void setFileSource(const Phonon::MediaSource&, RFile&); + virtual void setNextSource(const MediaSource &source); + + // VolumeObserver + virtual void volumeChanged(qreal volume); + + // AbstractPlayer + virtual void doSetTickInterval(qint32 interval); + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 91ed859..bf55781 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -32,8 +32,8 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::MediaObject::MediaObject(QObject *parent) : QObject(parent) - , m_recognizerOpened(false) +MMF::MediaObject::MediaObject(QObject *parent) : QObject(parent) + , m_recognizerOpened(false) { m_player.reset(new DummyPlayer()); @@ -64,74 +64,63 @@ MMF::MediaObject::~MediaObject() bool MMF::MediaObject::openRecognizer() { - TRACE_CONTEXT(MediaObject::openRecognizer, EAudioInternal); - - if(!m_recognizerOpened) - { - TInt err = m_recognizer.Connect(); - if(KErrNone != err) - { - TRACE("RApaLsSession::Connect error %d", err); - return false; - } - - err = m_fileServer.Connect(); - if(KErrNone != err) - { - TRACE("RFs::Connect error %d", err); - return false; - } - - // This must be called in order to be able to share file handles with - // the recognizer server (see fileMediaType function). - err = m_fileServer.ShareProtected(); - if(KErrNone != err) - { - TRACE("RFs::ShareProtected error %d", err); - return false; - } - - m_recognizerOpened = true; - } - - return true; + TRACE_CONTEXT(MediaObject::openRecognizer, EAudioInternal); + + if (!m_recognizerOpened) { + TInt err = m_recognizer.Connect(); + if (KErrNone != err) { + TRACE("RApaLsSession::Connect error %d", err); + return false; + } + + err = m_fileServer.Connect(); + if (KErrNone != err) { + TRACE("RFs::Connect error %d", err); + return false; + } + + // This must be called in order to be able to share file handles with + // the recognizer server (see fileMediaType function). + err = m_fileServer.ShareProtected(); + if (KErrNone != err) { + TRACE("RFs::ShareProtected error %d", err); + return false; + } + + m_recognizerOpened = true; + } + + return true; } MMF::MediaType MMF::MediaObject::fileMediaType - (const QString& fileName) +(const QString& fileName) { - TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal); - - MediaType result = MediaTypeUnknown; - - if(openRecognizer()) - { - QHBufC fileNameSymbian = Utils::symbianFilename(fileName); - - m_file.Close(); - TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead|EFileShareReadersOnly); - - if(KErrNone == err) - { - TDataRecognitionResult recognizerResult; - err = m_recognizer.RecognizeData(m_file, recognizerResult); - if(KErrNone == err) - { - const TPtrC mimeType = recognizerResult.iDataType.Des(); - result = Utils::mimeTypeToMediaType(mimeType); - } - else - { - TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err); - } - } - else - { - TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err); - } - } - - return result; + TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal); + + MediaType result = MediaTypeUnknown; + + if (openRecognizer()) { + QHBufC fileNameSymbian = Utils::symbianFilename(fileName); + + m_file.Close(); + TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly); + + if (KErrNone == err) { + TDataRecognitionResult recognizerResult; + err = m_recognizer.RecognizeData(m_file, recognizerResult); + if (KErrNone == err) { + const TPtrC mimeType = recognizerResult.iDataType.Des(); + result = Utils::mimeTypeToMediaType(mimeType); + } else { + TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err); + } + } else { + TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err); + } + } + + return result; } @@ -157,9 +146,8 @@ void MMF::MediaObject::stop() void MMF::MediaObject::seek(qint64 ms) { m_player->seek(ms); - - if(state() == PausedState or state() == PlayingState) - { + + if (state() == PausedState or state() == PlayingState) { emit tick(currentTime()); } } @@ -216,130 +204,117 @@ MediaSource MMF::MediaObject::source() const void MMF::MediaObject::setSource(const MediaSource &source) { - createPlayer(source); - + createPlayer(source); + // This is a hack to work around KErrInUse from MMF client utility // OpenFileL calls m_player->setFileSource(source, m_file); - + emit currentSourceChanged(source); } void MMF::MediaObject::createPlayer(const MediaSource &source) { - TRACE_CONTEXT(MediaObject::createPlayer, EAudioApi); + TRACE_CONTEXT(MediaObject::createPlayer, EAudioApi); TRACE_ENTRY("state %d source.type %d", state(), source.type()); - TRACE_ENTRY("source.type %d", source.type()); - - MediaType mediaType = MediaTypeUnknown; - - AbstractPlayer* oldPlayer = m_player.data(); - - const bool oldPlayerHasVideo = oldPlayer->hasVideo(); - const bool oldPlayerSeekable = oldPlayer->isSeekable(); - - // Determine media type - switch(source.type()) - { - case MediaSource::LocalFile: - mediaType = fileMediaType(source.fileName()); - break; - - case MediaSource::Url: - // TODO: support detection of media type from HTTP streams - TRACE_0("Network streaming not supported yet"); - /* - * TODO: handle error - * - m_error = NormalError; - changeState(ErrorState); - */ - break; - - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - TRACE_0("Unsupported media type"); - /* - * TODO: handle error - * - m_error = NormalError; - changeState(ErrorState); - */ - break; - - case MediaSource::Empty: - TRACE_0("Empty media source"); - break; - } - - AbstractPlayer* newPlayer = NULL; - - // Construct newPlayer using oldPlayer (if not NULL) in order to copy - // parameters (volume, prefinishMark, transitionTime) which may have - // been set on oldPlayer. - - switch(mediaType) - { - case MediaTypeUnknown: - TRACE_0("Media type could not be determined"); - if(oldPlayer) - { - newPlayer = new DummyPlayer(*oldPlayer); - } - else - { - newPlayer = new DummyPlayer(); - } - /* - * TODO: handle error? - * - m_error = NormalError; - changeState(ErrorState); - */ - break; - - case MediaTypeAudio: - if(oldPlayer) - { - newPlayer = new AudioPlayer(*oldPlayer); - } - else - { - newPlayer = new AudioPlayer(); - } - break; - - case MediaTypeVideo: - if(oldPlayer) - { - newPlayer = new VideoPlayer(*oldPlayer); - } - else - { - newPlayer = new VideoPlayer(); - } - break; - } - - m_player.reset(newPlayer); - - if(oldPlayerHasVideo != hasVideo()) - { - emit hasVideoChanged(hasVideo()); - } - - if(oldPlayerSeekable != isSeekable()) - { - emit seekableChanged(isSeekable()); - } - - connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64))); - connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); - connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); - connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); - - TRACE_EXIT_0(); + TRACE_ENTRY("source.type %d", source.type()); + + MediaType mediaType = MediaTypeUnknown; + + AbstractPlayer* oldPlayer = m_player.data(); + + const bool oldPlayerHasVideo = oldPlayer->hasVideo(); + const bool oldPlayerSeekable = oldPlayer->isSeekable(); + + // Determine media type + switch (source.type()) { + case MediaSource::LocalFile: + mediaType = fileMediaType(source.fileName()); + break; + + case MediaSource::Url: + // TODO: support detection of media type from HTTP streams + TRACE_0("Network streaming not supported yet"); + /* + * TODO: handle error + * + m_error = NormalError; + changeState(ErrorState); + */ + break; + + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + TRACE_0("Unsupported media type"); + /* + * TODO: handle error + * + m_error = NormalError; + changeState(ErrorState); + */ + break; + + case MediaSource::Empty: + TRACE_0("Empty media source"); + break; + } + + AbstractPlayer* newPlayer = NULL; + + // Construct newPlayer using oldPlayer (if not NULL) in order to copy + // parameters (volume, prefinishMark, transitionTime) which may have + // been set on oldPlayer. + + switch (mediaType) { + case MediaTypeUnknown: + TRACE_0("Media type could not be determined"); + if (oldPlayer) { + newPlayer = new DummyPlayer(*oldPlayer); + } else { + newPlayer = new DummyPlayer(); + } + /* + * TODO: handle error? + * + m_error = NormalError; + changeState(ErrorState); + */ + break; + + case MediaTypeAudio: + if (oldPlayer) { + newPlayer = new AudioPlayer(*oldPlayer); + } else { + newPlayer = new AudioPlayer(); + } + break; + + case MediaTypeVideo: + if (oldPlayer) { + newPlayer = new VideoPlayer(*oldPlayer); + } else { + newPlayer = new VideoPlayer(); + } + break; + } + + m_player.reset(newPlayer); + + if (oldPlayerHasVideo != hasVideo()) { + emit hasVideoChanged(hasVideo()); + } + + if (oldPlayerSeekable != isSeekable()) { + emit seekableChanged(isSeekable()); + } + + connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64))); + connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); + connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); + connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); + + TRACE_EXIT_0(); } void MMF::MediaObject::setNextSource(const MediaSource &source) diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index d9c32ce..c53b908 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -34,94 +34,94 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class AbstractPlayer; - class VideoOutput; - - /** - * @short Facade class which wraps MMF client utility instance - */ - class MediaObject : public QObject - , public MediaObjectInterface - , public VolumeObserver - { - Q_OBJECT - Q_INTERFACES(Phonon::MediaObjectInterface) - - public: - MediaObject(QObject *parent); - virtual ~MediaObject(); - - // MediaObjectInterface - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual qint32 tickInterval() const; - virtual void setTickInterval(qint32 interval); - virtual bool hasVideo() const; - virtual bool isSeekable() const; - virtual qint64 currentTime() const; - virtual Phonon::State state() const; - virtual QString errorString() const; - virtual Phonon::ErrorType errorType() const; - virtual qint64 totalTime() const; - virtual MediaSource source() const; - virtual void setSource(const MediaSource &); - virtual void setNextSource(const MediaSource &source); - virtual qint32 prefinishMark() const; - virtual void setPrefinishMark(qint32); - virtual qint32 transitionTime() const; - virtual void setTransitionTime(qint32); - - // VolumeObserver - void volumeChanged(qreal volume); - - void setVideoOutput(VideoOutput* videoOutput); - - Q_SIGNALS: - void totalTimeChanged(qint64 length); - void hasVideoChanged(bool hasVideo); - void seekableChanged(bool seekable); - // TODO: emit bufferStatus from MediaObject - void bufferStatus(int); - // TODO: emit aboutToFinish from MediaObject - void aboutToFinish(); - // TODO: emit prefinishMarkReached from MediaObject - void prefinishMarkReached(qint32); - // TODO: emit metaDataChanged from MediaObject - void metaDataChanged(const QMultiMap& metaData); - void currentSourceChanged(const MediaSource& source); - void stateChanged(Phonon::State oldState, - Phonon::State newState); - void finished(); - void tick(qint64 time); - - private: - void createPlayer(const MediaSource &source); - bool openRecognizer(); - - // Audio / video media type recognition - MediaType fileMediaType(const QString& fileName); - // TODO: urlMediaType function - - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - private: - // Audio / video media type recognition - bool m_recognizerOpened; - RApaLsSession m_recognizer; - RFs m_fileServer; - - // Storing the file handle here to work around KErrInUse error - // from MMF player utility OpenFileL functions - RFile m_file; - - QScopedPointer m_player; - - }; - } +namespace MMF +{ +class AbstractPlayer; +class VideoOutput; + +/** + * @short Facade class which wraps MMF client utility instance + */ +class MediaObject : public QObject + , public MediaObjectInterface + , public VolumeObserver +{ + Q_OBJECT + Q_INTERFACES(Phonon::MediaObjectInterface) + +public: + MediaObject(QObject *parent); + virtual ~MediaObject(); + + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual qint32 tickInterval() const; + virtual void setTickInterval(qint32 interval); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + virtual void setSource(const MediaSource &); + virtual void setNextSource(const MediaSource &source); + virtual qint32 prefinishMark() const; + virtual void setPrefinishMark(qint32); + virtual qint32 transitionTime() const; + virtual void setTransitionTime(qint32); + + // VolumeObserver + void volumeChanged(qreal volume); + + void setVideoOutput(VideoOutput* videoOutput); + +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void hasVideoChanged(bool hasVideo); + void seekableChanged(bool seekable); + // TODO: emit bufferStatus from MediaObject + void bufferStatus(int); + // TODO: emit aboutToFinish from MediaObject + void aboutToFinish(); + // TODO: emit prefinishMarkReached from MediaObject + void prefinishMarkReached(qint32); + // TODO: emit metaDataChanged from MediaObject + void metaDataChanged(const QMultiMap& metaData); + void currentSourceChanged(const MediaSource& source); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + void finished(); + void tick(qint64 time); + +private: + void createPlayer(const MediaSource &source); + bool openRecognizer(); + + // Audio / video media type recognition + MediaType fileMediaType(const QString& fileName); + // TODO: urlMediaType function + + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + +private: + // Audio / video media type recognition + bool m_recognizerOpened; + RApaLsSession m_recognizer; + RFs m_fileServer; + + // Storing the file handle here to work around KErrInUse error + // from MMF player utility OpenFileL functions + RFile m_file; + + QScopedPointer m_player; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index eb367f6..df9ceae 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -38,8 +38,7 @@ QHBufC MMF::Utils::symbianFilename(const QString& qtFilename) QHBufC result(qtFilename); TInt pos = result->Find(ForwardSlash); - while(pos != KErrNotFound) - { + while (pos != KErrNotFound) { result->Des().Replace(pos, 1, BackwardSlash); pos = result->Find(ForwardSlash); } @@ -54,18 +53,15 @@ _LIT(KMimePrefixVideo, "video/"); MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) { - MediaType result = MediaTypeUnknown; - - if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) - { - result = MediaTypeAudio; - } - else if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) - { - result = MediaTypeVideo; - } - - return result; + MediaType result = MediaTypeUnknown; + + if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) { + result = MediaTypeAudio; + } else if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) { + result = MediaTypeVideo; + } + + return result; } diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index e2b5e59..c0487a7 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -20,7 +20,7 @@ along with this library. If not, see . #define PHONON_MMF_UTILS_H #include -#include // for RDebug +#include // for RDebug #include "defs.h" @@ -28,136 +28,132 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * Panic codes for fatal errors - */ - enum PanicCode - { - InvalidStatePanic = 1, - InvalidMediaTypePanic = 2, - InvalidBackendInterfaceClass = 3 - }; - - namespace Utils - { - /** - * Raise a fatal exception - */ - void panic(PanicCode code); - - /** - * Translate forward slashes to backslashes - * - * \note This function is a temporary measure, for use until the - * responsibility for constructing valid file paths is - * determined. - */ - QHBufC symbianFilename(const QString& qtFilename); - - /** - * Determines whether the provided MIME type is an audio or video - * type. If it is neither, the function returns MediaTypeUnknown. - */ - MediaType mimeTypeToMediaType(const TDesC& mimeType); - } - - /** - * Available trace categories; - */ - enum TTraceCategory - { - /** - * Backend - */ - EBackend = 0x00000001, - - /** - * Functions which map directly to the public Phonon audio API - */ - EAudioApi = 0x00000010, - - /** - * Internal functions in the audio implementation - */ - EAudioInternal = 0x00000020, - - /** - * Functions which map directly to the public Phonon video API - */ - EVideoApi = 0x00010000, - - /** - * Internal functions in the video implementation - */ - EVideoInternal = 0x00020000 - }; - - /** - * Mask indicating which trace categories are enabled - * - * Note that, at the moment, this is a compiled static constant. For - * runtime control over enabled trace categories, this could be replaced - * by a per-thread singleton object which owns the trace mask, and which - * exposes an API allowing it to be modified. - */ - static const TUint KTraceMask = 0xffffffff; - - /** - * Data structure used by tracing macros - */ - class TTraceContext - { - public: - TTraceContext(const TText* aFunction, const TUint aAddr, - const TUint aCategory=0) +namespace MMF +{ +/** + * Panic codes for fatal errors + */ +enum PanicCode { + InvalidStatePanic = 1, + InvalidMediaTypePanic = 2, + InvalidBackendInterfaceClass = 3 +}; + +namespace Utils +{ +/** + * Raise a fatal exception + */ +void panic(PanicCode code); + +/** + * Translate forward slashes to backslashes + * + * \note This function is a temporary measure, for use until the + * responsibility for constructing valid file paths is + * determined. + */ +QHBufC symbianFilename(const QString& qtFilename); + +/** + * Determines whether the provided MIME type is an audio or video + * type. If it is neither, the function returns MediaTypeUnknown. + */ +MediaType mimeTypeToMediaType(const TDesC& mimeType); +} + +/** + * Available trace categories; + */ +enum TTraceCategory { + /** + * Backend + */ + EBackend = 0x00000001, + + /** + * Functions which map directly to the public Phonon audio API + */ + EAudioApi = 0x00000010, + + /** + * Internal functions in the audio implementation + */ + EAudioInternal = 0x00000020, + + /** + * Functions which map directly to the public Phonon video API + */ + EVideoApi = 0x00010000, + + /** + * Internal functions in the video implementation + */ + EVideoInternal = 0x00020000 +}; + +/** + * Mask indicating which trace categories are enabled + * + * Note that, at the moment, this is a compiled static constant. For + * runtime control over enabled trace categories, this could be replaced + * by a per-thread singleton object which owns the trace mask, and which + * exposes an API allowing it to be modified. + */ +static const TUint KTraceMask = 0xffffffff; + +/** + * Data structure used by tracing macros + */ +class TTraceContext +{ +public: + TTraceContext(const TText* aFunction, const TUint aAddr, + const TUint aCategory = 0) : iFunction(aFunction), - iAddr(aAddr), - iCategory(aCategory) - { } - - /** - * Check whether iCategory appears in the trace mask - */ - TBool Enabled() const - { - return (iCategory == 0) or (iCategory & KTraceMask); - } - - const TText* iFunction; // Name of function - const TUint iAddr; // 'this' pointer - const TUint iCategory; - }; - - // Macros used internally by the trace system - #define _TRACE_PRINT RDebug::Print - #define _TRACE_TEXT(x) (TPtrC((const TText *)(x))) - #define _TRACE_MODULE Phonon::MMF - - // Macros available for use by implementation code + iAddr(aAddr), + iCategory(aCategory) { } + + /** + * Check whether iCategory appears in the trace mask + */ + TBool Enabled() const { + return (iCategory == 0) or(iCategory & KTraceMask); + } + + const TText* iFunction; // Name of function + const TUint iAddr; // 'this' pointer + const TUint iCategory; +}; + +// Macros used internally by the trace system +#define _TRACE_PRINT RDebug::Print +#define _TRACE_TEXT(x) (TPtrC((const TText *)(x))) +#define _TRACE_MODULE Phonon::MMF + +// Macros available for use by implementation code #ifdef _DEBUG - #define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat); - #define TRACE_ENTRY_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } - #define TRACE_ENTRY(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } - #define TRACE_EXIT_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } - #define TRACE_EXIT(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } - #define TRACE_RETURN(string, result) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "r Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, result); } return result; - #define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code); - #define TRACE_0(string) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); } - #define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat); +#define TRACE_ENTRY_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } +#define TRACE_ENTRY(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#define TRACE_EXIT_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } +#define TRACE_EXIT(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#define TRACE_RETURN(string, result) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "r Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, result); } return result; +#define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code); +#define TRACE_0(string) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); } +#define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } #else - #define TRACE_CONTEXT(_fn, _cat) - #define TRACE_ENTRY_0() - #define TRACE_ENTRY(string, args...) - #define TRACE_EXIT_0() - #define TRACE_EXIT(string, args...) - #define TRACE_RETURN(string, result) return result; - #define TRACE_PANIC(code) Utils::panic(code); - #define TRACE_0(string) - #define TRACE(string, args...) +#define TRACE_CONTEXT(_fn, _cat) +#define TRACE_ENTRY_0() +#define TRACE_ENTRY(string, args...) +#define TRACE_EXIT_0() +#define TRACE_EXIT(string, args...) +#define TRACE_RETURN(string, result) return result; +#define TRACE_PANIC(code) Utils::panic(code); +#define TRACE_0(string) +#define TRACE(string, args...) #endif - } +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 6534b7b..53178cb 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -34,24 +34,24 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::VideoOutput::VideoOutput(QWidget* parent) - : QWidget(parent) - , m_observer(NULL) + : QWidget(parent) + , m_observer(NULL) { - TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); - TRACE_ENTRY("parent 0x%08x", parent); + TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); + TRACE_ENTRY("parent 0x%08x", parent); #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - setPalette(QPalette(Qt::black)); - //setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); - setAutoFillBackground(false); + setPalette(QPalette(Qt::black)); + //setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + setAutoFillBackground(false); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - + #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT - dump(); + dump(); #endif - - TRACE_EXIT_0(); + + TRACE_EXIT_0(); } #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT @@ -59,56 +59,54 @@ void VideoOutput::dump() { TRACE_CONTEXT(VideoOutput::dump, EVideoInternal); TRACE_ENTRY_0(); - + TRACE("dumpObjectInfo this 0x%08x", this); this->dumpObjectInfo(); TRACE_0("Traversing up object tree ..."); QObject* node = this; QObject* root = this; - while(node) - { + while (node) { QWidget* widget = qobject_cast(node); const bool visible = widget ? widget->isVisible() : false; const QHBufC name(node->objectName()); TRACE("node 0x%08x name %S widget 0x%08x visible %d", node, name.data(), widget, visible); - + root = node; node = node->parent(); } - + TRACE("dumpObjectInfo root 0x%08x", root); root->dumpObjectInfo(); TRACE_0("+ dumpObjectTree"); root->dumpObjectTree(); TRACE_0("- dumpObjectTree"); - + TRACE("isVisible %d", isVisible()); TRACE("pos %d %d", x(), y()); TRACE("size %d %d", size().width(), size().height()); TRACE("maxSize %d %d", maximumWidth(), maximumHeight()); TRACE("sizeHint %d %d", sizeHint().width(), sizeHint().height()); - + QWidget* parentWidget = qobject_cast(parent()); - if(parentWidget) - { + if (parentWidget) { TRACE("parent.isVisible %d", parentWidget->isVisible()); TRACE("parent.pos %d %d", parentWidget->x(), parentWidget->y()); TRACE("parent.size %d %d", parentWidget->size().width(), parentWidget->size().height()); TRACE("parent.maxSize %d %d", parentWidget->maximumWidth(), parentWidget->maximumHeight()); TRACE("parent.sizeHint %d %d", parentWidget->sizeHint().width(), parentWidget->sizeHint().height()); } - + TRACE_EXIT_0(); } #endif // PHONON_MMF_DEBUG_VIDEO_OUTPUT MMF::VideoOutput::~VideoOutput() { - TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); - TRACE_ENTRY_0(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } void MMF::VideoOutput::setFrameSize(const QSize& frameSize) @@ -118,11 +116,10 @@ void MMF::VideoOutput::setFrameSize(const QSize& frameSize) #else TRACE_CONTEXT(VideoOutput::setFrameSize, EVideoInternal); TRACE("oldSize %d %d newSize %d %d", - m_frameSize.width(), m_frameSize.height(), - frameSize.width(), frameSize.height()); - - if(frameSize != m_frameSize) - { + m_frameSize.width(), m_frameSize.height(), + frameSize.width(), frameSize.height()); + + if (frameSize != m_frameSize) { m_frameSize = frameSize; updateGeometry(); } @@ -133,7 +130,7 @@ void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) { TRACE_CONTEXT(VideoOutput::setObserver, EVideoInternal); TRACE("observer 0x%08x", observer); - + m_observer = observer; } @@ -147,35 +144,34 @@ void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) QSize MMF::VideoOutput::sizeHint() const { TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); - + // TODO: replace this with a more sensible default QSize result(320, 240); - - if(!m_frameSize.isNull()) - { + + if (!m_frameSize.isNull()) { result = m_frameSize; } - + TRACE(" result %d %d", result.width(), result.height()); return result; } void MMF::VideoOutput::paintEvent(QPaintEvent* event) { - TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); - TRACE("rect %d %d - %d %d", - event->rect().left(), event->rect().top(), - event->rect().right(), event->rect().bottom()); - TRACE("regions %d", event->region().numRects()); - TRACE("type %d", event->type()); - - QWidget::paintEvent(event); + TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); + TRACE("rect %d %d - %d %d", + event->rect().left(), event->rect().top(), + event->rect().right(), event->rect().bottom()); + TRACE("regions %d", event->region().numRects()); + TRACE("type %d", event->type()); + + QWidget::paintEvent(event); } QPaintEngine* MMF::VideoOutput::paintEngine() const { TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); - + QPaintEngine* const engine = QWidget::paintEngine(); TRACE_RETURN("0x%08x", engine); @@ -183,30 +179,28 @@ QPaintEngine* MMF::VideoOutput::paintEngine() const void MMF::VideoOutput::resizeEvent(QResizeEvent* event) { - TRACE_CONTEXT(VideoOutput::resizeEvent, EVideoInternal); - TRACE("%d %d -> %d %d", - event->oldSize().width(), event->oldSize().height(), - event->size().width(), event->size().height()); - - QWidget::resizeEvent(event); - - if(m_observer) - { - m_observer->videoOutputRegionChanged(); - } + TRACE_CONTEXT(VideoOutput::resizeEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldSize().width(), event->oldSize().height(), + event->size().width(), event->size().height()); + + QWidget::resizeEvent(event); + + if (m_observer) { + m_observer->videoOutputRegionChanged(); + } } void MMF::VideoOutput::moveEvent(QMoveEvent* event) { - TRACE_CONTEXT(VideoOutput::moveEvent, EVideoInternal); - TRACE("%d %d -> %d %d", - event->oldPos().x(), event->oldPos().y(), - event->pos().x(), event->pos().y()); - - QWidget::moveEvent(event); - - if(m_observer) - { + TRACE_CONTEXT(VideoOutput::moveEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldPos().x(), event->oldPos().y(), + event->pos().x(), event->pos().y()); + + QWidget::moveEvent(event); + + if (m_observer) { m_observer->videoOutputRegionChanged(); } } diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index b8e22ca..0da6ea0 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -26,43 +26,43 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class VideoOutputObserver; - - class VideoOutput : public QWidget - { - Q_OBJECT - - public: - explicit VideoOutput(QWidget* parent); - ~VideoOutput(); - - void setFrameSize(const QSize& size); - void setObserver(VideoOutputObserver* observer); - - protected: - #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - // Override QWidget functions - QSize sizeHint() const; - void paintEvent(QPaintEvent* event); - void resizeEvent(QResizeEvent* event); - void moveEvent(QMoveEvent* event); - QPaintEngine* paintEngine() const; - #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET +namespace MMF +{ +class VideoOutputObserver; + +class VideoOutput : public QWidget +{ + Q_OBJECT + +public: + explicit VideoOutput(QWidget* parent); + ~VideoOutput(); + + void setFrameSize(const QSize& size); + void setObserver(VideoOutputObserver* observer); + +protected: +#ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + // Override QWidget functions + QSize sizeHint() const; + void paintEvent(QPaintEvent* event); + void resizeEvent(QResizeEvent* event); + void moveEvent(QMoveEvent* event); + QPaintEngine* paintEngine() const; +#endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT - public: - void dump(); +public: + void dump(); #endif - - private: - QSize m_frameSize; - - // Not owned - VideoOutputObserver* m_observer; - }; - } + +private: + QSize m_frameSize; + + // Not owned + VideoOutputObserver* m_observer; +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutputobserver.h b/src/3rdparty/phonon/mmf/videooutputobserver.h index d38ff87..e3ba305 100644 --- a/src/3rdparty/phonon/mmf/videooutputobserver.h +++ b/src/3rdparty/phonon/mmf/videooutputobserver.h @@ -25,18 +25,18 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * Interface via which VideoOutput notifies VideoPlayer of changes to the - * video output screen region. - */ - class VideoOutputObserver - { - public: - virtual void videoOutputRegionChanged() = 0; - }; - } +namespace MMF +{ +/** + * Interface via which VideoOutput notifies VideoPlayer of changes to the + * video output screen region. + */ +class VideoOutputObserver +{ +public: + virtual void videoOutputRegionChanged() = 0; +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index ba06379..f008edd 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -20,7 +20,7 @@ along with this library. If not, see . #include #include -#include // For CCoeEnv +#include // For CCoeEnv #include #include "videoplayer.h" @@ -36,70 +36,68 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::VideoPlayer::VideoPlayer() - : m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) - , m_totalTime(0) + : m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) + , m_totalTime(0) { - construct(); + construct(); } MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) - , m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) - , m_totalTime(0) + : AbstractMediaPlayer(player) + , m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) + , m_totalTime(0) { - construct(); + construct(); } void MMF::VideoPlayer::construct() { - TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); - TRACE_ENTRY_0(); - - if(!m_videoOutput) - { - m_dummyVideoOutput.reset(new VideoOutput(NULL)); - } - - videoOutput().setObserver(this); - - const TInt priority = 0; - const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; - - getNativeWindowSystemHandles(); - - // TODO: is this the correct way to handle errors which occur when - // creating a Symbian object in the constructor of a Qt object? - TRAPD(err, - m_player = CVideoPlayerUtility::NewL - ( - *this, - priority, preference, - *m_wsSession, *m_screenDevice, - *m_window, - m_windowRect, m_clipRect - ) - ); - - if(KErrNone != err) - { - changeState(ErrorState); - } - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); + TRACE_ENTRY_0(); + + if (!m_videoOutput) { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } + + videoOutput().setObserver(this); + + const TInt priority = 0; + const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; + + getNativeWindowSystemHandles(); + + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? + TRAPD(err, + m_player = CVideoPlayerUtility::NewL + ( + *this, + priority, preference, + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect + ) + ); + + if (KErrNone != err) { + changeState(ErrorState); + } + + TRACE_EXIT_0(); } MMF::VideoPlayer::~VideoPlayer() { - TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); + TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); TRACE_ENTRY_0(); - - delete m_player; - - TRACE_EXIT_0(); + + delete m_player; + + TRACE_EXIT_0(); } //----------------------------------------------------------------------------- @@ -107,35 +105,33 @@ MMF::VideoPlayer::~VideoPlayer() //----------------------------------------------------------------------------- void MMF::VideoPlayer::doPlay() -{ - m_player->Play(); +{ + m_player->Play(); } void MMF::VideoPlayer::doPause() { - TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); - - TRAPD(err, m_player->PauseL()); - if(KErrNone != err) - { - TRACE("PauseL error %d", err); - setError(NormalError); - } + TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); + + TRAPD(err, m_player->PauseL()); + if (KErrNone != err) { + TRACE("PauseL error %d", err); + setError(NormalError); + } } void MMF::VideoPlayer::doStop() { - m_player->Stop(); + m_player->Stop(); } void MMF::VideoPlayer::doSeek(qint64 ms) { TRACE_CONTEXT(VideoPlayer::doSeek, EVideoApi); - + TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms * 1000))); - if(KErrNone != err) - { + if (KErrNone != err) { TRACE("SetPositionL error %d", err); setError(NormalError); } @@ -143,48 +139,45 @@ void MMF::VideoPlayer::doSeek(qint64 ms) int MMF::VideoPlayer::setDeviceVolume(int mmfVolume) { - TRAPD(err, m_player->SetVolumeL(mmfVolume)); - return err; + TRAPD(err, m_player->SetVolumeL(mmfVolume)); + return err; } int MMF::VideoPlayer::openFile(RFile& file) { - TRAPD(err, m_player->OpenFileL(file)); - return err; + TRAPD(err, m_player->OpenFileL(file)); + return err; } void MMF::VideoPlayer::close() { - m_player->Close(); + m_player->Close(); } bool MMF::VideoPlayer::hasVideo() const { - return true; + return true; } qint64 MMF::VideoPlayer::currentTime() const { - TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); + TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); - TTimeIntervalMicroSeconds us; + TTimeIntervalMicroSeconds us; TRAPD(err, us = m_player->PositionL()) qint64 result = 0; - if(KErrNone == err) - { + if (KErrNone == err) { result = toMilliSeconds(us); + } else { + TRACE("PositionL error %d", err); + + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast(this)->setError(NormalError); } - else - { - TRACE("PositionL error %d", err); - - // If we don't cast away constness here, we simply have to ignore - // the error. - const_cast(this)->setError(NormalError); - } - + return result; } @@ -200,60 +193,54 @@ qint64 MMF::VideoPlayer::totalTime() const void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); + TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); TRACE_ENTRY("state %d error %d", state(), aError); __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - if(KErrNone == aError) - { - m_player->Prepare(); - } - else - { - // TODO: set different error states according to value of aError? - setError(NormalError); - } - + if (KErrNone == aError) { + m_player->Prepare(); + } else { + // TODO: set different error states according to value of aError? + setError(NormalError); + } + TRACE_EXIT_0(); } void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); - TRACE_ENTRY("state %d error %d", state(), aError); + TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - + TRAPD(err, doPrepareCompleteL(aError)); - - if(KErrNone == err) - { - maxVolumeChanged(m_player->MaxVolume()); - - videoOutput().setFrameSize(m_frameSize); + + if (KErrNone == err) { + maxVolumeChanged(m_player->MaxVolume()); + + videoOutput().setFrameSize(m_frameSize); emit totalTimeChanged(totalTime()); changeState(StoppedState); - } - else - { - // TODO: set different error states according to value of aError? - setError(NormalError); - } - - TRACE_EXIT_0(); + } else { + // TODO: set different error states according to value of aError? + setError(NormalError); + } + + TRACE_EXIT_0(); } void MMF::VideoPlayer::doPrepareCompleteL(TInt aError) { User::LeaveIfError(aError); - + // Get frame size TSize size; m_player->VideoFrameSizeL(size); m_frameSize = QSize(size.iWidth, size.iHeight); - + // Get duration m_totalTime = toMilliSeconds(m_player->DurationL()); } @@ -261,36 +248,36 @@ void MMF::VideoPlayer::doPrepareCompleteL(TInt aError) void MMF::VideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); - TRACE_ENTRY("state %d error %d", state(), aError); - - // TODO - Q_UNUSED(aFrame); - Q_UNUSED(aError); // suppress warnings in release builds - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); + + // TODO + Q_UNUSED(aFrame); + Q_UNUSED(aError); // suppress warnings in release builds + + TRACE_EXIT_0(); } void MMF::VideoPlayer::MvpuoPlayComplete(TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) - TRACE_ENTRY("state %d error %d", state(), aError); + TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) + TRACE_ENTRY("state %d error %d", state(), aError); - // TODO - Q_UNUSED(aError); // suppress warnings in release builds - - TRACE_EXIT_0(); + // TODO + Q_UNUSED(aError); // suppress warnings in release builds + + TRACE_EXIT_0(); } void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) { - TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); - TRACE_ENTRY("state %d", state()); + TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); + TRACE_ENTRY("state %d", state()); - // TODO - Q_UNUSED(aEvent); - - TRACE_EXIT_0(); + // TODO + Q_UNUSED(aEvent); + + TRACE_EXIT_0(); } @@ -302,28 +289,27 @@ void MMF::VideoPlayer::videoOutputRegionChanged() { TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); TRACE_ENTRY_0(); - + #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT videoOutput().dump(); #endif - + getNativeWindowSystemHandles(); - + TRAPD(err, - m_player->SetDisplayWindowL - ( - *m_wsSession, *m_screenDevice, - *m_window, - m_windowRect, m_clipRect - ) - ); - - if(KErrNone != err) - { + m_player->SetDisplayWindowL + ( + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect + ) + ); + + if (KErrNone != err) { TRACE("SetDisplayWindowL error %d", err); setError(NormalError); } - + TRACE_EXIT_0(); } @@ -334,81 +320,80 @@ void MMF::VideoPlayer::videoOutputRegionChanged() VideoOutput& MMF::VideoPlayer::videoOutput() { - TRACE_CONTEXT(VideoPlayer::videoOutput, EVideoInternal); - TRACE("videoOutput 0x%08x dummy 0x%08x", m_videoOutput, m_dummyVideoOutput.data()); + TRACE_CONTEXT(VideoPlayer::videoOutput, EVideoInternal); + TRACE("videoOutput 0x%08x dummy 0x%08x", m_videoOutput, m_dummyVideoOutput.data()); - return m_videoOutput ? *m_videoOutput : *m_dummyVideoOutput; + return m_videoOutput ? *m_videoOutput : *m_dummyVideoOutput; } void MMF::VideoPlayer::videoOutputChanged() { - TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); - TRACE_ENTRY_0(); - - // Lazily construct a dummy output if needed here - if(!m_videoOutput and m_dummyVideoOutput.isNull()) - { - m_dummyVideoOutput.reset(new VideoOutput(NULL)); - } - - videoOutput().setObserver(this); - - videoOutput().setFrameSize(m_frameSize); - - videoOutputRegionChanged(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); + TRACE_ENTRY_0(); + + // Lazily construct a dummy output if needed here + if (!m_videoOutput and m_dummyVideoOutput.isNull()) { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } + + videoOutput().setObserver(this); + + videoOutput().setFrameSize(m_frameSize); + + videoOutputRegionChanged(); + + TRACE_EXIT_0(); } void MMF::VideoPlayer::getNativeWindowSystemHandles() { - TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); - - VideoOutput& output = videoOutput(); - CCoeControl* const control = output.winId(); - - TRACE("control 0x%08x", control); - TRACE("control IsVisible %d", control->IsVisible()); - TRACE("control IsDimmed %d", control->IsDimmed()); - TRACE("control HasBorder %d", control->HasBorder()); - TRACE("control Position %d %d", - control->Position().iX, control->Position().iY); - TRACE("control Rect %d %d - %d %d", - control->Rect().iTl.iX, control->Rect().iTl.iY, - control->Rect().iBr.iX, control->Rect().iBr.iY); - TRACE("control OwnsWindow %d", control->OwnsWindow()); - - CCoeEnv* const coeEnv = control->ControlEnv(); - - m_wsSession = &(coeEnv->WsSession()); - - TRACE("session Handle 0x%08x", m_wsSession->Handle()); - - m_screenDevice = coeEnv->ScreenDevice(); - - TRACE("device WsHandle 0x%08x", m_screenDevice->WsHandle()); - - m_window = control->DrawableWindow(); - - TRACE("window ClientHandle 0x%08x", m_window->ClientHandle()); - TRACE("window WsHandle 0x%08x", m_window->WsHandle()); - TRACE("window WindowGroupId %d", m_window->WindowGroupId()); - TRACE("window Position %d %d", - m_window->Position().iX, m_window->Position().iY); - TRACE("window AbsPosition %d %d", - m_window->AbsPosition().iX, m_window->AbsPosition().iY); - TRACE("window Size %d %d", - m_window->Size().iWidth, m_window->Size().iHeight); - + TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); + + VideoOutput& output = videoOutput(); + CCoeControl* const control = output.winId(); + + TRACE("control 0x%08x", control); + TRACE("control IsVisible %d", control->IsVisible()); + TRACE("control IsDimmed %d", control->IsDimmed()); + TRACE("control HasBorder %d", control->HasBorder()); + TRACE("control Position %d %d", + control->Position().iX, control->Position().iY); + TRACE("control Rect %d %d - %d %d", + control->Rect().iTl.iX, control->Rect().iTl.iY, + control->Rect().iBr.iX, control->Rect().iBr.iY); + TRACE("control OwnsWindow %d", control->OwnsWindow()); + + CCoeEnv* const coeEnv = control->ControlEnv(); + + m_wsSession = &(coeEnv->WsSession()); + + TRACE("session Handle 0x%08x", m_wsSession->Handle()); + + m_screenDevice = coeEnv->ScreenDevice(); + + TRACE("device WsHandle 0x%08x", m_screenDevice->WsHandle()); + + m_window = control->DrawableWindow(); + + TRACE("window ClientHandle 0x%08x", m_window->ClientHandle()); + TRACE("window WsHandle 0x%08x", m_window->WsHandle()); + TRACE("window WindowGroupId %d", m_window->WindowGroupId()); + TRACE("window Position %d %d", + m_window->Position().iX, m_window->Position().iY); + TRACE("window AbsPosition %d %d", + m_window->AbsPosition().iX, m_window->AbsPosition().iY); + TRACE("window Size %d %d", + m_window->Size().iWidth, m_window->Size().iHeight); + #ifdef PHONON_MMF_HARD_CODE_VIDEO_RECT - // HACK: why isn't control->Rect updated following a call to - // updateGeometry on the parent widget? - m_windowRect = TRect(0,100,320,250); + // HACK: why isn't control->Rect updated following a call to + // updateGeometry on the parent widget? + m_windowRect = TRect(0, 100, 320, 250); #else - m_windowRect = control->Rect(); + m_windowRect = control->Rect(); #endif - - m_clipRect = m_windowRect; + + m_clipRect = m_windowRect; } diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index f8b1486..da373ab 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -29,81 +29,81 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * @short Wrapper over MMF video client utility - * - * See - * How to - * play a video file using CVideoPlayerUtility - */ - class VideoPlayer : public AbstractMediaPlayer - , public MVideoPlayerUtilityObserver - , public VideoOutputObserver - { - Q_OBJECT - - public: - VideoPlayer(); - explicit VideoPlayer(const AbstractPlayer& player); - virtual ~VideoPlayer(); - - // AbstractPlayer - virtual void doPlay(); - virtual void doPause(); - virtual void doStop(); - virtual void doSeek(qint64 milliseconds); - virtual int setDeviceVolume(int mmfVolume); - virtual int openFile(RFile& file); - virtual void close(); - - // MediaObjectInterface - virtual bool hasVideo() const; - virtual qint64 currentTime() const; - virtual qint64 totalTime() const; - - // MVideoPlayerUtilityObserver - virtual void MvpuoOpenComplete(TInt aError); - virtual void MvpuoPrepareComplete(TInt aError); - virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); - virtual void MvpuoPlayComplete(TInt aError); - virtual void MvpuoEvent(const TMMFEvent &aEvent); - - // VideoOutputObserver - virtual void videoOutputRegionChanged(); - - Q_SIGNALS: - void totalTimeChanged(qint64 length); - void finished(); - - private: - void construct(); - VideoOutput& videoOutput(); - - void doPrepareCompleteL(TInt aError); - - // AbstractPlayer - virtual void videoOutputChanged(); - - void getNativeWindowSystemHandles(); - - private: - CVideoPlayerUtility* m_player; - QScopedPointer m_dummyVideoOutput; - - // Not owned - RWsSession* m_wsSession; - CWsScreenDevice* m_screenDevice; - RWindowBase* m_window; - TRect m_windowRect; - TRect m_clipRect; - - QSize m_frameSize; - qint64 m_totalTime; - - }; - } +namespace MMF +{ +/** + * @short Wrapper over MMF video client utility + * + * See + * How to + * play a video file using CVideoPlayerUtility + */ +class VideoPlayer : public AbstractMediaPlayer + , public MVideoPlayerUtilityObserver + , public VideoOutputObserver +{ + Q_OBJECT + +public: + VideoPlayer(); + explicit VideoPlayer(const AbstractPlayer& player); + virtual ~VideoPlayer(); + + // AbstractPlayer + virtual void doPlay(); + virtual void doPause(); + virtual void doStop(); + virtual void doSeek(qint64 milliseconds); + virtual int setDeviceVolume(int mmfVolume); + virtual int openFile(RFile& file); + virtual void close(); + + // MediaObjectInterface + virtual bool hasVideo() const; + virtual qint64 currentTime() const; + virtual qint64 totalTime() const; + + // MVideoPlayerUtilityObserver + virtual void MvpuoOpenComplete(TInt aError); + virtual void MvpuoPrepareComplete(TInt aError); + virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); + virtual void MvpuoPlayComplete(TInt aError); + virtual void MvpuoEvent(const TMMFEvent &aEvent); + + // VideoOutputObserver + virtual void videoOutputRegionChanged(); + +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void finished(); + +private: + void construct(); + VideoOutput& videoOutput(); + + void doPrepareCompleteL(TInt aError); + + // AbstractPlayer + virtual void videoOutputChanged(); + + void getNativeWindowSystemHandles(); + +private: + CVideoPlayerUtility* m_player; + QScopedPointer m_dummyVideoOutput; + + // Not owned + RWsSession* m_wsSession; + CWsScreenDevice* m_screenDevice; + RWindowBase* m_window; + TRect m_windowRect; + TRect m_clipRect; + + QSize m_frameSize; + qint64 m_totalTime; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index ae94e5e..be3c752 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -29,11 +29,11 @@ using namespace Phonon::MMF; // Constants //----------------------------------------------------------------------------- -static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio = - Phonon::VideoWidget::AspectRatioAuto; +static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio = + Phonon::VideoWidget::AspectRatioAuto; static const qreal DefaultBrightness = 1.0; -static const Phonon::VideoWidget::ScaleMode DefaultScaleMode = - Phonon::VideoWidget::FitInView; +static const Phonon::VideoWidget::ScaleMode DefaultScaleMode = + Phonon::VideoWidget::FitInView; static const qreal DefaultContrast = 1.0; static const qreal DefaultHue = 1.0; static const qreal DefaultSaturation = 1.0; @@ -44,27 +44,27 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : QObject(parent) - , m_widget(new VideoOutput(parent)) - , m_aspectRatio(DefaultAspectRatio) - , m_brightness(DefaultBrightness) - , m_scaleMode(DefaultScaleMode) - , m_contrast(DefaultContrast) - , m_hue(DefaultHue) - , m_saturation(DefaultSaturation) + : QObject(parent) + , m_widget(new VideoOutput(parent)) + , m_aspectRatio(DefaultAspectRatio) + , m_brightness(DefaultBrightness) + , m_scaleMode(DefaultScaleMode) + , m_contrast(DefaultContrast) + , m_hue(DefaultHue) + , m_saturation(DefaultSaturation) { - TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); - TRACE_ENTRY_0(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } MMF::VideoWidget::~VideoWidget() { - TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi); - TRACE_ENTRY_0(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } @@ -74,91 +74,91 @@ MMF::VideoWidget::~VideoWidget() Phonon::VideoWidget::AspectRatio MMF::VideoWidget::aspectRatio() const { - return m_aspectRatio; + return m_aspectRatio; } void MMF::VideoWidget::setAspectRatio - (Phonon::VideoWidget::AspectRatio aspectRatio) +(Phonon::VideoWidget::AspectRatio aspectRatio) { - TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi); - TRACE("aspectRatio %d", aspectRatio); + TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi); + TRACE("aspectRatio %d", aspectRatio); - m_aspectRatio = aspectRatio; + m_aspectRatio = aspectRatio; } qreal MMF::VideoWidget::brightness() const { - return m_brightness; + return m_brightness; } void MMF::VideoWidget::setBrightness(qreal brightness) { - TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi); - TRACE("brightness %f", brightness); + TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi); + TRACE("brightness %f", brightness); - m_brightness = brightness; + m_brightness = brightness; } Phonon::VideoWidget::ScaleMode MMF::VideoWidget::scaleMode() const { - return m_scaleMode; + return m_scaleMode; } void MMF::VideoWidget::setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode) { - TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi); - TRACE("setScaleMode %d", setScaleMode); + TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi); + TRACE("setScaleMode %d", setScaleMode); - m_scaleMode = scaleMode; + m_scaleMode = scaleMode; } qreal MMF::VideoWidget::contrast() const { - return m_contrast; + return m_contrast; } void MMF::VideoWidget::setContrast(qreal contrast) { - TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi); - TRACE("contrast %f", contrast); + TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi); + TRACE("contrast %f", contrast); - m_contrast = contrast; + m_contrast = contrast; } qreal MMF::VideoWidget::hue() const { - return m_hue; + return m_hue; } void MMF::VideoWidget::setHue(qreal hue) { - TRACE_CONTEXT(VideoWidget::setHue, EVideoApi); - TRACE("hue %f", hue); + TRACE_CONTEXT(VideoWidget::setHue, EVideoApi); + TRACE("hue %f", hue); - m_hue = hue; + m_hue = hue; } qreal MMF::VideoWidget::saturation() const { - return m_saturation; + return m_saturation; } void MMF::VideoWidget::setSaturation(qreal saturation) { - TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi); - TRACE("saturation %f", saturation); + TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi); + TRACE("saturation %f", saturation); - m_saturation = saturation; + m_saturation = saturation; } QWidget* MMF::VideoWidget::widget() { - return m_widget.data(); + return m_widget.data(); } VideoOutput& MMF::VideoWidget::videoOutput() { - return *static_cast(widget()); + return *static_cast(widget()); } diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 799121b..e2e1f33 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -27,49 +27,49 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class VideoOutput; - - class VideoWidget : public QObject - , public Phonon::VideoWidgetInterface - { - Q_OBJECT - Q_INTERFACES(Phonon::VideoWidgetInterface) - - public: - VideoWidget(QWidget* parent); - ~VideoWidget(); - - // VideoWidgetInterface - virtual Phonon::VideoWidget::AspectRatio aspectRatio() const; - virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio aspectRatio); - virtual qreal brightness() const; - virtual void setBrightness(qreal brightness); - virtual Phonon::VideoWidget::ScaleMode scaleMode() const; - virtual void setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode); - virtual qreal contrast() const; - virtual void setContrast(qreal constrast); - virtual qreal hue() const; - virtual void setHue(qreal hue); - virtual qreal saturation() const; - virtual void setSaturation(qreal saturation); - virtual QWidget *widget(); - - VideoOutput& videoOutput(); - - private: - QScopedPointer m_widget; - - Phonon::VideoWidget::AspectRatio m_aspectRatio; - qreal m_brightness; - Phonon::VideoWidget::ScaleMode m_scaleMode; - qreal m_contrast; - qreal m_hue; - qreal m_saturation; - - }; - } +namespace MMF +{ +class VideoOutput; + +class VideoWidget : public QObject + , public Phonon::VideoWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::VideoWidgetInterface) + +public: + VideoWidget(QWidget* parent); + ~VideoWidget(); + + // VideoWidgetInterface + virtual Phonon::VideoWidget::AspectRatio aspectRatio() const; + virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio aspectRatio); + virtual qreal brightness() const; + virtual void setBrightness(qreal brightness); + virtual Phonon::VideoWidget::ScaleMode scaleMode() const; + virtual void setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode); + virtual qreal contrast() const; + virtual void setContrast(qreal constrast); + virtual qreal hue() const; + virtual void setHue(qreal hue); + virtual qreal saturation() const; + virtual void setSaturation(qreal saturation); + virtual QWidget *widget(); + + VideoOutput& videoOutput(); + +private: + QScopedPointer m_widget; + + Phonon::VideoWidget::AspectRatio m_aspectRatio; + qreal m_brightness; + Phonon::VideoWidget::ScaleMode m_scaleMode; + qreal m_contrast; + qreal m_hue; + qreal m_saturation; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/volumeobserver.h b/src/3rdparty/phonon/mmf/volumeobserver.h index d6717cba..bedd3de 100644 --- a/src/3rdparty/phonon/mmf/volumeobserver.h +++ b/src/3rdparty/phonon/mmf/volumeobserver.h @@ -25,18 +25,18 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * Interface used by AudioOutput to pass volume control commands - * back along the audio path to the MediaObject. - */ - class VolumeObserver - { - public: - virtual void volumeChanged(qreal volume) = 0; - }; - } +namespace MMF +{ +/** + * Interface used by AudioOutput to pass volume control commands + * back along the audio path to the MediaObject. + */ +class VolumeObserver +{ +public: + virtual void volumeChanged(qreal volume) = 0; +}; +} } QT_END_NAMESPACE -- cgit v0.12 From 591e949eb0164d639f8db9f24038fc7949a1036d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 13:51:35 +0100 Subject: Reformatted code to comply with Qt style --- src/3rdparty/phonon/mmf/TODO.txt | 5 - src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 347 ++++++++++---------- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 247 +++++++------- src/3rdparty/phonon/mmf/abstractplayer.cpp | 24 +- src/3rdparty/phonon/mmf/abstractplayer.h | 142 ++++----- src/3rdparty/phonon/mmf/audiooutput.cpp | 33 +- src/3rdparty/phonon/mmf/audiooutput.h | 120 +++---- src/3rdparty/phonon/mmf/audioplayer.cpp | 127 ++++---- src/3rdparty/phonon/mmf/audioplayer.h | 114 +++---- src/3rdparty/phonon/mmf/backend.cpp | 177 +++++------ src/3rdparty/phonon/mmf/backend.h | 46 +-- src/3rdparty/phonon/mmf/defs.h | 27 +- src/3rdparty/phonon/mmf/dummyplayer.cpp | 6 +- src/3rdparty/phonon/mmf/dummyplayer.h | 90 +++--- src/3rdparty/phonon/mmf/mediaobject.cpp | 343 +++++++++----------- src/3rdparty/phonon/mmf/mediaobject.h | 176 +++++----- src/3rdparty/phonon/mmf/utils.cpp | 24 +- src/3rdparty/phonon/mmf/utils.h | 250 +++++++-------- src/3rdparty/phonon/mmf/videooutput.cpp | 126 ++++---- src/3rdparty/phonon/mmf/videooutput.h | 68 ++-- src/3rdparty/phonon/mmf/videooutputobserver.h | 24 +- src/3rdparty/phonon/mmf/videoplayer.cpp | 407 ++++++++++++------------ src/3rdparty/phonon/mmf/videoplayer.h | 150 ++++----- src/3rdparty/phonon/mmf/videowidget.cpp | 94 +++--- src/3rdparty/phonon/mmf/videowidget.h | 86 ++--- src/3rdparty/phonon/mmf/volumeobserver.h | 24 +- 26 files changed, 1591 insertions(+), 1686 deletions(-) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 7f20793..846f0bb 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -37,9 +37,4 @@ Compare video frame rate obtained using default S60 media player and Qt demo app * Implement MMF::Backend::disconnectNodes This should probably be left for now, particularly until audio effects have been implemented. This is because the node connection mechanism may need to be refactored slightly once we start building up longer graphs (e.g. MediaObject -> Effect -> Effect -> AudioOutput). -* Fix code layout -My editor was set to use tabs for indenting, rather than the Qt standard of 4 spaces. So we can either: - 1. Do "s/\t/ /g" - which will just fix the indenting - 2. Use http://astyle.sourceforge.net/: - astyle --indent=spaces=4 --brackets=linux --indent-labels --pad=oper --unpad=paren --one-line=keep-statements --convert-tabs --indent-preprocessor --recursive ./ diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 7883709..1e032f3 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -29,7 +29,7 @@ using namespace Phonon::MMF; // Constants //----------------------------------------------------------------------------- -const int NullMaxVolume = -1; +const int NullMaxVolume = -1; //----------------------------------------------------------------------------- @@ -37,31 +37,31 @@ const int NullMaxVolume = -1; //----------------------------------------------------------------------------- MMF::AbstractMediaPlayer::AbstractMediaPlayer() : - m_state(GroundState) - , m_error(NoError) - , m_playPending(false) - , m_tickTimer(new QTimer(this)) - , m_volume(InitialVolume) - , m_mmfMaxVolume(NullMaxVolume) + m_state(GroundState) + , m_error(NoError) + , m_playPending(false) + , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) + , m_mmfMaxVolume(NullMaxVolume) { - connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); } MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) : - AbstractPlayer(player) - , m_state(GroundState) - , m_error(NoError) - , m_playPending(false) - , m_tickTimer(new QTimer(this)) - , m_volume(InitialVolume) - , m_mmfMaxVolume(NullMaxVolume) + AbstractPlayer(player) + , m_state(GroundState) + , m_error(NoError) + , m_playPending(false) + , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) + , m_mmfMaxVolume(NullMaxVolume) { - connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); } MMF::AbstractMediaPlayer::~AbstractMediaPlayer() { - + } @@ -74,34 +74,33 @@ void MMF::AbstractMediaPlayer::play() TRACE_CONTEXT(AbstractMediaPlayer::play, EAudioApi); TRACE_ENTRY("state %d", m_state); - switch(m_state) - { - case GroundState: - // Is this the correct error? Really we want 'NotReadyError' - m_error = NormalError; - changeState(ErrorState); - break; - - case LoadingState: - m_playPending = true; - break; - - case StoppedState: - case PausedState: - doPlay(); - startTickTimer(); - changeState(PlayingState); - break; - - case PlayingState: - case BufferingState: - case ErrorState: - // Do nothing - break; + switch (m_state) { + case GroundState: + // Is this the correct error? Really we want 'NotReadyError' + m_error = NormalError; + changeState(ErrorState); + break; + + case LoadingState: + m_playPending = true; + break; + + case StoppedState: + case PausedState: + doPlay(); + startTickTimer(); + changeState(PlayingState); + break; + + case PlayingState: + case BufferingState: + case ErrorState: + // Do nothing + break; // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); + default: + TRACE_PANIC(InvalidStatePanic); } TRACE_EXIT("state %d", m_state); @@ -113,27 +112,26 @@ void MMF::AbstractMediaPlayer::pause() TRACE_ENTRY("state %d", m_state); m_playPending = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case PausedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - doPause(); - stopTickTimer(); - changeState(PausedState); - break; + + switch (m_state) { + case GroundState: + case LoadingState: + case StoppedState: + case PausedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + doPause(); + stopTickTimer(); + changeState(PausedState); + break; // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); + default: + TRACE_PANIC(InvalidStatePanic); } TRACE_EXIT("state %d", m_state); @@ -145,27 +143,26 @@ void MMF::AbstractMediaPlayer::stop() TRACE_ENTRY("state %d", m_state); m_playPending = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - case PausedState: - doStop(); - stopTickTimer(); - changeState(StoppedState); - break; + + switch (m_state) { + case GroundState: + case LoadingState: + case StoppedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + case PausedState: + doStop(); + stopTickTimer(); + changeState(StoppedState); + break; // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); + default: + TRACE_PANIC(InvalidStatePanic); } TRACE_EXIT("state %d", m_state); @@ -177,23 +174,22 @@ void MMF::AbstractMediaPlayer::seek(qint64 ms) TRACE_ENTRY("state %d pos %Ld", state(), ms); // TODO: put a state guard in here - + const bool tickTimerWasRunning = m_tickTimer->isActive(); stopTickTimer(); - + doSeek(ms); - - if(tickTimerWasRunning) - { + + if (tickTimerWasRunning) { startTickTimer(); } - + TRACE_EXIT_0(); } bool MMF::AbstractMediaPlayer::isSeekable() const { - return true; + return true; } void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) @@ -209,7 +205,7 @@ void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) Phonon::ErrorType MMF::AbstractMediaPlayer::errorType() const { const Phonon::ErrorType result = (ErrorState == m_state) - ? m_error : NoError; + ? m_error : NoError; return result; } @@ -244,58 +240,52 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f TInt symbianErr = KErrNone; - switch(m_source.type()) - { - case MediaSource::LocalFile: - { - // TODO: work out whose responsibility it is to ensure that paths - // are Symbian-style, i.e. have backslashes for path delimiters. - // Until then, use this utility function... - //const QHBufC filename = Utils::symbianFilename(m_source.fileName()); - //TRAP(symbianErr, m_player->OpenFileL(*filename)); - - // Open using shared filehandle - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //TRAP(symbianErr, m_player->OpenFileL(file)); - - symbianErr = openFile(file); - break; - } + switch (m_source.type()) { + case MediaSource::LocalFile: { + // TODO: work out whose responsibility it is to ensure that paths + // are Symbian-style, i.e. have backslashes for path delimiters. + // Until then, use this utility function... + //const QHBufC filename = Utils::symbianFilename(m_source.fileName()); + //TRAP(symbianErr, m_player->OpenFileL(*filename)); + + // Open using shared filehandle + // This is a temporary hack to work around KErrInUse from MMF + // client utility OpenFileL calls + //TRAP(symbianErr, m_player->OpenFileL(file)); + + symbianErr = openFile(file); + break; + } - case MediaSource::Url: - { - TRACE_0("Source type not supported"); - // TODO: support opening URLs - symbianErr = KErrNotSupported; - break; - } + case MediaSource::Url: { + TRACE_0("Source type not supported"); + // TODO: support opening URLs + symbianErr = KErrNotSupported; + break; + } - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - TRACE_0("Source type not supported"); - symbianErr = KErrNotSupported; - break; + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + TRACE_0("Source type not supported"); + symbianErr = KErrNotSupported; + break; - case MediaSource::Empty: - TRACE_0("Empty source - doing nothing"); - TRACE_EXIT_0(); - return; + case MediaSource::Empty: + TRACE_0("Empty source - doing nothing"); + TRACE_EXIT_0(); + return; // Protection against adding new media types and forgetting to update this switch - default: - TRACE_PANIC(InvalidMediaTypePanic); + default: + TRACE_PANIC(InvalidMediaTypePanic); } - if(KErrNone == symbianErr) - { + if (KErrNone == symbianErr) { changeState(LoadingState); - } - else - { - TRACE("error %d", symbianErr) - + } else { + TRACE("error %d", symbianErr) + // TODO: do something with the value of symbianErr? m_error = NormalError; changeState(ErrorState); @@ -326,44 +316,41 @@ void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) { TRACE_CONTEXT(AbstractMediaPlayer::volumeChanged, EAudioInternal); TRACE_ENTRY("state %d", m_state); - + m_volume = volume; doVolumeChanged(); - + TRACE_EXIT_0(); } void MMF::AbstractMediaPlayer::doVolumeChanged() { - switch(m_state) - { - case GroundState: - case LoadingState: - case ErrorState: - // Do nothing - break; - - case StoppedState: - case PausedState: - case PlayingState: - case BufferingState: - { - const int err = setDeviceVolume(m_volume * m_mmfMaxVolume); - - if(KErrNone != err) - { - m_error = NormalError; - changeState(ErrorState); - } - break; - } - - // Protection against adding new states and forgetting to update this - // switch - default: - Utils::panic(InvalidStatePanic); - } + switch (m_state) { + case GroundState: + case LoadingState: + case ErrorState: + // Do nothing + break; + + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: { + const int err = setDeviceVolume(m_volume * m_mmfMaxVolume); + + if (KErrNone != err) { + m_error = NormalError; + changeState(ErrorState); + } + break; + } + + // Protection against adding new states and forgetting to update this + // switch + default: + Utils::panic(InvalidStatePanic); + } } @@ -373,23 +360,23 @@ void MMF::AbstractMediaPlayer::doVolumeChanged() void MMF::AbstractMediaPlayer::startTickTimer() { - m_tickTimer->start(tickInterval()); + m_tickTimer->start(tickInterval()); } void MMF::AbstractMediaPlayer::stopTickTimer() { - m_tickTimer->stop(); + m_tickTimer->stop(); } void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) { - m_mmfMaxVolume = mmfMaxVolume; - doVolumeChanged(); + m_mmfMaxVolume = mmfMaxVolume; + doVolumeChanged(); } Phonon::State MMF::AbstractMediaPlayer::phononState() const { - return phononState(m_state); + return phononState(m_state); } Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) @@ -411,27 +398,25 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) const Phonon::State oldPhononState = phononState(m_state); const Phonon::State newPhononState = phononState(newState); - if(oldPhononState != newPhononState) - { + if (oldPhononState != newPhononState) { TRACE("emit stateChanged(%d, %d)", newPhononState, oldPhononState); emit stateChanged(newPhononState, oldPhononState); } m_state = newState; - + // Check whether play() was called while clip was being loaded. If so, // playback should be started now - if( - LoadingState == oldPhononState - and StoppedState == newPhononState - and m_playPending - ) - { - TRACE_0("play was called while loading; starting playback now"); - m_playPending = false; - play(); + if ( + LoadingState == oldPhononState + and StoppedState == newPhononState + and m_playPending + ) { + TRACE_0("play was called while loading; starting playback now"); + m_playPending = false; + play(); } - + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 51935a3..f11b559 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -30,130 +30,129 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class AudioOutput; - - /** - * Interface via which MMF client APIs for both audio and video can be - * accessed. - */ - class AbstractMediaPlayer : public AbstractPlayer - { - Q_OBJECT - - protected: - AbstractMediaPlayer(); - explicit AbstractMediaPlayer(const AbstractPlayer& player); - ~AbstractMediaPlayer(); - - public: - // MediaObjectInterface - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual bool isSeekable() const; - virtual Phonon::ErrorType errorType() const; - virtual QString errorString() const; - virtual Phonon::State state() const; - virtual MediaSource source() const; - virtual void setFileSource(const Phonon::MediaSource&, RFile&); - virtual void setNextSource(const MediaSource &source); - - // VolumeObserver - virtual void volumeChanged(qreal volume); - - protected: - // AbstractPlayer - virtual void doSetTickInterval(qint32 interval); - - protected: - virtual void doPlay() = 0; - virtual void doPause() = 0; - virtual void doStop() = 0; - virtual void doSeek(qint64 pos) = 0; - virtual int setDeviceVolume(int mmfVolume) = 0; - virtual int openFile(RFile& file) = 0; - virtual void close() = 0; - - protected: - bool tickTimerRunning() const; - void startTickTimer(); - void stopTickTimer(); - void maxVolumeChanged(int maxVolume); - - /** - * Defined private state enumeration in order to add GroundState - */ - enum PrivateState - { - LoadingState = Phonon::LoadingState, - StoppedState = Phonon::StoppedState, - PlayingState = Phonon::PlayingState, - BufferingState = Phonon::BufferingState, - PausedState = Phonon::PausedState, - ErrorState = Phonon::ErrorState, - GroundState - }; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - Phonon::State phononState() const; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - static Phonon::State phononState(PrivateState state); - - /** - * Changes state and emits stateChanged() - */ - void changeState(PrivateState newState); - - /** - * Records error and changes state to ErrorState - */ - void setError(Phonon::ErrorType error); - - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - private: - void doVolumeChanged(); - - Q_SIGNALS: - void tick(qint64 time); - void stateChanged(Phonon::State oldState, - Phonon::State newState); - - private Q_SLOTS: - /** - * Receives signal from m_tickTimer - */ - void tick(); - - private: - PrivateState m_state; - Phonon::ErrorType m_error; - - /** - * This flag is set to true if play is called when the object is - * in a Loading state. Once loading is complete, playback will - * be started. - */ - bool m_playPending; - - QScopedPointer m_tickTimer; - - qreal m_volume; - int m_mmfMaxVolume; - - MediaSource m_source; - MediaSource m_nextSource; - - }; - } +namespace MMF +{ +class AudioOutput; + +/** + * Interface via which MMF client APIs for both audio and video can be + * accessed. + */ +class AbstractMediaPlayer : public AbstractPlayer +{ + Q_OBJECT + +protected: + AbstractMediaPlayer(); + explicit AbstractMediaPlayer(const AbstractPlayer& player); + ~AbstractMediaPlayer(); + +public: + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual bool isSeekable() const; + virtual Phonon::ErrorType errorType() const; + virtual QString errorString() const; + virtual Phonon::State state() const; + virtual MediaSource source() const; + virtual void setFileSource(const Phonon::MediaSource&, RFile&); + virtual void setNextSource(const MediaSource &source); + + // VolumeObserver + virtual void volumeChanged(qreal volume); + +protected: + // AbstractPlayer + virtual void doSetTickInterval(qint32 interval); + +protected: + virtual void doPlay() = 0; + virtual void doPause() = 0; + virtual void doStop() = 0; + virtual void doSeek(qint64 pos) = 0; + virtual int setDeviceVolume(int mmfVolume) = 0; + virtual int openFile(RFile& file) = 0; + virtual void close() = 0; + +protected: + bool tickTimerRunning() const; + void startTickTimer(); + void stopTickTimer(); + void maxVolumeChanged(int maxVolume); + + /** + * Defined private state enumeration in order to add GroundState + */ + enum PrivateState { + LoadingState = Phonon::LoadingState, + StoppedState = Phonon::StoppedState, + PlayingState = Phonon::PlayingState, + BufferingState = Phonon::BufferingState, + PausedState = Phonon::PausedState, + ErrorState = Phonon::ErrorState, + GroundState + }; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + Phonon::State phononState() const; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + static Phonon::State phononState(PrivateState state); + + /** + * Changes state and emits stateChanged() + */ + void changeState(PrivateState newState); + + /** + * Records error and changes state to ErrorState + */ + void setError(Phonon::ErrorType error); + + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + +private: + void doVolumeChanged(); + +Q_SIGNALS: + void tick(qint64 time); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + +private Q_SLOTS: + /** + * Receives signal from m_tickTimer + */ + void tick(); + +private: + PrivateState m_state; + Phonon::ErrorType m_error; + + /** + * This flag is set to true if play is called when the object is + * in a Loading state. Once loading is complete, playback will + * be started. + */ + bool m_playPending; + + QScopedPointer m_tickTimer; + + qreal m_volume; + int m_mmfMaxVolume; + + MediaSource m_source; + MediaSource m_nextSource; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 328ab37..c6f0f6b 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -30,19 +30,19 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::AbstractPlayer::AbstractPlayer() - : m_videoOutput(NULL) - , m_tickInterval(DefaultTickInterval) - , m_transitionTime(0) - , m_prefinishMark(0) + : m_videoOutput(NULL) + , m_tickInterval(DefaultTickInterval) + , m_transitionTime(0) + , m_prefinishMark(0) { } MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) - : m_videoOutput(player.m_videoOutput) - , m_tickInterval(player.tickInterval()) - , m_transitionTime(player.transitionTime()) - , m_prefinishMark(player.prefinishMark()) + : m_videoOutput(player.m_videoOutput) + , m_tickInterval(player.tickInterval()) + , m_transitionTime(player.transitionTime()) + , m_prefinishMark(player.prefinishMark()) { } @@ -64,17 +64,17 @@ void MMF::AbstractPlayer::setTickInterval(qint32 interval) qint32 MMF::AbstractPlayer::prefinishMark() const { - return m_prefinishMark; + return m_prefinishMark; } void MMF::AbstractPlayer::setPrefinishMark(qint32 mark) { - m_prefinishMark = mark; + m_prefinishMark = mark; } qint32 MMF::AbstractPlayer::transitionTime() const { - return m_transitionTime; + return m_transitionTime; } void MMF::AbstractPlayer::setTransitionTime(qint32 time) @@ -95,7 +95,7 @@ void MMF::AbstractPlayer::setVideoOutput(VideoOutput* videoOutput) void MMF::AbstractPlayer::videoOutputChanged() { - // Default behaviour is empty - overridden by VideoPlayer + // Default behaviour is empty - overridden by VideoPlayer } diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 399cd5d..da0fe51 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -34,77 +34,77 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class VideoOutput; - - /** - * @short Interface which abstracts from MediaObject the current - * media type - * - * This may be: - * - Nothing, in which case this interface is implemented by - * DummyPlayer - * - Audio, in which case the implementation is AudioPlayer - * - Video, in which case the implementation is VideoPlayer - */ - class AbstractPlayer : public QObject - , public VolumeObserver - { - // Required although this class has no signals or slots - // Without this, qobject_cast will fail - Q_OBJECT - - public: - AbstractPlayer(); - explicit AbstractPlayer(const AbstractPlayer& player); - - // MediaObjectInterface (implemented) - qint32 tickInterval() const; - void setTickInterval(qint32); - void setTransitionTime(qint32); - qint32 transitionTime() const; - void setPrefinishMark(qint32); - qint32 prefinishMark() const; - - // MediaObjectInterface (abstract) - virtual void play() = 0; - virtual void pause() = 0; - virtual void stop() = 0; - virtual void seek(qint64 milliseconds) = 0; - virtual bool hasVideo() const = 0; - virtual bool isSeekable() const = 0; - virtual qint64 currentTime() const = 0; - virtual Phonon::State state() const = 0; - virtual QString errorString() const = 0; - virtual Phonon::ErrorType errorType() const = 0; - virtual qint64 totalTime() const = 0; - virtual Phonon::MediaSource source() const = 0; - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //virtual void setSource(const Phonon::MediaSource &) = 0; - virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; - virtual void setNextSource(const Phonon::MediaSource &) = 0; - - void setVideoOutput(VideoOutput* videoOutput); - - protected: - virtual void videoOutputChanged(); - - private: - virtual void doSetTickInterval(qint32 interval) = 0; - - protected: - // Not owned - VideoOutput* m_videoOutput; - - private: - qint32 m_tickInterval; - qint32 m_transitionTime; - qint32 m_prefinishMark; - - }; - } +namespace MMF +{ +class VideoOutput; + +/** + * @short Interface which abstracts from MediaObject the current + * media type + * + * This may be: + * - Nothing, in which case this interface is implemented by + * DummyPlayer + * - Audio, in which case the implementation is AudioPlayer + * - Video, in which case the implementation is VideoPlayer + */ +class AbstractPlayer : public QObject + , public VolumeObserver +{ + // Required although this class has no signals or slots + // Without this, qobject_cast will fail + Q_OBJECT + +public: + AbstractPlayer(); + explicit AbstractPlayer(const AbstractPlayer& player); + + // MediaObjectInterface (implemented) + qint32 tickInterval() const; + void setTickInterval(qint32); + void setTransitionTime(qint32); + qint32 transitionTime() const; + void setPrefinishMark(qint32); + qint32 prefinishMark() const; + + // MediaObjectInterface (abstract) + virtual void play() = 0; + virtual void pause() = 0; + virtual void stop() = 0; + virtual void seek(qint64 milliseconds) = 0; + virtual bool hasVideo() const = 0; + virtual bool isSeekable() const = 0; + virtual qint64 currentTime() const = 0; + virtual Phonon::State state() const = 0; + virtual QString errorString() const = 0; + virtual Phonon::ErrorType errorType() const = 0; + virtual qint64 totalTime() const = 0; + virtual Phonon::MediaSource source() const = 0; + // This is a temporary hack to work around KErrInUse from MMF + // client utility OpenFileL calls + //virtual void setSource(const Phonon::MediaSource &) = 0; + virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; + virtual void setNextSource(const Phonon::MediaSource &) = 0; + + void setVideoOutput(VideoOutput* videoOutput); + +protected: + virtual void videoOutputChanged(); + +private: + virtual void doSetTickInterval(qint32 interval) = 0; + +protected: + // Not owned + VideoOutput* m_videoOutput; + +private: + qint32 m_tickInterval; + qint32 m_transitionTime; + qint32 m_prefinishMark; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 099c899..909e568 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -33,9 +33,9 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) - , m_volume(InitialVolume) - , m_observer(NULL) +MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) + , m_volume(InitialVolume) + , m_observer(NULL) { } @@ -47,7 +47,7 @@ MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) qreal MMF::AudioOutput::volume() const { - return m_volume; + return m_volume; } void MMF::AudioOutput::setVolume(qreal volume) @@ -55,18 +55,16 @@ void MMF::AudioOutput::setVolume(qreal volume) TRACE_CONTEXT(AudioOutput::setVolume, EAudioApi); TRACE_ENTRY("observer 0x%08x volume %f", m_observer, volume); - if(volume != m_volume) - { - if(m_observer) - { - m_observer->volumeChanged(volume); - } - - m_volume = volume; - TRACE("emit volumeChanged(%f)", volume) - emit volumeChanged(volume); + if (volume != m_volume) { + if (m_observer) { + m_observer->volumeChanged(volume); + } + + m_volume = volume; + TRACE("emit volumeChanged(%f)", volume) + emit volumeChanged(volume); } - + TRACE_EXIT_0(); } @@ -88,9 +86,8 @@ bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer) { m_observer = observer; - if(m_observer) - { - m_observer->volumeChanged(m_volume); + if (m_observer) { + m_observer->volumeChanged(m_volume); } } diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index ab90c44..001190f 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -25,66 +25,66 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class Backend; - class VolumeObserver; - - /** - * @short AudioOutputInterface implementation for MMF. - * - * Forwards volume commands to the VolumeObserver instance, - * which is provided by the backend when MediaNode objects are - * connected. - * - * \section volume Volume - * - * Phonon's concept on volume is from 0.0 to 1.0, and from 1< it does - * voltage multiplication. CDrmPlayerUtility goes from 1 to - * CDrmPlayerUtility::MaxVolume(). We apply some basic math to convert - * between the two. - * - * @author Frans Englich - */ - class AudioOutput : public QObject - , public AudioOutputInterface - { - Q_OBJECT - Q_INTERFACES(Phonon::AudioOutputInterface) - - public: - AudioOutput(Backend *backend, QObject *parent); - virtual qreal volume() const; - virtual void setVolume(qreal volume); - - virtual int outputDevice() const; - - /** - * Has no effect. - */ - virtual bool setOutputDevice(int); - - /** - * Has no effect. - */ - virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); - - /** - * Called by backend when nodes are connected. - */ - void setVolumeObserver(VolumeObserver* observer); - - Q_SIGNALS: - void volumeChanged(qreal volume); - void audioDeviceFailed(); - - private: - qreal m_volume; - - // Not owned - VolumeObserver* m_observer; - }; - } +namespace MMF +{ +class Backend; +class VolumeObserver; + +/** + * @short AudioOutputInterface implementation for MMF. + * + * Forwards volume commands to the VolumeObserver instance, + * which is provided by the backend when MediaNode objects are + * connected. + * + * \section volume Volume + * + * Phonon's concept on volume is from 0.0 to 1.0, and from 1< it does + * voltage multiplication. CDrmPlayerUtility goes from 1 to + * CDrmPlayerUtility::MaxVolume(). We apply some basic math to convert + * between the two. + * + * @author Frans Englich + */ +class AudioOutput : public QObject + , public AudioOutputInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::AudioOutputInterface) + +public: + AudioOutput(Backend *backend, QObject *parent); + virtual qreal volume() const; + virtual void setVolume(qreal volume); + + virtual int outputDevice() const; + + /** + * Has no effect. + */ + virtual bool setOutputDevice(int); + + /** + * Has no effect. + */ + virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); + + /** + * Called by backend when nodes are connected. + */ + void setVolumeObserver(VolumeObserver* observer); + +Q_SIGNALS: + void volumeChanged(qreal volume); + void audioDeviceFailed(); + +private: + qreal m_volume; + + // Not owned + VolumeObserver* m_observer; +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 50048c8..1229625 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -30,32 +30,31 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioPlayer::AudioPlayer() : m_player(NULL) +MMF::AudioPlayer::AudioPlayer() : m_player(NULL) { - construct(); + construct(); } MMF::AudioPlayer::AudioPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) - , m_player(NULL) + : AbstractMediaPlayer(player) + , m_player(NULL) { - construct(); + construct(); } void MMF::AudioPlayer::construct() { - TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); - TRACE_ENTRY_0(); - - // TODO: is this the correct way to handle errors which occur when - // creating a Symbian object in the constructor of a Qt object? - TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); - if(KErrNone != err) - { - changeState(ErrorState); - } - - TRACE_EXIT_0(); + TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); + TRACE_ENTRY_0(); + + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? + TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); + if (KErrNone != err) { + changeState(ErrorState); + } + + TRACE_EXIT_0(); } MMF::AudioPlayer::~AudioPlayer() @@ -74,17 +73,17 @@ MMF::AudioPlayer::~AudioPlayer() void MMF::AudioPlayer::doPlay() { - m_player->Play(); + m_player->Play(); } void MMF::AudioPlayer::doPause() { - m_player->Pause(); + m_player->Pause(); } void MMF::AudioPlayer::doStop() { - m_player->Stop(); + m_player->Stop(); } void MMF::AudioPlayer::doSeek(qint64 ms) @@ -94,30 +93,29 @@ void MMF::AudioPlayer::doSeek(qint64 ms) int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) { - return m_player->SetVolume(mmfVolume); + return m_player->SetVolume(mmfVolume); } int MMF::AudioPlayer::openFile(RFile& file) { - TRAPD(err, m_player->OpenFileL(file)); - + TRAPD(err, m_player->OpenFileL(file)); + #ifdef QT_PHONON_MMF_AUDIO_DRM - if(KErrNone == err) - { + if (KErrNone == err) { // There appears to be a bug in the CDrmPlayerUtility implementation (at least // in S60 5.x) whereby the player does not check whether the loading observer // pointer is null before dereferencing it. Therefore we must register for // loading notification, even though we do nothing in the callback functions. m_player->RegisterForAudioLoadingNotification(*this); - } + } #endif - - return err; + + return err; } void MMF::AudioPlayer::close() { - m_player->Close(); + m_player->Close(); } bool MMF::AudioPlayer::hasVideo() const @@ -134,17 +132,14 @@ qint64 MMF::AudioPlayer::currentTime() const qint64 result = 0; - if(KErrNone == err) - { + if (KErrNone == err) { result = toMilliSeconds(us); - } - else - { - TRACE("GetPosition err %d", err); - - // If we don't cast away constness here, we simply have to ignore - // the error. - const_cast(this)->setError(NormalError); + } else { + TRACE("GetPosition err %d", err); + + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast(this)->setError(NormalError); } return result; @@ -162,10 +157,10 @@ qint64 MMF::AudioPlayer::totalTime() const #ifdef QT_PHONON_MMF_AUDIO_DRM void MMF::AudioPlayer::MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &) + const TTimeIntervalMicroSeconds &) #else void MMF::AudioPlayer::MapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &) + const TTimeIntervalMicroSeconds &) #endif { TRACE_CONTEXT(AudioPlayer::MapcInitComplete, EAudioInternal); @@ -173,15 +168,12 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - if(KErrNone == aError) - { - maxVolumeChanged(m_player->MaxVolume()); + if (KErrNone == aError) { + maxVolumeChanged(m_player->MaxVolume()); - emit totalTimeChanged(totalTime()); - changeState(StoppedState); - } - else - { + emit totalTimeChanged(totalTime()); + changeState(StoppedState); + } else { // TODO: set different error states according to value of aError? setError(NormalError); } @@ -200,33 +192,30 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) stopTickTimer(); - if(KErrNone == aError) - { + if (KErrNone == aError) { changeState(StoppedState); // TODO: move on to m_nextSource - } - else - { + } else { // TODO: do something with aError? setError(NormalError); } -/* - if(aError == KErrNone) { - if(m_nextSource.type() == MediaSource::Empty) { - emit finished(); - } else { - setSource(m_nextSource); - m_nextSource = MediaSource(); - } + /* + if(aError == KErrNone) { + if(m_nextSource.type() == MediaSource::Empty) { + emit finished(); + } else { + setSource(m_nextSource); + m_nextSource = MediaSource(); + } - changeState(StoppedState); - } - else { - m_error = NormalError; - changeState(ErrorState); - } -*/ + changeState(StoppedState); + } + else { + m_error = NormalError; + changeState(ErrorState); + } + */ TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index cdb6cb9..424985c 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -38,70 +38,70 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * @short Wrapper over MMF audio client utility - */ - class AudioPlayer : public AbstractMediaPlayer - , public MPlayerObserverType // typedef +namespace MMF +{ +/** + * @short Wrapper over MMF audio client utility + */ +class AudioPlayer : public AbstractMediaPlayer + , public MPlayerObserverType // typedef #ifdef QT_PHONON_MMF_AUDIO_DRM - , public MAudioLoadingObserver + , public MAudioLoadingObserver #endif - { - Q_OBJECT - - public: - AudioPlayer(); - explicit AudioPlayer(const AbstractPlayer& player); - virtual ~AudioPlayer(); - - // AbstractMediaPlayer - virtual void doPlay(); - virtual void doPause(); - virtual void doStop(); - virtual void doSeek(qint64 milliseconds); - virtual int setDeviceVolume(int mmfVolume); - virtual int openFile(RFile& file); - virtual void close(); - - // MediaObjectInterface - virtual bool hasVideo() const; - virtual qint64 currentTime() const; - virtual qint64 totalTime() const; +{ + Q_OBJECT + +public: + AudioPlayer(); + explicit AudioPlayer(const AbstractPlayer& player); + virtual ~AudioPlayer(); + + // AbstractMediaPlayer + virtual void doPlay(); + virtual void doPause(); + virtual void doStop(); + virtual void doSeek(qint64 milliseconds); + virtual int setDeviceVolume(int mmfVolume); + virtual int openFile(RFile& file); + virtual void close(); + + // MediaObjectInterface + virtual bool hasVideo() const; + virtual qint64 currentTime() const; + virtual qint64 totalTime() const; #ifdef QT_PHONON_MMF_AUDIO_DRM - // MDrmAudioPlayerCallback - virtual void MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MdapcPlayComplete(TInt aError); - - // MAudioLoadingObserver - virtual void MaloLoadingStarted(); - virtual void MaloLoadingComplete(); + // MDrmAudioPlayerCallback + virtual void MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MdapcPlayComplete(TInt aError); + + // MAudioLoadingObserver + virtual void MaloLoadingStarted(); + virtual void MaloLoadingComplete(); #else - // MMdaAudioPlayerCallback - virtual void MapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MapcPlayComplete(TInt aError); + // MMdaAudioPlayerCallback + virtual void MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MapcPlayComplete(TInt aError); #endif - Q_SIGNALS: - void totalTimeChanged(qint64 length); - void finished(); - - private: - void construct(); - - private: - /** - * Using CPlayerType typedef in order to be able to easily switch between - * CMdaAudioPlayerUtility and CDrmPlayerUtility - */ - CPlayerType* m_player; - - }; - } +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void finished(); + +private: + void construct(); + +private: + /** + * Using CPlayerType typedef in order to be able to easily switch between + * CMdaAudioPlayerUtility and CDrmPlayerUtility + */ + CPlayerType* m_player; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 236ef28..71e51d9 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -34,49 +34,48 @@ QT_BEGIN_NAMESPACE using namespace Phonon; using namespace Phonon::MMF; -Backend::Backend(QObject *parent) : QObject(parent) +Backend::Backend(QObject *parent) : QObject(parent) { - TRACE_CONTEXT(Backend::Backend, EBackend); - TRACE_ENTRY_0(); + TRACE_CONTEXT(Backend::Backend, EBackend); + TRACE_ENTRY_0(); setProperty("identifier", QLatin1String("phonon_mmf")); setProperty("backendName", QLatin1String("MMF")); setProperty("backendComment", QLatin1String("Backend using Symbian Multimedia Framework (MMF)")); setProperty("backendVersion", QLatin1String("0.1")); setProperty("backendWebsite", QLatin1String("http://www.qtsoftware.com/")); - + TRACE_EXIT_0(); } QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &) { - TRACE_CONTEXT(Backend::createObject, EBackend); - TRACE_ENTRY("class %d", c); - - QObject* result = NULL; - - switch(c) - { - case AudioOutputClass: - result = new AudioOutput(this, parent); - break; - - case MediaObjectClass: - result = new MediaObject(parent); - break; - - case VolumeFaderEffectClass: - case VisualizationClass: - case VideoDataOutputClass: - case EffectClass: - break; - - case VideoWidgetClass: - result = new VideoWidget(qobject_cast(parent)); - break; - - default: - TRACE_PANIC(InvalidBackendInterfaceClass); + TRACE_CONTEXT(Backend::createObject, EBackend); + TRACE_ENTRY("class %d", c); + + QObject* result = NULL; + + switch (c) { + case AudioOutputClass: + result = new AudioOutput(this, parent); + break; + + case MediaObjectClass: + result = new MediaObject(parent); + break; + + case VolumeFaderEffectClass: + case VisualizationClass: + case VideoDataOutputClass: + case EffectClass: + break; + + case VideoWidgetClass: + result = new VideoWidget(qobject_cast(parent)); + break; + + default: + TRACE_PANIC(InvalidBackendInterfaceClass); } TRACE_RETURN("0x%08x", result); @@ -99,46 +98,44 @@ bool Backend::startConnectionChange(QSet) bool Backend::connectNodes(QObject *source, QObject *target) { - TRACE_CONTEXT(Backend::connectNodes, EBackend); - TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); + TRACE_CONTEXT(Backend::connectNodes, EBackend); + TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - MediaObject *const mediaObject = qobject_cast(source); + MediaObject *const mediaObject = qobject_cast(source); AudioOutput *const audioOutput = qobject_cast(target); VideoWidget *const videoWidget = qobject_cast(target); - + bool result = false; - - if(mediaObject and audioOutput) - { - TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); - audioOutput->setVolumeObserver(mediaObject); - result = true; + + if (mediaObject and audioOutput) { + TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); + audioOutput->setVolumeObserver(mediaObject); + result = true; } - - if(mediaObject and videoWidget) - { - TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); - mediaObject->setVideoOutput(&videoWidget->videoOutput()); - result = true; - } - + + if (mediaObject and videoWidget) { + TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); + mediaObject->setVideoOutput(&videoWidget->videoOutput()); + result = true; + } + TRACE_RETURN("%d", result); } bool Backend::disconnectNodes(QObject *source, QObject *target) { - TRACE_CONTEXT(Backend::disconnectNodes, EBackend); - TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - - MediaObject *const mediaObject = qobject_cast(source); - AudioOutput *const audioOutput = qobject_cast(target); - VideoWidget *const videoWidget = qobject_cast(target); - - bool result = true; - - // TODO: disconnection - - TRACE_RETURN("%d", result); + TRACE_CONTEXT(Backend::disconnectNodes, EBackend); + TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); + + MediaObject *const mediaObject = qobject_cast(source); + AudioOutput *const audioOutput = qobject_cast(target); + VideoWidget *const videoWidget = qobject_cast(target); + + bool result = true; + + // TODO: disconnection + + TRACE_RETURN("%d", result); } bool Backend::endConnectionChange(QSet) @@ -148,40 +145,38 @@ bool Backend::endConnectionChange(QSet) void getAvailableMimeTypesL(QStringList& result) { - RApaLsSession apaSession; - User::LeaveIfError(apaSession.Connect()); - CleanupClosePushL(apaSession); - - static const TInt DataTypeArrayGranularity = 8; - CDataTypeArray* array = new (ELeave) CDataTypeArray(DataTypeArrayGranularity); - CleanupStack::PushL(array); - - apaSession.GetSupportedDataTypesL(*array); - - for(TInt i=0; iCount(); ++i) - { - const TPtrC mimeType = array->At(i).Des(); - const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType); - if(MediaTypeAudio == mediaType or MediaTypeVideo == mediaType) - { - result.append(qt_TDesC2QString(mimeType)); - } - } - - CleanupStack::PopAndDestroy(2); // apaSession, array + RApaLsSession apaSession; + User::LeaveIfError(apaSession.Connect()); + CleanupClosePushL(apaSession); + + static const TInt DataTypeArrayGranularity = 8; + CDataTypeArray* array = new(ELeave) CDataTypeArray(DataTypeArrayGranularity); + CleanupStack::PushL(array); + + apaSession.GetSupportedDataTypesL(*array); + + for (TInt i = 0; i < array->Count(); ++i) { + const TPtrC mimeType = array->At(i).Des(); + const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType); + if (MediaTypeAudio == mediaType or MediaTypeVideo == mediaType) { + result.append(qt_TDesC2QString(mimeType)); + } + } + + CleanupStack::PopAndDestroy(2); // apaSession, array } QStringList Backend::availableMimeTypes() const { - QStringList result; - - // There is no way to return an error from this function, so we just - // have to trap and ignore exceptions... - TRAP_IGNORE(getAvailableMimeTypesL(result)); - - result.sort(); - - return result; + QStringList result; + + // There is no way to return an error from this function, so we just + // have to trap and ignore exceptions... + TRAP_IGNORE(getAvailableMimeTypesL(result)); + + result.sort(); + + return result; } Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend); diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index b448187..7598fa7 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -26,29 +26,29 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class Backend : public QObject - , public BackendInterface - { - Q_OBJECT - Q_INTERFACES(Phonon::BackendInterface) - public: - Backend(QObject *parent = 0); - - virtual QObject *createObject(BackendInterface::Class c, QObject *parent, const QList &args); - virtual QList objectDescriptionIndexes(ObjectDescriptionType type) const; - virtual QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const; - virtual bool startConnectionChange(QSet); - virtual bool connectNodes(QObject *, QObject *); - virtual bool disconnectNodes(QObject *, QObject *); - virtual bool endConnectionChange(QSet); - virtual QStringList availableMimeTypes() const; - - Q_SIGNALS: - void objectDescriptionChanged(ObjectDescriptionType); - }; - } +namespace MMF +{ +class Backend : public QObject + , public BackendInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::BackendInterface) +public: + Backend(QObject *parent = 0); + + virtual QObject *createObject(BackendInterface::Class c, QObject *parent, const QList &args); + virtual QList objectDescriptionIndexes(ObjectDescriptionType type) const; + virtual QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const; + virtual bool startConnectionChange(QSet); + virtual bool connectNodes(QObject *, QObject *); + virtual bool disconnectNodes(QObject *, QObject *); + virtual bool endConnectionChange(QSet); + virtual QStringList availableMimeTypes() const; + +Q_SIGNALS: + void objectDescriptionChanged(ObjectDescriptionType); +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 37a25d1..674e767 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -21,11 +21,11 @@ along with this library. If not, see . #include -// The following macros are for switching on / off various bits of code, +// The following macros are for switching on / off various bits of code, // in order to debug the current problems with video visibility. // If this is defined, then VideoOutput is essentially just a typedef for -// QWidget. This is to allow us to test whether the QWidget function +// QWidget. This is to allow us to test whether the QWidget function // overrides present in VideoOutput (e.g. sizeHint, paintEvent etc) may // be the cause of the visibility problems. //#define PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET @@ -40,18 +40,17 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - static const qint32 DefaultTickInterval = 10; - static const qreal InitialVolume = 0.5; - - enum MediaType - { - MediaTypeUnknown, - MediaTypeAudio, - MediaTypeVideo - }; - } +namespace MMF +{ +static const qint32 DefaultTickInterval = 10; +static const qreal InitialVolume = 0.5; + +enum MediaType { + MediaTypeUnknown, + MediaTypeAudio, + MediaTypeVideo +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index dc7f8d1..dc55af7 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -29,13 +29,13 @@ using namespace Phonon::MMF; MMF::DummyPlayer::DummyPlayer() { - + } MMF::DummyPlayer::DummyPlayer(const AbstractPlayer& player) - : AbstractPlayer(player) + : AbstractPlayer(player) { - + } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 12e3bd8..b2725df 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -25,51 +25,51 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class AudioOutput; - - /** - * @short Stub implementation of AbstractPlayer. - * - * The functions of this class are: - * - Allow MediaObject to call a subset of the MediaObjectInterface - * API, before SetSource has been called. - * - Cache any parameters which are set in this state (e.g. - * prefinish mark), so that they can be copied into the 'real' - * AbstractPlayer implementation once a source has been loaded. - */ - class DummyPlayer : public AbstractPlayer - { - public: - DummyPlayer(); - DummyPlayer(const AbstractPlayer& player); - - // MediaObjectInterface - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual bool hasVideo() const; - virtual bool isSeekable() const; - virtual qint64 currentTime() const; - virtual Phonon::State state() const; - virtual QString errorString() const; - virtual Phonon::ErrorType errorType() const; - virtual qint64 totalTime() const; - virtual MediaSource source() const; - // virtual void setSource(const MediaSource &); - virtual void setFileSource(const Phonon::MediaSource&, RFile&); - virtual void setNextSource(const MediaSource &source); - - // VolumeObserver - virtual void volumeChanged(qreal volume); - - // AbstractPlayer - virtual void doSetTickInterval(qint32 interval); - - }; - } +namespace MMF +{ +class AudioOutput; + +/** + * @short Stub implementation of AbstractPlayer. + * + * The functions of this class are: + * - Allow MediaObject to call a subset of the MediaObjectInterface + * API, before SetSource has been called. + * - Cache any parameters which are set in this state (e.g. + * prefinish mark), so that they can be copied into the 'real' + * AbstractPlayer implementation once a source has been loaded. + */ +class DummyPlayer : public AbstractPlayer +{ +public: + DummyPlayer(); + DummyPlayer(const AbstractPlayer& player); + + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + // virtual void setSource(const MediaSource &); + virtual void setFileSource(const Phonon::MediaSource&, RFile&); + virtual void setNextSource(const MediaSource &source); + + // VolumeObserver + virtual void volumeChanged(qreal volume); + + // AbstractPlayer + virtual void doSetTickInterval(qint32 interval); + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 91ed859..bf55781 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -32,8 +32,8 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::MediaObject::MediaObject(QObject *parent) : QObject(parent) - , m_recognizerOpened(false) +MMF::MediaObject::MediaObject(QObject *parent) : QObject(parent) + , m_recognizerOpened(false) { m_player.reset(new DummyPlayer()); @@ -64,74 +64,63 @@ MMF::MediaObject::~MediaObject() bool MMF::MediaObject::openRecognizer() { - TRACE_CONTEXT(MediaObject::openRecognizer, EAudioInternal); - - if(!m_recognizerOpened) - { - TInt err = m_recognizer.Connect(); - if(KErrNone != err) - { - TRACE("RApaLsSession::Connect error %d", err); - return false; - } - - err = m_fileServer.Connect(); - if(KErrNone != err) - { - TRACE("RFs::Connect error %d", err); - return false; - } - - // This must be called in order to be able to share file handles with - // the recognizer server (see fileMediaType function). - err = m_fileServer.ShareProtected(); - if(KErrNone != err) - { - TRACE("RFs::ShareProtected error %d", err); - return false; - } - - m_recognizerOpened = true; - } - - return true; + TRACE_CONTEXT(MediaObject::openRecognizer, EAudioInternal); + + if (!m_recognizerOpened) { + TInt err = m_recognizer.Connect(); + if (KErrNone != err) { + TRACE("RApaLsSession::Connect error %d", err); + return false; + } + + err = m_fileServer.Connect(); + if (KErrNone != err) { + TRACE("RFs::Connect error %d", err); + return false; + } + + // This must be called in order to be able to share file handles with + // the recognizer server (see fileMediaType function). + err = m_fileServer.ShareProtected(); + if (KErrNone != err) { + TRACE("RFs::ShareProtected error %d", err); + return false; + } + + m_recognizerOpened = true; + } + + return true; } MMF::MediaType MMF::MediaObject::fileMediaType - (const QString& fileName) +(const QString& fileName) { - TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal); - - MediaType result = MediaTypeUnknown; - - if(openRecognizer()) - { - QHBufC fileNameSymbian = Utils::symbianFilename(fileName); - - m_file.Close(); - TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead|EFileShareReadersOnly); - - if(KErrNone == err) - { - TDataRecognitionResult recognizerResult; - err = m_recognizer.RecognizeData(m_file, recognizerResult); - if(KErrNone == err) - { - const TPtrC mimeType = recognizerResult.iDataType.Des(); - result = Utils::mimeTypeToMediaType(mimeType); - } - else - { - TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err); - } - } - else - { - TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err); - } - } - - return result; + TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal); + + MediaType result = MediaTypeUnknown; + + if (openRecognizer()) { + QHBufC fileNameSymbian = Utils::symbianFilename(fileName); + + m_file.Close(); + TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly); + + if (KErrNone == err) { + TDataRecognitionResult recognizerResult; + err = m_recognizer.RecognizeData(m_file, recognizerResult); + if (KErrNone == err) { + const TPtrC mimeType = recognizerResult.iDataType.Des(); + result = Utils::mimeTypeToMediaType(mimeType); + } else { + TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err); + } + } else { + TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err); + } + } + + return result; } @@ -157,9 +146,8 @@ void MMF::MediaObject::stop() void MMF::MediaObject::seek(qint64 ms) { m_player->seek(ms); - - if(state() == PausedState or state() == PlayingState) - { + + if (state() == PausedState or state() == PlayingState) { emit tick(currentTime()); } } @@ -216,130 +204,117 @@ MediaSource MMF::MediaObject::source() const void MMF::MediaObject::setSource(const MediaSource &source) { - createPlayer(source); - + createPlayer(source); + // This is a hack to work around KErrInUse from MMF client utility // OpenFileL calls m_player->setFileSource(source, m_file); - + emit currentSourceChanged(source); } void MMF::MediaObject::createPlayer(const MediaSource &source) { - TRACE_CONTEXT(MediaObject::createPlayer, EAudioApi); + TRACE_CONTEXT(MediaObject::createPlayer, EAudioApi); TRACE_ENTRY("state %d source.type %d", state(), source.type()); - TRACE_ENTRY("source.type %d", source.type()); - - MediaType mediaType = MediaTypeUnknown; - - AbstractPlayer* oldPlayer = m_player.data(); - - const bool oldPlayerHasVideo = oldPlayer->hasVideo(); - const bool oldPlayerSeekable = oldPlayer->isSeekable(); - - // Determine media type - switch(source.type()) - { - case MediaSource::LocalFile: - mediaType = fileMediaType(source.fileName()); - break; - - case MediaSource::Url: - // TODO: support detection of media type from HTTP streams - TRACE_0("Network streaming not supported yet"); - /* - * TODO: handle error - * - m_error = NormalError; - changeState(ErrorState); - */ - break; - - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - TRACE_0("Unsupported media type"); - /* - * TODO: handle error - * - m_error = NormalError; - changeState(ErrorState); - */ - break; - - case MediaSource::Empty: - TRACE_0("Empty media source"); - break; - } - - AbstractPlayer* newPlayer = NULL; - - // Construct newPlayer using oldPlayer (if not NULL) in order to copy - // parameters (volume, prefinishMark, transitionTime) which may have - // been set on oldPlayer. - - switch(mediaType) - { - case MediaTypeUnknown: - TRACE_0("Media type could not be determined"); - if(oldPlayer) - { - newPlayer = new DummyPlayer(*oldPlayer); - } - else - { - newPlayer = new DummyPlayer(); - } - /* - * TODO: handle error? - * - m_error = NormalError; - changeState(ErrorState); - */ - break; - - case MediaTypeAudio: - if(oldPlayer) - { - newPlayer = new AudioPlayer(*oldPlayer); - } - else - { - newPlayer = new AudioPlayer(); - } - break; - - case MediaTypeVideo: - if(oldPlayer) - { - newPlayer = new VideoPlayer(*oldPlayer); - } - else - { - newPlayer = new VideoPlayer(); - } - break; - } - - m_player.reset(newPlayer); - - if(oldPlayerHasVideo != hasVideo()) - { - emit hasVideoChanged(hasVideo()); - } - - if(oldPlayerSeekable != isSeekable()) - { - emit seekableChanged(isSeekable()); - } - - connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64))); - connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); - connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); - connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); - - TRACE_EXIT_0(); + TRACE_ENTRY("source.type %d", source.type()); + + MediaType mediaType = MediaTypeUnknown; + + AbstractPlayer* oldPlayer = m_player.data(); + + const bool oldPlayerHasVideo = oldPlayer->hasVideo(); + const bool oldPlayerSeekable = oldPlayer->isSeekable(); + + // Determine media type + switch (source.type()) { + case MediaSource::LocalFile: + mediaType = fileMediaType(source.fileName()); + break; + + case MediaSource::Url: + // TODO: support detection of media type from HTTP streams + TRACE_0("Network streaming not supported yet"); + /* + * TODO: handle error + * + m_error = NormalError; + changeState(ErrorState); + */ + break; + + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + TRACE_0("Unsupported media type"); + /* + * TODO: handle error + * + m_error = NormalError; + changeState(ErrorState); + */ + break; + + case MediaSource::Empty: + TRACE_0("Empty media source"); + break; + } + + AbstractPlayer* newPlayer = NULL; + + // Construct newPlayer using oldPlayer (if not NULL) in order to copy + // parameters (volume, prefinishMark, transitionTime) which may have + // been set on oldPlayer. + + switch (mediaType) { + case MediaTypeUnknown: + TRACE_0("Media type could not be determined"); + if (oldPlayer) { + newPlayer = new DummyPlayer(*oldPlayer); + } else { + newPlayer = new DummyPlayer(); + } + /* + * TODO: handle error? + * + m_error = NormalError; + changeState(ErrorState); + */ + break; + + case MediaTypeAudio: + if (oldPlayer) { + newPlayer = new AudioPlayer(*oldPlayer); + } else { + newPlayer = new AudioPlayer(); + } + break; + + case MediaTypeVideo: + if (oldPlayer) { + newPlayer = new VideoPlayer(*oldPlayer); + } else { + newPlayer = new VideoPlayer(); + } + break; + } + + m_player.reset(newPlayer); + + if (oldPlayerHasVideo != hasVideo()) { + emit hasVideoChanged(hasVideo()); + } + + if (oldPlayerSeekable != isSeekable()) { + emit seekableChanged(isSeekable()); + } + + connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64))); + connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); + connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); + connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); + + TRACE_EXIT_0(); } void MMF::MediaObject::setNextSource(const MediaSource &source) diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index d9c32ce..c53b908 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -34,94 +34,94 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class AbstractPlayer; - class VideoOutput; - - /** - * @short Facade class which wraps MMF client utility instance - */ - class MediaObject : public QObject - , public MediaObjectInterface - , public VolumeObserver - { - Q_OBJECT - Q_INTERFACES(Phonon::MediaObjectInterface) - - public: - MediaObject(QObject *parent); - virtual ~MediaObject(); - - // MediaObjectInterface - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual qint32 tickInterval() const; - virtual void setTickInterval(qint32 interval); - virtual bool hasVideo() const; - virtual bool isSeekable() const; - virtual qint64 currentTime() const; - virtual Phonon::State state() const; - virtual QString errorString() const; - virtual Phonon::ErrorType errorType() const; - virtual qint64 totalTime() const; - virtual MediaSource source() const; - virtual void setSource(const MediaSource &); - virtual void setNextSource(const MediaSource &source); - virtual qint32 prefinishMark() const; - virtual void setPrefinishMark(qint32); - virtual qint32 transitionTime() const; - virtual void setTransitionTime(qint32); - - // VolumeObserver - void volumeChanged(qreal volume); - - void setVideoOutput(VideoOutput* videoOutput); - - Q_SIGNALS: - void totalTimeChanged(qint64 length); - void hasVideoChanged(bool hasVideo); - void seekableChanged(bool seekable); - // TODO: emit bufferStatus from MediaObject - void bufferStatus(int); - // TODO: emit aboutToFinish from MediaObject - void aboutToFinish(); - // TODO: emit prefinishMarkReached from MediaObject - void prefinishMarkReached(qint32); - // TODO: emit metaDataChanged from MediaObject - void metaDataChanged(const QMultiMap& metaData); - void currentSourceChanged(const MediaSource& source); - void stateChanged(Phonon::State oldState, - Phonon::State newState); - void finished(); - void tick(qint64 time); - - private: - void createPlayer(const MediaSource &source); - bool openRecognizer(); - - // Audio / video media type recognition - MediaType fileMediaType(const QString& fileName); - // TODO: urlMediaType function - - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - private: - // Audio / video media type recognition - bool m_recognizerOpened; - RApaLsSession m_recognizer; - RFs m_fileServer; - - // Storing the file handle here to work around KErrInUse error - // from MMF player utility OpenFileL functions - RFile m_file; - - QScopedPointer m_player; - - }; - } +namespace MMF +{ +class AbstractPlayer; +class VideoOutput; + +/** + * @short Facade class which wraps MMF client utility instance + */ +class MediaObject : public QObject + , public MediaObjectInterface + , public VolumeObserver +{ + Q_OBJECT + Q_INTERFACES(Phonon::MediaObjectInterface) + +public: + MediaObject(QObject *parent); + virtual ~MediaObject(); + + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual qint32 tickInterval() const; + virtual void setTickInterval(qint32 interval); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + virtual void setSource(const MediaSource &); + virtual void setNextSource(const MediaSource &source); + virtual qint32 prefinishMark() const; + virtual void setPrefinishMark(qint32); + virtual qint32 transitionTime() const; + virtual void setTransitionTime(qint32); + + // VolumeObserver + void volumeChanged(qreal volume); + + void setVideoOutput(VideoOutput* videoOutput); + +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void hasVideoChanged(bool hasVideo); + void seekableChanged(bool seekable); + // TODO: emit bufferStatus from MediaObject + void bufferStatus(int); + // TODO: emit aboutToFinish from MediaObject + void aboutToFinish(); + // TODO: emit prefinishMarkReached from MediaObject + void prefinishMarkReached(qint32); + // TODO: emit metaDataChanged from MediaObject + void metaDataChanged(const QMultiMap& metaData); + void currentSourceChanged(const MediaSource& source); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + void finished(); + void tick(qint64 time); + +private: + void createPlayer(const MediaSource &source); + bool openRecognizer(); + + // Audio / video media type recognition + MediaType fileMediaType(const QString& fileName); + // TODO: urlMediaType function + + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + +private: + // Audio / video media type recognition + bool m_recognizerOpened; + RApaLsSession m_recognizer; + RFs m_fileServer; + + // Storing the file handle here to work around KErrInUse error + // from MMF player utility OpenFileL functions + RFile m_file; + + QScopedPointer m_player; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index eb367f6..df9ceae 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -38,8 +38,7 @@ QHBufC MMF::Utils::symbianFilename(const QString& qtFilename) QHBufC result(qtFilename); TInt pos = result->Find(ForwardSlash); - while(pos != KErrNotFound) - { + while (pos != KErrNotFound) { result->Des().Replace(pos, 1, BackwardSlash); pos = result->Find(ForwardSlash); } @@ -54,18 +53,15 @@ _LIT(KMimePrefixVideo, "video/"); MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) { - MediaType result = MediaTypeUnknown; - - if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) - { - result = MediaTypeAudio; - } - else if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) - { - result = MediaTypeVideo; - } - - return result; + MediaType result = MediaTypeUnknown; + + if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) { + result = MediaTypeAudio; + } else if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) { + result = MediaTypeVideo; + } + + return result; } diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index e2b5e59..c0487a7 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -20,7 +20,7 @@ along with this library. If not, see . #define PHONON_MMF_UTILS_H #include -#include // for RDebug +#include // for RDebug #include "defs.h" @@ -28,136 +28,132 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * Panic codes for fatal errors - */ - enum PanicCode - { - InvalidStatePanic = 1, - InvalidMediaTypePanic = 2, - InvalidBackendInterfaceClass = 3 - }; - - namespace Utils - { - /** - * Raise a fatal exception - */ - void panic(PanicCode code); - - /** - * Translate forward slashes to backslashes - * - * \note This function is a temporary measure, for use until the - * responsibility for constructing valid file paths is - * determined. - */ - QHBufC symbianFilename(const QString& qtFilename); - - /** - * Determines whether the provided MIME type is an audio or video - * type. If it is neither, the function returns MediaTypeUnknown. - */ - MediaType mimeTypeToMediaType(const TDesC& mimeType); - } - - /** - * Available trace categories; - */ - enum TTraceCategory - { - /** - * Backend - */ - EBackend = 0x00000001, - - /** - * Functions which map directly to the public Phonon audio API - */ - EAudioApi = 0x00000010, - - /** - * Internal functions in the audio implementation - */ - EAudioInternal = 0x00000020, - - /** - * Functions which map directly to the public Phonon video API - */ - EVideoApi = 0x00010000, - - /** - * Internal functions in the video implementation - */ - EVideoInternal = 0x00020000 - }; - - /** - * Mask indicating which trace categories are enabled - * - * Note that, at the moment, this is a compiled static constant. For - * runtime control over enabled trace categories, this could be replaced - * by a per-thread singleton object which owns the trace mask, and which - * exposes an API allowing it to be modified. - */ - static const TUint KTraceMask = 0xffffffff; - - /** - * Data structure used by tracing macros - */ - class TTraceContext - { - public: - TTraceContext(const TText* aFunction, const TUint aAddr, - const TUint aCategory=0) +namespace MMF +{ +/** + * Panic codes for fatal errors + */ +enum PanicCode { + InvalidStatePanic = 1, + InvalidMediaTypePanic = 2, + InvalidBackendInterfaceClass = 3 +}; + +namespace Utils +{ +/** + * Raise a fatal exception + */ +void panic(PanicCode code); + +/** + * Translate forward slashes to backslashes + * + * \note This function is a temporary measure, for use until the + * responsibility for constructing valid file paths is + * determined. + */ +QHBufC symbianFilename(const QString& qtFilename); + +/** + * Determines whether the provided MIME type is an audio or video + * type. If it is neither, the function returns MediaTypeUnknown. + */ +MediaType mimeTypeToMediaType(const TDesC& mimeType); +} + +/** + * Available trace categories; + */ +enum TTraceCategory { + /** + * Backend + */ + EBackend = 0x00000001, + + /** + * Functions which map directly to the public Phonon audio API + */ + EAudioApi = 0x00000010, + + /** + * Internal functions in the audio implementation + */ + EAudioInternal = 0x00000020, + + /** + * Functions which map directly to the public Phonon video API + */ + EVideoApi = 0x00010000, + + /** + * Internal functions in the video implementation + */ + EVideoInternal = 0x00020000 +}; + +/** + * Mask indicating which trace categories are enabled + * + * Note that, at the moment, this is a compiled static constant. For + * runtime control over enabled trace categories, this could be replaced + * by a per-thread singleton object which owns the trace mask, and which + * exposes an API allowing it to be modified. + */ +static const TUint KTraceMask = 0xffffffff; + +/** + * Data structure used by tracing macros + */ +class TTraceContext +{ +public: + TTraceContext(const TText* aFunction, const TUint aAddr, + const TUint aCategory = 0) : iFunction(aFunction), - iAddr(aAddr), - iCategory(aCategory) - { } - - /** - * Check whether iCategory appears in the trace mask - */ - TBool Enabled() const - { - return (iCategory == 0) or (iCategory & KTraceMask); - } - - const TText* iFunction; // Name of function - const TUint iAddr; // 'this' pointer - const TUint iCategory; - }; - - // Macros used internally by the trace system - #define _TRACE_PRINT RDebug::Print - #define _TRACE_TEXT(x) (TPtrC((const TText *)(x))) - #define _TRACE_MODULE Phonon::MMF - - // Macros available for use by implementation code + iAddr(aAddr), + iCategory(aCategory) { } + + /** + * Check whether iCategory appears in the trace mask + */ + TBool Enabled() const { + return (iCategory == 0) or(iCategory & KTraceMask); + } + + const TText* iFunction; // Name of function + const TUint iAddr; // 'this' pointer + const TUint iCategory; +}; + +// Macros used internally by the trace system +#define _TRACE_PRINT RDebug::Print +#define _TRACE_TEXT(x) (TPtrC((const TText *)(x))) +#define _TRACE_MODULE Phonon::MMF + +// Macros available for use by implementation code #ifdef _DEBUG - #define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat); - #define TRACE_ENTRY_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } - #define TRACE_ENTRY(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } - #define TRACE_EXIT_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } - #define TRACE_EXIT(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } - #define TRACE_RETURN(string, result) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "r Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, result); } return result; - #define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code); - #define TRACE_0(string) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); } - #define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat); +#define TRACE_ENTRY_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } +#define TRACE_ENTRY(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#define TRACE_EXIT_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } +#define TRACE_EXIT(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#define TRACE_RETURN(string, result) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "r Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, result); } return result; +#define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code); +#define TRACE_0(string) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); } +#define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } #else - #define TRACE_CONTEXT(_fn, _cat) - #define TRACE_ENTRY_0() - #define TRACE_ENTRY(string, args...) - #define TRACE_EXIT_0() - #define TRACE_EXIT(string, args...) - #define TRACE_RETURN(string, result) return result; - #define TRACE_PANIC(code) Utils::panic(code); - #define TRACE_0(string) - #define TRACE(string, args...) +#define TRACE_CONTEXT(_fn, _cat) +#define TRACE_ENTRY_0() +#define TRACE_ENTRY(string, args...) +#define TRACE_EXIT_0() +#define TRACE_EXIT(string, args...) +#define TRACE_RETURN(string, result) return result; +#define TRACE_PANIC(code) Utils::panic(code); +#define TRACE_0(string) +#define TRACE(string, args...) #endif - } +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 6534b7b..53178cb 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -34,24 +34,24 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::VideoOutput::VideoOutput(QWidget* parent) - : QWidget(parent) - , m_observer(NULL) + : QWidget(parent) + , m_observer(NULL) { - TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); - TRACE_ENTRY("parent 0x%08x", parent); + TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); + TRACE_ENTRY("parent 0x%08x", parent); #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - setPalette(QPalette(Qt::black)); - //setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); - setAutoFillBackground(false); + setPalette(QPalette(Qt::black)); + //setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + setAutoFillBackground(false); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - + #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT - dump(); + dump(); #endif - - TRACE_EXIT_0(); + + TRACE_EXIT_0(); } #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT @@ -59,56 +59,54 @@ void VideoOutput::dump() { TRACE_CONTEXT(VideoOutput::dump, EVideoInternal); TRACE_ENTRY_0(); - + TRACE("dumpObjectInfo this 0x%08x", this); this->dumpObjectInfo(); TRACE_0("Traversing up object tree ..."); QObject* node = this; QObject* root = this; - while(node) - { + while (node) { QWidget* widget = qobject_cast(node); const bool visible = widget ? widget->isVisible() : false; const QHBufC name(node->objectName()); TRACE("node 0x%08x name %S widget 0x%08x visible %d", node, name.data(), widget, visible); - + root = node; node = node->parent(); } - + TRACE("dumpObjectInfo root 0x%08x", root); root->dumpObjectInfo(); TRACE_0("+ dumpObjectTree"); root->dumpObjectTree(); TRACE_0("- dumpObjectTree"); - + TRACE("isVisible %d", isVisible()); TRACE("pos %d %d", x(), y()); TRACE("size %d %d", size().width(), size().height()); TRACE("maxSize %d %d", maximumWidth(), maximumHeight()); TRACE("sizeHint %d %d", sizeHint().width(), sizeHint().height()); - + QWidget* parentWidget = qobject_cast(parent()); - if(parentWidget) - { + if (parentWidget) { TRACE("parent.isVisible %d", parentWidget->isVisible()); TRACE("parent.pos %d %d", parentWidget->x(), parentWidget->y()); TRACE("parent.size %d %d", parentWidget->size().width(), parentWidget->size().height()); TRACE("parent.maxSize %d %d", parentWidget->maximumWidth(), parentWidget->maximumHeight()); TRACE("parent.sizeHint %d %d", parentWidget->sizeHint().width(), parentWidget->sizeHint().height()); } - + TRACE_EXIT_0(); } #endif // PHONON_MMF_DEBUG_VIDEO_OUTPUT MMF::VideoOutput::~VideoOutput() { - TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); - TRACE_ENTRY_0(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } void MMF::VideoOutput::setFrameSize(const QSize& frameSize) @@ -118,11 +116,10 @@ void MMF::VideoOutput::setFrameSize(const QSize& frameSize) #else TRACE_CONTEXT(VideoOutput::setFrameSize, EVideoInternal); TRACE("oldSize %d %d newSize %d %d", - m_frameSize.width(), m_frameSize.height(), - frameSize.width(), frameSize.height()); - - if(frameSize != m_frameSize) - { + m_frameSize.width(), m_frameSize.height(), + frameSize.width(), frameSize.height()); + + if (frameSize != m_frameSize) { m_frameSize = frameSize; updateGeometry(); } @@ -133,7 +130,7 @@ void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) { TRACE_CONTEXT(VideoOutput::setObserver, EVideoInternal); TRACE("observer 0x%08x", observer); - + m_observer = observer; } @@ -147,35 +144,34 @@ void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) QSize MMF::VideoOutput::sizeHint() const { TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); - + // TODO: replace this with a more sensible default QSize result(320, 240); - - if(!m_frameSize.isNull()) - { + + if (!m_frameSize.isNull()) { result = m_frameSize; } - + TRACE(" result %d %d", result.width(), result.height()); return result; } void MMF::VideoOutput::paintEvent(QPaintEvent* event) { - TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); - TRACE("rect %d %d - %d %d", - event->rect().left(), event->rect().top(), - event->rect().right(), event->rect().bottom()); - TRACE("regions %d", event->region().numRects()); - TRACE("type %d", event->type()); - - QWidget::paintEvent(event); + TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); + TRACE("rect %d %d - %d %d", + event->rect().left(), event->rect().top(), + event->rect().right(), event->rect().bottom()); + TRACE("regions %d", event->region().numRects()); + TRACE("type %d", event->type()); + + QWidget::paintEvent(event); } QPaintEngine* MMF::VideoOutput::paintEngine() const { TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); - + QPaintEngine* const engine = QWidget::paintEngine(); TRACE_RETURN("0x%08x", engine); @@ -183,30 +179,28 @@ QPaintEngine* MMF::VideoOutput::paintEngine() const void MMF::VideoOutput::resizeEvent(QResizeEvent* event) { - TRACE_CONTEXT(VideoOutput::resizeEvent, EVideoInternal); - TRACE("%d %d -> %d %d", - event->oldSize().width(), event->oldSize().height(), - event->size().width(), event->size().height()); - - QWidget::resizeEvent(event); - - if(m_observer) - { - m_observer->videoOutputRegionChanged(); - } + TRACE_CONTEXT(VideoOutput::resizeEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldSize().width(), event->oldSize().height(), + event->size().width(), event->size().height()); + + QWidget::resizeEvent(event); + + if (m_observer) { + m_observer->videoOutputRegionChanged(); + } } void MMF::VideoOutput::moveEvent(QMoveEvent* event) { - TRACE_CONTEXT(VideoOutput::moveEvent, EVideoInternal); - TRACE("%d %d -> %d %d", - event->oldPos().x(), event->oldPos().y(), - event->pos().x(), event->pos().y()); - - QWidget::moveEvent(event); - - if(m_observer) - { + TRACE_CONTEXT(VideoOutput::moveEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldPos().x(), event->oldPos().y(), + event->pos().x(), event->pos().y()); + + QWidget::moveEvent(event); + + if (m_observer) { m_observer->videoOutputRegionChanged(); } } diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index b8e22ca..0da6ea0 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -26,43 +26,43 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class VideoOutputObserver; - - class VideoOutput : public QWidget - { - Q_OBJECT - - public: - explicit VideoOutput(QWidget* parent); - ~VideoOutput(); - - void setFrameSize(const QSize& size); - void setObserver(VideoOutputObserver* observer); - - protected: - #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - // Override QWidget functions - QSize sizeHint() const; - void paintEvent(QPaintEvent* event); - void resizeEvent(QResizeEvent* event); - void moveEvent(QMoveEvent* event); - QPaintEngine* paintEngine() const; - #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET +namespace MMF +{ +class VideoOutputObserver; + +class VideoOutput : public QWidget +{ + Q_OBJECT + +public: + explicit VideoOutput(QWidget* parent); + ~VideoOutput(); + + void setFrameSize(const QSize& size); + void setObserver(VideoOutputObserver* observer); + +protected: +#ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + // Override QWidget functions + QSize sizeHint() const; + void paintEvent(QPaintEvent* event); + void resizeEvent(QResizeEvent* event); + void moveEvent(QMoveEvent* event); + QPaintEngine* paintEngine() const; +#endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT - public: - void dump(); +public: + void dump(); #endif - - private: - QSize m_frameSize; - - // Not owned - VideoOutputObserver* m_observer; - }; - } + +private: + QSize m_frameSize; + + // Not owned + VideoOutputObserver* m_observer; +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutputobserver.h b/src/3rdparty/phonon/mmf/videooutputobserver.h index d38ff87..e3ba305 100644 --- a/src/3rdparty/phonon/mmf/videooutputobserver.h +++ b/src/3rdparty/phonon/mmf/videooutputobserver.h @@ -25,18 +25,18 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * Interface via which VideoOutput notifies VideoPlayer of changes to the - * video output screen region. - */ - class VideoOutputObserver - { - public: - virtual void videoOutputRegionChanged() = 0; - }; - } +namespace MMF +{ +/** + * Interface via which VideoOutput notifies VideoPlayer of changes to the + * video output screen region. + */ +class VideoOutputObserver +{ +public: + virtual void videoOutputRegionChanged() = 0; +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index ba06379..f008edd 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -20,7 +20,7 @@ along with this library. If not, see . #include #include -#include // For CCoeEnv +#include // For CCoeEnv #include #include "videoplayer.h" @@ -36,70 +36,68 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::VideoPlayer::VideoPlayer() - : m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) - , m_totalTime(0) + : m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) + , m_totalTime(0) { - construct(); + construct(); } MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) - , m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) - , m_totalTime(0) + : AbstractMediaPlayer(player) + , m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) + , m_totalTime(0) { - construct(); + construct(); } void MMF::VideoPlayer::construct() { - TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); - TRACE_ENTRY_0(); - - if(!m_videoOutput) - { - m_dummyVideoOutput.reset(new VideoOutput(NULL)); - } - - videoOutput().setObserver(this); - - const TInt priority = 0; - const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; - - getNativeWindowSystemHandles(); - - // TODO: is this the correct way to handle errors which occur when - // creating a Symbian object in the constructor of a Qt object? - TRAPD(err, - m_player = CVideoPlayerUtility::NewL - ( - *this, - priority, preference, - *m_wsSession, *m_screenDevice, - *m_window, - m_windowRect, m_clipRect - ) - ); - - if(KErrNone != err) - { - changeState(ErrorState); - } - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); + TRACE_ENTRY_0(); + + if (!m_videoOutput) { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } + + videoOutput().setObserver(this); + + const TInt priority = 0; + const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; + + getNativeWindowSystemHandles(); + + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? + TRAPD(err, + m_player = CVideoPlayerUtility::NewL + ( + *this, + priority, preference, + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect + ) + ); + + if (KErrNone != err) { + changeState(ErrorState); + } + + TRACE_EXIT_0(); } MMF::VideoPlayer::~VideoPlayer() { - TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); + TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); TRACE_ENTRY_0(); - - delete m_player; - - TRACE_EXIT_0(); + + delete m_player; + + TRACE_EXIT_0(); } //----------------------------------------------------------------------------- @@ -107,35 +105,33 @@ MMF::VideoPlayer::~VideoPlayer() //----------------------------------------------------------------------------- void MMF::VideoPlayer::doPlay() -{ - m_player->Play(); +{ + m_player->Play(); } void MMF::VideoPlayer::doPause() { - TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); - - TRAPD(err, m_player->PauseL()); - if(KErrNone != err) - { - TRACE("PauseL error %d", err); - setError(NormalError); - } + TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); + + TRAPD(err, m_player->PauseL()); + if (KErrNone != err) { + TRACE("PauseL error %d", err); + setError(NormalError); + } } void MMF::VideoPlayer::doStop() { - m_player->Stop(); + m_player->Stop(); } void MMF::VideoPlayer::doSeek(qint64 ms) { TRACE_CONTEXT(VideoPlayer::doSeek, EVideoApi); - + TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms * 1000))); - if(KErrNone != err) - { + if (KErrNone != err) { TRACE("SetPositionL error %d", err); setError(NormalError); } @@ -143,48 +139,45 @@ void MMF::VideoPlayer::doSeek(qint64 ms) int MMF::VideoPlayer::setDeviceVolume(int mmfVolume) { - TRAPD(err, m_player->SetVolumeL(mmfVolume)); - return err; + TRAPD(err, m_player->SetVolumeL(mmfVolume)); + return err; } int MMF::VideoPlayer::openFile(RFile& file) { - TRAPD(err, m_player->OpenFileL(file)); - return err; + TRAPD(err, m_player->OpenFileL(file)); + return err; } void MMF::VideoPlayer::close() { - m_player->Close(); + m_player->Close(); } bool MMF::VideoPlayer::hasVideo() const { - return true; + return true; } qint64 MMF::VideoPlayer::currentTime() const { - TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); + TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); - TTimeIntervalMicroSeconds us; + TTimeIntervalMicroSeconds us; TRAPD(err, us = m_player->PositionL()) qint64 result = 0; - if(KErrNone == err) - { + if (KErrNone == err) { result = toMilliSeconds(us); + } else { + TRACE("PositionL error %d", err); + + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast(this)->setError(NormalError); } - else - { - TRACE("PositionL error %d", err); - - // If we don't cast away constness here, we simply have to ignore - // the error. - const_cast(this)->setError(NormalError); - } - + return result; } @@ -200,60 +193,54 @@ qint64 MMF::VideoPlayer::totalTime() const void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); + TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); TRACE_ENTRY("state %d error %d", state(), aError); __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - if(KErrNone == aError) - { - m_player->Prepare(); - } - else - { - // TODO: set different error states according to value of aError? - setError(NormalError); - } - + if (KErrNone == aError) { + m_player->Prepare(); + } else { + // TODO: set different error states according to value of aError? + setError(NormalError); + } + TRACE_EXIT_0(); } void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); - TRACE_ENTRY("state %d error %d", state(), aError); + TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - + TRAPD(err, doPrepareCompleteL(aError)); - - if(KErrNone == err) - { - maxVolumeChanged(m_player->MaxVolume()); - - videoOutput().setFrameSize(m_frameSize); + + if (KErrNone == err) { + maxVolumeChanged(m_player->MaxVolume()); + + videoOutput().setFrameSize(m_frameSize); emit totalTimeChanged(totalTime()); changeState(StoppedState); - } - else - { - // TODO: set different error states according to value of aError? - setError(NormalError); - } - - TRACE_EXIT_0(); + } else { + // TODO: set different error states according to value of aError? + setError(NormalError); + } + + TRACE_EXIT_0(); } void MMF::VideoPlayer::doPrepareCompleteL(TInt aError) { User::LeaveIfError(aError); - + // Get frame size TSize size; m_player->VideoFrameSizeL(size); m_frameSize = QSize(size.iWidth, size.iHeight); - + // Get duration m_totalTime = toMilliSeconds(m_player->DurationL()); } @@ -261,36 +248,36 @@ void MMF::VideoPlayer::doPrepareCompleteL(TInt aError) void MMF::VideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); - TRACE_ENTRY("state %d error %d", state(), aError); - - // TODO - Q_UNUSED(aFrame); - Q_UNUSED(aError); // suppress warnings in release builds - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); + + // TODO + Q_UNUSED(aFrame); + Q_UNUSED(aError); // suppress warnings in release builds + + TRACE_EXIT_0(); } void MMF::VideoPlayer::MvpuoPlayComplete(TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) - TRACE_ENTRY("state %d error %d", state(), aError); + TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) + TRACE_ENTRY("state %d error %d", state(), aError); - // TODO - Q_UNUSED(aError); // suppress warnings in release builds - - TRACE_EXIT_0(); + // TODO + Q_UNUSED(aError); // suppress warnings in release builds + + TRACE_EXIT_0(); } void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) { - TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); - TRACE_ENTRY("state %d", state()); + TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); + TRACE_ENTRY("state %d", state()); - // TODO - Q_UNUSED(aEvent); - - TRACE_EXIT_0(); + // TODO + Q_UNUSED(aEvent); + + TRACE_EXIT_0(); } @@ -302,28 +289,27 @@ void MMF::VideoPlayer::videoOutputRegionChanged() { TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); TRACE_ENTRY_0(); - + #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT videoOutput().dump(); #endif - + getNativeWindowSystemHandles(); - + TRAPD(err, - m_player->SetDisplayWindowL - ( - *m_wsSession, *m_screenDevice, - *m_window, - m_windowRect, m_clipRect - ) - ); - - if(KErrNone != err) - { + m_player->SetDisplayWindowL + ( + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect + ) + ); + + if (KErrNone != err) { TRACE("SetDisplayWindowL error %d", err); setError(NormalError); } - + TRACE_EXIT_0(); } @@ -334,81 +320,80 @@ void MMF::VideoPlayer::videoOutputRegionChanged() VideoOutput& MMF::VideoPlayer::videoOutput() { - TRACE_CONTEXT(VideoPlayer::videoOutput, EVideoInternal); - TRACE("videoOutput 0x%08x dummy 0x%08x", m_videoOutput, m_dummyVideoOutput.data()); + TRACE_CONTEXT(VideoPlayer::videoOutput, EVideoInternal); + TRACE("videoOutput 0x%08x dummy 0x%08x", m_videoOutput, m_dummyVideoOutput.data()); - return m_videoOutput ? *m_videoOutput : *m_dummyVideoOutput; + return m_videoOutput ? *m_videoOutput : *m_dummyVideoOutput; } void MMF::VideoPlayer::videoOutputChanged() { - TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); - TRACE_ENTRY_0(); - - // Lazily construct a dummy output if needed here - if(!m_videoOutput and m_dummyVideoOutput.isNull()) - { - m_dummyVideoOutput.reset(new VideoOutput(NULL)); - } - - videoOutput().setObserver(this); - - videoOutput().setFrameSize(m_frameSize); - - videoOutputRegionChanged(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); + TRACE_ENTRY_0(); + + // Lazily construct a dummy output if needed here + if (!m_videoOutput and m_dummyVideoOutput.isNull()) { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } + + videoOutput().setObserver(this); + + videoOutput().setFrameSize(m_frameSize); + + videoOutputRegionChanged(); + + TRACE_EXIT_0(); } void MMF::VideoPlayer::getNativeWindowSystemHandles() { - TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); - - VideoOutput& output = videoOutput(); - CCoeControl* const control = output.winId(); - - TRACE("control 0x%08x", control); - TRACE("control IsVisible %d", control->IsVisible()); - TRACE("control IsDimmed %d", control->IsDimmed()); - TRACE("control HasBorder %d", control->HasBorder()); - TRACE("control Position %d %d", - control->Position().iX, control->Position().iY); - TRACE("control Rect %d %d - %d %d", - control->Rect().iTl.iX, control->Rect().iTl.iY, - control->Rect().iBr.iX, control->Rect().iBr.iY); - TRACE("control OwnsWindow %d", control->OwnsWindow()); - - CCoeEnv* const coeEnv = control->ControlEnv(); - - m_wsSession = &(coeEnv->WsSession()); - - TRACE("session Handle 0x%08x", m_wsSession->Handle()); - - m_screenDevice = coeEnv->ScreenDevice(); - - TRACE("device WsHandle 0x%08x", m_screenDevice->WsHandle()); - - m_window = control->DrawableWindow(); - - TRACE("window ClientHandle 0x%08x", m_window->ClientHandle()); - TRACE("window WsHandle 0x%08x", m_window->WsHandle()); - TRACE("window WindowGroupId %d", m_window->WindowGroupId()); - TRACE("window Position %d %d", - m_window->Position().iX, m_window->Position().iY); - TRACE("window AbsPosition %d %d", - m_window->AbsPosition().iX, m_window->AbsPosition().iY); - TRACE("window Size %d %d", - m_window->Size().iWidth, m_window->Size().iHeight); - + TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); + + VideoOutput& output = videoOutput(); + CCoeControl* const control = output.winId(); + + TRACE("control 0x%08x", control); + TRACE("control IsVisible %d", control->IsVisible()); + TRACE("control IsDimmed %d", control->IsDimmed()); + TRACE("control HasBorder %d", control->HasBorder()); + TRACE("control Position %d %d", + control->Position().iX, control->Position().iY); + TRACE("control Rect %d %d - %d %d", + control->Rect().iTl.iX, control->Rect().iTl.iY, + control->Rect().iBr.iX, control->Rect().iBr.iY); + TRACE("control OwnsWindow %d", control->OwnsWindow()); + + CCoeEnv* const coeEnv = control->ControlEnv(); + + m_wsSession = &(coeEnv->WsSession()); + + TRACE("session Handle 0x%08x", m_wsSession->Handle()); + + m_screenDevice = coeEnv->ScreenDevice(); + + TRACE("device WsHandle 0x%08x", m_screenDevice->WsHandle()); + + m_window = control->DrawableWindow(); + + TRACE("window ClientHandle 0x%08x", m_window->ClientHandle()); + TRACE("window WsHandle 0x%08x", m_window->WsHandle()); + TRACE("window WindowGroupId %d", m_window->WindowGroupId()); + TRACE("window Position %d %d", + m_window->Position().iX, m_window->Position().iY); + TRACE("window AbsPosition %d %d", + m_window->AbsPosition().iX, m_window->AbsPosition().iY); + TRACE("window Size %d %d", + m_window->Size().iWidth, m_window->Size().iHeight); + #ifdef PHONON_MMF_HARD_CODE_VIDEO_RECT - // HACK: why isn't control->Rect updated following a call to - // updateGeometry on the parent widget? - m_windowRect = TRect(0,100,320,250); + // HACK: why isn't control->Rect updated following a call to + // updateGeometry on the parent widget? + m_windowRect = TRect(0, 100, 320, 250); #else - m_windowRect = control->Rect(); + m_windowRect = control->Rect(); #endif - - m_clipRect = m_windowRect; + + m_clipRect = m_windowRect; } diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index f8b1486..da373ab 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -29,81 +29,81 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * @short Wrapper over MMF video client utility - * - * See - * How to - * play a video file using CVideoPlayerUtility - */ - class VideoPlayer : public AbstractMediaPlayer - , public MVideoPlayerUtilityObserver - , public VideoOutputObserver - { - Q_OBJECT - - public: - VideoPlayer(); - explicit VideoPlayer(const AbstractPlayer& player); - virtual ~VideoPlayer(); - - // AbstractPlayer - virtual void doPlay(); - virtual void doPause(); - virtual void doStop(); - virtual void doSeek(qint64 milliseconds); - virtual int setDeviceVolume(int mmfVolume); - virtual int openFile(RFile& file); - virtual void close(); - - // MediaObjectInterface - virtual bool hasVideo() const; - virtual qint64 currentTime() const; - virtual qint64 totalTime() const; - - // MVideoPlayerUtilityObserver - virtual void MvpuoOpenComplete(TInt aError); - virtual void MvpuoPrepareComplete(TInt aError); - virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); - virtual void MvpuoPlayComplete(TInt aError); - virtual void MvpuoEvent(const TMMFEvent &aEvent); - - // VideoOutputObserver - virtual void videoOutputRegionChanged(); - - Q_SIGNALS: - void totalTimeChanged(qint64 length); - void finished(); - - private: - void construct(); - VideoOutput& videoOutput(); - - void doPrepareCompleteL(TInt aError); - - // AbstractPlayer - virtual void videoOutputChanged(); - - void getNativeWindowSystemHandles(); - - private: - CVideoPlayerUtility* m_player; - QScopedPointer m_dummyVideoOutput; - - // Not owned - RWsSession* m_wsSession; - CWsScreenDevice* m_screenDevice; - RWindowBase* m_window; - TRect m_windowRect; - TRect m_clipRect; - - QSize m_frameSize; - qint64 m_totalTime; - - }; - } +namespace MMF +{ +/** + * @short Wrapper over MMF video client utility + * + * See + * How to + * play a video file using CVideoPlayerUtility + */ +class VideoPlayer : public AbstractMediaPlayer + , public MVideoPlayerUtilityObserver + , public VideoOutputObserver +{ + Q_OBJECT + +public: + VideoPlayer(); + explicit VideoPlayer(const AbstractPlayer& player); + virtual ~VideoPlayer(); + + // AbstractPlayer + virtual void doPlay(); + virtual void doPause(); + virtual void doStop(); + virtual void doSeek(qint64 milliseconds); + virtual int setDeviceVolume(int mmfVolume); + virtual int openFile(RFile& file); + virtual void close(); + + // MediaObjectInterface + virtual bool hasVideo() const; + virtual qint64 currentTime() const; + virtual qint64 totalTime() const; + + // MVideoPlayerUtilityObserver + virtual void MvpuoOpenComplete(TInt aError); + virtual void MvpuoPrepareComplete(TInt aError); + virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); + virtual void MvpuoPlayComplete(TInt aError); + virtual void MvpuoEvent(const TMMFEvent &aEvent); + + // VideoOutputObserver + virtual void videoOutputRegionChanged(); + +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void finished(); + +private: + void construct(); + VideoOutput& videoOutput(); + + void doPrepareCompleteL(TInt aError); + + // AbstractPlayer + virtual void videoOutputChanged(); + + void getNativeWindowSystemHandles(); + +private: + CVideoPlayerUtility* m_player; + QScopedPointer m_dummyVideoOutput; + + // Not owned + RWsSession* m_wsSession; + CWsScreenDevice* m_screenDevice; + RWindowBase* m_window; + TRect m_windowRect; + TRect m_clipRect; + + QSize m_frameSize; + qint64 m_totalTime; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index ae94e5e..be3c752 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -29,11 +29,11 @@ using namespace Phonon::MMF; // Constants //----------------------------------------------------------------------------- -static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio = - Phonon::VideoWidget::AspectRatioAuto; +static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio = + Phonon::VideoWidget::AspectRatioAuto; static const qreal DefaultBrightness = 1.0; -static const Phonon::VideoWidget::ScaleMode DefaultScaleMode = - Phonon::VideoWidget::FitInView; +static const Phonon::VideoWidget::ScaleMode DefaultScaleMode = + Phonon::VideoWidget::FitInView; static const qreal DefaultContrast = 1.0; static const qreal DefaultHue = 1.0; static const qreal DefaultSaturation = 1.0; @@ -44,27 +44,27 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : QObject(parent) - , m_widget(new VideoOutput(parent)) - , m_aspectRatio(DefaultAspectRatio) - , m_brightness(DefaultBrightness) - , m_scaleMode(DefaultScaleMode) - , m_contrast(DefaultContrast) - , m_hue(DefaultHue) - , m_saturation(DefaultSaturation) + : QObject(parent) + , m_widget(new VideoOutput(parent)) + , m_aspectRatio(DefaultAspectRatio) + , m_brightness(DefaultBrightness) + , m_scaleMode(DefaultScaleMode) + , m_contrast(DefaultContrast) + , m_hue(DefaultHue) + , m_saturation(DefaultSaturation) { - TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); - TRACE_ENTRY_0(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } MMF::VideoWidget::~VideoWidget() { - TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi); - TRACE_ENTRY_0(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } @@ -74,91 +74,91 @@ MMF::VideoWidget::~VideoWidget() Phonon::VideoWidget::AspectRatio MMF::VideoWidget::aspectRatio() const { - return m_aspectRatio; + return m_aspectRatio; } void MMF::VideoWidget::setAspectRatio - (Phonon::VideoWidget::AspectRatio aspectRatio) +(Phonon::VideoWidget::AspectRatio aspectRatio) { - TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi); - TRACE("aspectRatio %d", aspectRatio); + TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi); + TRACE("aspectRatio %d", aspectRatio); - m_aspectRatio = aspectRatio; + m_aspectRatio = aspectRatio; } qreal MMF::VideoWidget::brightness() const { - return m_brightness; + return m_brightness; } void MMF::VideoWidget::setBrightness(qreal brightness) { - TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi); - TRACE("brightness %f", brightness); + TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi); + TRACE("brightness %f", brightness); - m_brightness = brightness; + m_brightness = brightness; } Phonon::VideoWidget::ScaleMode MMF::VideoWidget::scaleMode() const { - return m_scaleMode; + return m_scaleMode; } void MMF::VideoWidget::setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode) { - TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi); - TRACE("setScaleMode %d", setScaleMode); + TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi); + TRACE("setScaleMode %d", setScaleMode); - m_scaleMode = scaleMode; + m_scaleMode = scaleMode; } qreal MMF::VideoWidget::contrast() const { - return m_contrast; + return m_contrast; } void MMF::VideoWidget::setContrast(qreal contrast) { - TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi); - TRACE("contrast %f", contrast); + TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi); + TRACE("contrast %f", contrast); - m_contrast = contrast; + m_contrast = contrast; } qreal MMF::VideoWidget::hue() const { - return m_hue; + return m_hue; } void MMF::VideoWidget::setHue(qreal hue) { - TRACE_CONTEXT(VideoWidget::setHue, EVideoApi); - TRACE("hue %f", hue); + TRACE_CONTEXT(VideoWidget::setHue, EVideoApi); + TRACE("hue %f", hue); - m_hue = hue; + m_hue = hue; } qreal MMF::VideoWidget::saturation() const { - return m_saturation; + return m_saturation; } void MMF::VideoWidget::setSaturation(qreal saturation) { - TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi); - TRACE("saturation %f", saturation); + TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi); + TRACE("saturation %f", saturation); - m_saturation = saturation; + m_saturation = saturation; } QWidget* MMF::VideoWidget::widget() { - return m_widget.data(); + return m_widget.data(); } VideoOutput& MMF::VideoWidget::videoOutput() { - return *static_cast(widget()); + return *static_cast(widget()); } diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 799121b..e2e1f33 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -27,49 +27,49 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class VideoOutput; - - class VideoWidget : public QObject - , public Phonon::VideoWidgetInterface - { - Q_OBJECT - Q_INTERFACES(Phonon::VideoWidgetInterface) - - public: - VideoWidget(QWidget* parent); - ~VideoWidget(); - - // VideoWidgetInterface - virtual Phonon::VideoWidget::AspectRatio aspectRatio() const; - virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio aspectRatio); - virtual qreal brightness() const; - virtual void setBrightness(qreal brightness); - virtual Phonon::VideoWidget::ScaleMode scaleMode() const; - virtual void setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode); - virtual qreal contrast() const; - virtual void setContrast(qreal constrast); - virtual qreal hue() const; - virtual void setHue(qreal hue); - virtual qreal saturation() const; - virtual void setSaturation(qreal saturation); - virtual QWidget *widget(); - - VideoOutput& videoOutput(); - - private: - QScopedPointer m_widget; - - Phonon::VideoWidget::AspectRatio m_aspectRatio; - qreal m_brightness; - Phonon::VideoWidget::ScaleMode m_scaleMode; - qreal m_contrast; - qreal m_hue; - qreal m_saturation; - - }; - } +namespace MMF +{ +class VideoOutput; + +class VideoWidget : public QObject + , public Phonon::VideoWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::VideoWidgetInterface) + +public: + VideoWidget(QWidget* parent); + ~VideoWidget(); + + // VideoWidgetInterface + virtual Phonon::VideoWidget::AspectRatio aspectRatio() const; + virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio aspectRatio); + virtual qreal brightness() const; + virtual void setBrightness(qreal brightness); + virtual Phonon::VideoWidget::ScaleMode scaleMode() const; + virtual void setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode); + virtual qreal contrast() const; + virtual void setContrast(qreal constrast); + virtual qreal hue() const; + virtual void setHue(qreal hue); + virtual qreal saturation() const; + virtual void setSaturation(qreal saturation); + virtual QWidget *widget(); + + VideoOutput& videoOutput(); + +private: + QScopedPointer m_widget; + + Phonon::VideoWidget::AspectRatio m_aspectRatio; + qreal m_brightness; + Phonon::VideoWidget::ScaleMode m_scaleMode; + qreal m_contrast; + qreal m_hue; + qreal m_saturation; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/volumeobserver.h b/src/3rdparty/phonon/mmf/volumeobserver.h index d6717cba..bedd3de 100644 --- a/src/3rdparty/phonon/mmf/volumeobserver.h +++ b/src/3rdparty/phonon/mmf/volumeobserver.h @@ -25,18 +25,18 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * Interface used by AudioOutput to pass volume control commands - * back along the audio path to the MediaObject. - */ - class VolumeObserver - { - public: - virtual void volumeChanged(qreal volume) = 0; - }; - } +namespace MMF +{ +/** + * Interface used by AudioOutput to pass volume control commands + * back along the audio path to the MediaObject. + */ +class VolumeObserver +{ +public: + virtual void volumeChanged(qreal volume) = 0; +}; +} } QT_END_NAMESPACE -- cgit v0.12 From 104b5dc3b96f2d9d7fbae79ca1fcd303f3828d86 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 08:50:55 +0100 Subject: Added more tracing to VideoPlayer --- src/3rdparty/phonon/mmf/videoplayer.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index df922ec..546f761 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -365,36 +365,37 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() VideoOutput& output = videoOutput(); CCoeControl* const control = output.winId(); - TRACE("control 0x%08x", control); - TRACE("control isVisible %d", control->IsVisible()); - TRACE("control isDimmed %d", control->IsDimmed()); - TRACE("control hasBorder %d", control->HasBorder()); - TRACE("control position %d %d", + TRACE("control 0x%08x", control); + TRACE("control IsVisible %d", control->IsVisible()); + TRACE("control IsDimmed %d", control->IsDimmed()); + TRACE("control HasBorder %d", control->HasBorder()); + TRACE("control Position %d %d", control->Position().iX, control->Position().iY); - TRACE("control rect %d %d - %d %d", + TRACE("control Rect %d %d - %d %d", control->Rect().iTl.iX, control->Rect().iTl.iY, control->Rect().iBr.iX, control->Rect().iBr.iY); + TRACE("control OwnsWindow %d", control->OwnsWindow()); CCoeEnv* const coeEnv = control->ControlEnv(); m_wsSession = &(coeEnv->WsSession()); - TRACE("session handle 0x%08x", m_wsSession->Handle()); + TRACE("session Handle 0x%08x", m_wsSession->Handle()); m_screenDevice = coeEnv->ScreenDevice(); - TRACE("device srv handle 0x%08x", m_screenDevice->WsHandle()); + TRACE("device WsHandle 0x%08x", m_screenDevice->WsHandle()); m_window = control->DrawableWindow(); - TRACE("window cli handle 0x%08x", m_window->ClientHandle()); - TRACE("window srv handle 0x%08x", m_window->WsHandle()); - TRACE("window group %d", m_window->WindowGroupId()); - TRACE("window position %d %d", + TRACE("window ClientHandle 0x%08x", m_window->ClientHandle()); + TRACE("window WsHandle 0x%08x", m_window->WsHandle()); + TRACE("window WindowGroupId %d", m_window->WindowGroupId()); + TRACE("window Position %d %d", m_window->Position().iX, m_window->Position().iY); - TRACE("window abs_pos %d %d", + TRACE("window AbsPosition %d %d", m_window->AbsPosition().iX, m_window->AbsPosition().iY); - TRACE("window size %d %d", + TRACE("window Size %d %d", m_window->Size().iWidth, m_window->Size().iHeight); #ifdef PHONON_MMF_HARD_CODE_VIDEO_RECT -- cgit v0.12 From 559ef5cafeb39766a7481a37168e37e9cb315bb5 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 13:27:15 +0100 Subject: Wrapped code using QT_BEGIN/END_NAMESPACE macros --- src/3rdparty/phonon/mmf/1 | 139 ++++++++++++++++++++++++ src/3rdparty/phonon/mmf/TODO.txt | 6 - src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 6 +- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 4 + src/3rdparty/phonon/mmf/abstractplayer.cpp | 5 + src/3rdparty/phonon/mmf/abstractplayer.h | 4 + src/3rdparty/phonon/mmf/audiooutput.cpp | 4 + src/3rdparty/phonon/mmf/audiooutput.h | 4 + src/3rdparty/phonon/mmf/audioplayer.cpp | 16 +-- src/3rdparty/phonon/mmf/audioplayer.h | 4 + src/3rdparty/phonon/mmf/backend.cpp | 4 + src/3rdparty/phonon/mmf/backend.h | 4 + src/3rdparty/phonon/mmf/defs.h | 4 + src/3rdparty/phonon/mmf/dummyplayer.cpp | 5 +- src/3rdparty/phonon/mmf/dummyplayer.h | 4 + src/3rdparty/phonon/mmf/mediaobject.cpp | 3 + src/3rdparty/phonon/mmf/mediaobject.h | 4 + src/3rdparty/phonon/mmf/utils.cpp | 6 + src/3rdparty/phonon/mmf/utils.h | 4 + src/3rdparty/phonon/mmf/videooutput.cpp | 18 ++- src/3rdparty/phonon/mmf/videooutput.h | 7 +- src/3rdparty/phonon/mmf/videooutputobserver.h | 4 + src/3rdparty/phonon/mmf/videoplayer.cpp | 6 + src/3rdparty/phonon/mmf/videoplayer.h | 3 + src/3rdparty/phonon/mmf/videowidget.cpp | 8 +- src/3rdparty/phonon/mmf/videowidget.h | 4 + src/3rdparty/phonon/mmf/volumeobserver.h | 4 + 27 files changed, 251 insertions(+), 33 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/1 diff --git a/src/3rdparty/phonon/mmf/1 b/src/3rdparty/phonon/mmf/1 new file mode 100644 index 0000000..e5d6b26 --- /dev/null +++ b/src/3rdparty/phonon/mmf/1 @@ -0,0 +1,139 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "dummyplayer.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::DummyPlayer::DummyPlayer() +{ + +} + +MMF::DummyPlayer::DummyPlayer(const AbstractPlayer& player) + : AbstractPlayer(player) +{ + +} + + +//----------------------------------------------------------------------------- +// MediaObjectInterface +//----------------------------------------------------------------------------- + +void MMF::DummyPlayer::play() +{ + +} + +void MMF::DummyPlayer::pause() +{ + +} + +void MMF::DummyPlayer::stop() +{ + +} + +void MMF::DummyPlayer::seek(qint64) +{ + +} + +bool MMF::DummyPlayer::hasVideo() const +{ + return false; +} + +bool MMF::DummyPlayer::isSeekable() const +{ + return false; +} + +Phonon::State MMF::DummyPlayer::state() const +{ + return Phonon::LoadingState; +} + +qint64 MMF::DummyPlayer::currentTime() const +{ + return 0; +} + +QString MMF::DummyPlayer::errorString() const +{ + return QString(); +} + +Phonon::ErrorType MMF::DummyPlayer::errorType() const +{ + return Phonon::NoError; +} + +qint64 MMF::DummyPlayer::totalTime() const +{ + return 0; +} + +MediaSource MMF::DummyPlayer::source() const +{ + return MediaSource(); +} + +void MMF::DummyPlayer::setFileSource(const Phonon::MediaSource &, RFile &) +{ + +} + +void MMF::DummyPlayer::setNextSource(const MediaSource &) +{ + +} + + +//----------------------------------------------------------------------------- +// VolumeObserver +//----------------------------------------------------------------------------- + +void MMF::DummyPlayer::volumeChanged(qreal) +{ + +} + + +//----------------------------------------------------------------------------- +// AbstractPlayer +//----------------------------------------------------------------------------- + +void MMF::DummyPlayer::doSetTickInterval(qint32) +{ + +} + + + + + diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 49e8074..7f20793 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -12,9 +12,6 @@ The following items are in rough order of priority. - Dragging of other widgets on top of / underneath the video widget These will allow the video widget's moveEvent / resizeEvent implementations to be tested. -* Write / modify a test app which allows audio effects to be enabled / disabled. - - In the simplest case, this could just be a command-line app which allows effects to be specified using flags. - * On-target testing 1. Ensure that Phonon front- and back-end libraries are included in the SIS file. 2. Add musicplayer.exe and mediaplayer.exe to the FluidLauncher @@ -40,9 +37,6 @@ Compare video frame rate obtained using default S60 media player and Qt demo app * Implement MMF::Backend::disconnectNodes This should probably be left for now, particularly until audio effects have been implemented. This is because the node connection mechanism may need to be refactored slightly once we start building up longer graphs (e.g. MediaObject -> Effect -> Effect -> AudioOutput). -* Namespace macros -For consistency with other backends, the code should be wrapped in QT_BEGIN_NAMESPACE / QT_END_NAMESPACE macros. - * Fix code layout My editor was set to use tabs for indenting, rather than the Qt standard of 4 spaces. So we can either: 1. Do "s/\t/ /g" - which will just fix the indenting diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 7849d87..7883709 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -20,6 +20,8 @@ along with this library. If not, see . #include "defs.h" #include "utils.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -459,7 +461,5 @@ void MMF::AbstractMediaPlayer::tick() emit tick(currentTime()); } - - - +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 7f53a2d..51935a3 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -26,6 +26,8 @@ along with this library. If not, see . class RFile; +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -154,5 +156,7 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 9027f08..328ab37 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -19,6 +19,8 @@ along with this library. If not, see . #include "abstractplayer.h" #include "defs.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -96,3 +98,6 @@ void MMF::AbstractPlayer::videoOutputChanged() // Default behaviour is empty - overridden by VideoPlayer } + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 1c9ef9b..399cd5d 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -30,6 +30,8 @@ along with this library. If not, see . class RFile; +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -105,5 +107,7 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 82b2b82..099c899 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -23,6 +23,8 @@ along with this library. If not, see . #include "utils.h" #include "volumeobserver.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -92,3 +94,5 @@ void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer) } } + +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 5ecfc0d..ab90c44 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -21,6 +21,8 @@ along with this library. If not, see . #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -85,4 +87,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 41fedb4..50048c8 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -21,6 +21,8 @@ along with this library. If not, see . #include "audioplayer.h" #include "utils.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -242,17 +244,5 @@ void MMF::AudioPlayer::MaloLoadingComplete() #endif // QT_PHONON_MMF_AUDIO_DRM - - - - - - - - - - - - - +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 8d29547..cdb6cb9 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -34,6 +34,8 @@ typedef CMdaAudioPlayerUtility CPlayerType; typedef MMdaAudioPlayerCallback MPlayerObserverType; #endif +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -102,4 +104,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 010562e..236ef28 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -29,6 +29,8 @@ along with this library. If not, see . #include "utils.h" #include "videowidget.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -184,3 +186,5 @@ QStringList Backend::availableMimeTypes() const Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend); +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index 4fff204..b448187 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -22,6 +22,8 @@ along with this library. If not, see . #include #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -49,4 +51,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 12b8785..37a25d1 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -36,6 +36,8 @@ along with this library. If not, see . #define PHONON_MMF_DEBUG_VIDEO_OUTPUT +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -52,4 +54,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif // PHONON_MMF_DEFS_H diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index d9e836d..dc7f8d1 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -18,6 +18,8 @@ along with this library. If not, see . #include "dummyplayer.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -132,6 +134,5 @@ void MMF::DummyPlayer::doSetTickInterval(qint32) } - - +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 5846d88..12e3bd8 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -21,6 +21,8 @@ along with this library. If not, see . #include "abstractplayer.h" +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -70,4 +72,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 04b7dc7..91ed859 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -23,6 +23,7 @@ along with this library. If not, see . #include "utils.h" #include "videoplayer.h" +QT_BEGIN_NAMESPACE using namespace Phonon; using namespace Phonon::MMF; @@ -387,3 +388,5 @@ void MMF::MediaObject::setVideoOutput(VideoOutput* videoOutput) } +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 5bbca96..d9c32ce 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -30,6 +30,8 @@ along with this library. If not, see . #include "defs.h" #include "volumeobserver.h" +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -122,4 +124,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index 2655962..eb367f6 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -19,6 +19,8 @@ along with this library. If not, see . #include "utils.h" #include +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -65,3 +67,7 @@ MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) return result; } + + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index 2df7e48..e2b5e59 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -24,6 +24,8 @@ along with this library. If not, see . #include "defs.h" +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -158,4 +160,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 171565b..6534b7b 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -24,6 +24,8 @@ along with this library. If not, see . #include #include +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -87,12 +89,15 @@ void VideoOutput::dump() TRACE("maxSize %d %d", maximumWidth(), maximumHeight()); TRACE("sizeHint %d %d", sizeHint().width(), sizeHint().height()); - QWidget& parentWidget = *qobject_cast(parent()); - TRACE("parent.isVisible %d", parentWidget.isVisible()); - TRACE("parent.pos %d %d", parentWidget.x(), parentWidget.y()); - TRACE("parent.size %d %d", parentWidget.size().width(), parentWidget.size().height()); - TRACE("parent.maxSize %d %d", parentWidget.maximumWidth(), parentWidget.maximumHeight()); - TRACE("parent.sizeHint %d %d", parentWidget.sizeHint().width(), parentWidget.sizeHint().height()); + QWidget* parentWidget = qobject_cast(parent()); + if(parentWidget) + { + TRACE("parent.isVisible %d", parentWidget->isVisible()); + TRACE("parent.pos %d %d", parentWidget->x(), parentWidget->y()); + TRACE("parent.size %d %d", parentWidget->size().width(), parentWidget->size().height()); + TRACE("parent.maxSize %d %d", parentWidget->maximumWidth(), parentWidget->maximumHeight()); + TRACE("parent.sizeHint %d %d", parentWidget->sizeHint().width(), parentWidget->sizeHint().height()); + } TRACE_EXIT_0(); } @@ -214,4 +219,5 @@ void MMF::VideoOutput::moveEvent(QMoveEvent* event) //----------------------------------------------------------------------------- +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 6d1e4a0..b8e22ca 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -22,6 +22,8 @@ along with this library. If not, see . #include #include "defs.h" +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -33,11 +35,10 @@ namespace Phonon Q_OBJECT public: - VideoOutput(QWidget* parent); + explicit VideoOutput(QWidget* parent); ~VideoOutput(); void setFrameSize(const QSize& size); - void setObserver(VideoOutputObserver* observer); protected: @@ -64,4 +65,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/videooutputobserver.h b/src/3rdparty/phonon/mmf/videooutputobserver.h index 30fb3e0..d38ff87 100644 --- a/src/3rdparty/phonon/mmf/videooutputobserver.h +++ b/src/3rdparty/phonon/mmf/videooutputobserver.h @@ -21,6 +21,8 @@ along with this library. If not, see . #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -37,4 +39,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 546f761..ba06379 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -26,6 +26,8 @@ along with this library. If not, see . #include "videoplayer.h" #include "utils.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -408,3 +410,7 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() m_clipRect = m_windowRect; } + + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index a6f069f..f8b1486 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -25,6 +25,7 @@ along with this library. If not, see . #include "videooutput.h" #include "videooutputobserver.h" +QT_BEGIN_NAMESPACE namespace Phonon { @@ -105,4 +106,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 515f04e..ae94e5e 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -20,6 +20,8 @@ along with this library. If not, see . #include "videooutput.h" #include "videowidget.h" +QT_BEGIN_NAMESPACE + using namespace Phonon; using namespace Phonon::MMF; @@ -42,7 +44,8 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : m_widget(new VideoOutput(parent)) + : QObject(parent) + , m_widget(new VideoOutput(parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) @@ -158,3 +161,6 @@ VideoOutput& MMF::VideoWidget::videoOutput() return *static_cast(widget()); } + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index e8fc603..799121b 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -23,6 +23,8 @@ along with this library. If not, see . #include #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -70,4 +72,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif diff --git a/src/3rdparty/phonon/mmf/volumeobserver.h b/src/3rdparty/phonon/mmf/volumeobserver.h index 11ee960..d6717cba 100644 --- a/src/3rdparty/phonon/mmf/volumeobserver.h +++ b/src/3rdparty/phonon/mmf/volumeobserver.h @@ -21,6 +21,8 @@ along with this library. If not, see . #include +QT_BEGIN_NAMESPACE + namespace Phonon { namespace MMF @@ -37,4 +39,6 @@ namespace Phonon } } +QT_END_NAMESPACE + #endif -- cgit v0.12 From 1a551b57e5c9738ba81200dae6aa33ac8b6d2b96 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 13:45:45 +0100 Subject: Made non-toplevel widgets window-owning --- src/gui/kernel/qapplication_s60.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 44ac380..3a7fc4b 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -317,9 +317,14 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) { if (!desktop) { - if (topLevel) + // We cannot assume that parentless widgets are top-level + QWidget *const parent = qobject_cast(qwidget->parent()); + + if (topLevel or parent) CreateWindowL(S60->windowGroup()); - + else + CreateWindowL(parent->winId()); + SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); } -- cgit v0.12 From 76a7f0744cdfeb3ec25c77d4f237e60c74b7b141 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 13:51:35 +0100 Subject: Reformatted code to comply with Qt style --- src/3rdparty/phonon/mmf/TODO.txt | 5 - src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 347 ++++++++++---------- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 247 +++++++------- src/3rdparty/phonon/mmf/abstractplayer.cpp | 24 +- src/3rdparty/phonon/mmf/abstractplayer.h | 142 ++++----- src/3rdparty/phonon/mmf/audiooutput.cpp | 33 +- src/3rdparty/phonon/mmf/audiooutput.h | 120 +++---- src/3rdparty/phonon/mmf/audioplayer.cpp | 127 ++++---- src/3rdparty/phonon/mmf/audioplayer.h | 114 +++---- src/3rdparty/phonon/mmf/backend.cpp | 177 +++++------ src/3rdparty/phonon/mmf/backend.h | 46 +-- src/3rdparty/phonon/mmf/defs.h | 27 +- src/3rdparty/phonon/mmf/dummyplayer.cpp | 6 +- src/3rdparty/phonon/mmf/dummyplayer.h | 90 +++--- src/3rdparty/phonon/mmf/mediaobject.cpp | 343 +++++++++----------- src/3rdparty/phonon/mmf/mediaobject.h | 176 +++++----- src/3rdparty/phonon/mmf/utils.cpp | 24 +- src/3rdparty/phonon/mmf/utils.h | 250 +++++++-------- src/3rdparty/phonon/mmf/videooutput.cpp | 126 ++++---- src/3rdparty/phonon/mmf/videooutput.h | 68 ++-- src/3rdparty/phonon/mmf/videooutputobserver.h | 24 +- src/3rdparty/phonon/mmf/videoplayer.cpp | 407 ++++++++++++------------ src/3rdparty/phonon/mmf/videoplayer.h | 150 ++++----- src/3rdparty/phonon/mmf/videowidget.cpp | 94 +++--- src/3rdparty/phonon/mmf/videowidget.h | 86 ++--- src/3rdparty/phonon/mmf/volumeobserver.h | 24 +- 26 files changed, 1591 insertions(+), 1686 deletions(-) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 7f20793..846f0bb 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -37,9 +37,4 @@ Compare video frame rate obtained using default S60 media player and Qt demo app * Implement MMF::Backend::disconnectNodes This should probably be left for now, particularly until audio effects have been implemented. This is because the node connection mechanism may need to be refactored slightly once we start building up longer graphs (e.g. MediaObject -> Effect -> Effect -> AudioOutput). -* Fix code layout -My editor was set to use tabs for indenting, rather than the Qt standard of 4 spaces. So we can either: - 1. Do "s/\t/ /g" - which will just fix the indenting - 2. Use http://astyle.sourceforge.net/: - astyle --indent=spaces=4 --brackets=linux --indent-labels --pad=oper --unpad=paren --one-line=keep-statements --convert-tabs --indent-preprocessor --recursive ./ diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 7883709..1e032f3 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -29,7 +29,7 @@ using namespace Phonon::MMF; // Constants //----------------------------------------------------------------------------- -const int NullMaxVolume = -1; +const int NullMaxVolume = -1; //----------------------------------------------------------------------------- @@ -37,31 +37,31 @@ const int NullMaxVolume = -1; //----------------------------------------------------------------------------- MMF::AbstractMediaPlayer::AbstractMediaPlayer() : - m_state(GroundState) - , m_error(NoError) - , m_playPending(false) - , m_tickTimer(new QTimer(this)) - , m_volume(InitialVolume) - , m_mmfMaxVolume(NullMaxVolume) + m_state(GroundState) + , m_error(NoError) + , m_playPending(false) + , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) + , m_mmfMaxVolume(NullMaxVolume) { - connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); } MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) : - AbstractPlayer(player) - , m_state(GroundState) - , m_error(NoError) - , m_playPending(false) - , m_tickTimer(new QTimer(this)) - , m_volume(InitialVolume) - , m_mmfMaxVolume(NullMaxVolume) + AbstractPlayer(player) + , m_state(GroundState) + , m_error(NoError) + , m_playPending(false) + , m_tickTimer(new QTimer(this)) + , m_volume(InitialVolume) + , m_mmfMaxVolume(NullMaxVolume) { - connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); } MMF::AbstractMediaPlayer::~AbstractMediaPlayer() { - + } @@ -74,34 +74,33 @@ void MMF::AbstractMediaPlayer::play() TRACE_CONTEXT(AbstractMediaPlayer::play, EAudioApi); TRACE_ENTRY("state %d", m_state); - switch(m_state) - { - case GroundState: - // Is this the correct error? Really we want 'NotReadyError' - m_error = NormalError; - changeState(ErrorState); - break; - - case LoadingState: - m_playPending = true; - break; - - case StoppedState: - case PausedState: - doPlay(); - startTickTimer(); - changeState(PlayingState); - break; - - case PlayingState: - case BufferingState: - case ErrorState: - // Do nothing - break; + switch (m_state) { + case GroundState: + // Is this the correct error? Really we want 'NotReadyError' + m_error = NormalError; + changeState(ErrorState); + break; + + case LoadingState: + m_playPending = true; + break; + + case StoppedState: + case PausedState: + doPlay(); + startTickTimer(); + changeState(PlayingState); + break; + + case PlayingState: + case BufferingState: + case ErrorState: + // Do nothing + break; // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); + default: + TRACE_PANIC(InvalidStatePanic); } TRACE_EXIT("state %d", m_state); @@ -113,27 +112,26 @@ void MMF::AbstractMediaPlayer::pause() TRACE_ENTRY("state %d", m_state); m_playPending = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case PausedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - doPause(); - stopTickTimer(); - changeState(PausedState); - break; + + switch (m_state) { + case GroundState: + case LoadingState: + case StoppedState: + case PausedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + doPause(); + stopTickTimer(); + changeState(PausedState); + break; // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); + default: + TRACE_PANIC(InvalidStatePanic); } TRACE_EXIT("state %d", m_state); @@ -145,27 +143,26 @@ void MMF::AbstractMediaPlayer::stop() TRACE_ENTRY("state %d", m_state); m_playPending = false; - - switch(m_state) - { - case GroundState: - case LoadingState: - case StoppedState: - case ErrorState: - // Do nothing - break; - - case PlayingState: - case BufferingState: - case PausedState: - doStop(); - stopTickTimer(); - changeState(StoppedState); - break; + + switch (m_state) { + case GroundState: + case LoadingState: + case StoppedState: + case ErrorState: + // Do nothing + break; + + case PlayingState: + case BufferingState: + case PausedState: + doStop(); + stopTickTimer(); + changeState(StoppedState); + break; // Protection against adding new states and forgetting to update this switch - default: - TRACE_PANIC(InvalidStatePanic); + default: + TRACE_PANIC(InvalidStatePanic); } TRACE_EXIT("state %d", m_state); @@ -177,23 +174,22 @@ void MMF::AbstractMediaPlayer::seek(qint64 ms) TRACE_ENTRY("state %d pos %Ld", state(), ms); // TODO: put a state guard in here - + const bool tickTimerWasRunning = m_tickTimer->isActive(); stopTickTimer(); - + doSeek(ms); - - if(tickTimerWasRunning) - { + + if (tickTimerWasRunning) { startTickTimer(); } - + TRACE_EXIT_0(); } bool MMF::AbstractMediaPlayer::isSeekable() const { - return true; + return true; } void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) @@ -209,7 +205,7 @@ void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) Phonon::ErrorType MMF::AbstractMediaPlayer::errorType() const { const Phonon::ErrorType result = (ErrorState == m_state) - ? m_error : NoError; + ? m_error : NoError; return result; } @@ -244,58 +240,52 @@ void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& f TInt symbianErr = KErrNone; - switch(m_source.type()) - { - case MediaSource::LocalFile: - { - // TODO: work out whose responsibility it is to ensure that paths - // are Symbian-style, i.e. have backslashes for path delimiters. - // Until then, use this utility function... - //const QHBufC filename = Utils::symbianFilename(m_source.fileName()); - //TRAP(symbianErr, m_player->OpenFileL(*filename)); - - // Open using shared filehandle - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //TRAP(symbianErr, m_player->OpenFileL(file)); - - symbianErr = openFile(file); - break; - } + switch (m_source.type()) { + case MediaSource::LocalFile: { + // TODO: work out whose responsibility it is to ensure that paths + // are Symbian-style, i.e. have backslashes for path delimiters. + // Until then, use this utility function... + //const QHBufC filename = Utils::symbianFilename(m_source.fileName()); + //TRAP(symbianErr, m_player->OpenFileL(*filename)); + + // Open using shared filehandle + // This is a temporary hack to work around KErrInUse from MMF + // client utility OpenFileL calls + //TRAP(symbianErr, m_player->OpenFileL(file)); + + symbianErr = openFile(file); + break; + } - case MediaSource::Url: - { - TRACE_0("Source type not supported"); - // TODO: support opening URLs - symbianErr = KErrNotSupported; - break; - } + case MediaSource::Url: { + TRACE_0("Source type not supported"); + // TODO: support opening URLs + symbianErr = KErrNotSupported; + break; + } - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - TRACE_0("Source type not supported"); - symbianErr = KErrNotSupported; - break; + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + TRACE_0("Source type not supported"); + symbianErr = KErrNotSupported; + break; - case MediaSource::Empty: - TRACE_0("Empty source - doing nothing"); - TRACE_EXIT_0(); - return; + case MediaSource::Empty: + TRACE_0("Empty source - doing nothing"); + TRACE_EXIT_0(); + return; // Protection against adding new media types and forgetting to update this switch - default: - TRACE_PANIC(InvalidMediaTypePanic); + default: + TRACE_PANIC(InvalidMediaTypePanic); } - if(KErrNone == symbianErr) - { + if (KErrNone == symbianErr) { changeState(LoadingState); - } - else - { - TRACE("error %d", symbianErr) - + } else { + TRACE("error %d", symbianErr) + // TODO: do something with the value of symbianErr? m_error = NormalError; changeState(ErrorState); @@ -326,44 +316,41 @@ void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) { TRACE_CONTEXT(AbstractMediaPlayer::volumeChanged, EAudioInternal); TRACE_ENTRY("state %d", m_state); - + m_volume = volume; doVolumeChanged(); - + TRACE_EXIT_0(); } void MMF::AbstractMediaPlayer::doVolumeChanged() { - switch(m_state) - { - case GroundState: - case LoadingState: - case ErrorState: - // Do nothing - break; - - case StoppedState: - case PausedState: - case PlayingState: - case BufferingState: - { - const int err = setDeviceVolume(m_volume * m_mmfMaxVolume); - - if(KErrNone != err) - { - m_error = NormalError; - changeState(ErrorState); - } - break; - } - - // Protection against adding new states and forgetting to update this - // switch - default: - Utils::panic(InvalidStatePanic); - } + switch (m_state) { + case GroundState: + case LoadingState: + case ErrorState: + // Do nothing + break; + + case StoppedState: + case PausedState: + case PlayingState: + case BufferingState: { + const int err = setDeviceVolume(m_volume * m_mmfMaxVolume); + + if (KErrNone != err) { + m_error = NormalError; + changeState(ErrorState); + } + break; + } + + // Protection against adding new states and forgetting to update this + // switch + default: + Utils::panic(InvalidStatePanic); + } } @@ -373,23 +360,23 @@ void MMF::AbstractMediaPlayer::doVolumeChanged() void MMF::AbstractMediaPlayer::startTickTimer() { - m_tickTimer->start(tickInterval()); + m_tickTimer->start(tickInterval()); } void MMF::AbstractMediaPlayer::stopTickTimer() { - m_tickTimer->stop(); + m_tickTimer->stop(); } void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) { - m_mmfMaxVolume = mmfMaxVolume; - doVolumeChanged(); + m_mmfMaxVolume = mmfMaxVolume; + doVolumeChanged(); } Phonon::State MMF::AbstractMediaPlayer::phononState() const { - return phononState(m_state); + return phononState(m_state); } Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) @@ -411,27 +398,25 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) const Phonon::State oldPhononState = phononState(m_state); const Phonon::State newPhononState = phononState(newState); - if(oldPhononState != newPhononState) - { + if (oldPhononState != newPhononState) { TRACE("emit stateChanged(%d, %d)", newPhononState, oldPhononState); emit stateChanged(newPhononState, oldPhononState); } m_state = newState; - + // Check whether play() was called while clip was being loaded. If so, // playback should be started now - if( - LoadingState == oldPhononState - and StoppedState == newPhononState - and m_playPending - ) - { - TRACE_0("play was called while loading; starting playback now"); - m_playPending = false; - play(); + if ( + LoadingState == oldPhononState + and StoppedState == newPhononState + and m_playPending + ) { + TRACE_0("play was called while loading; starting playback now"); + m_playPending = false; + play(); } - + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 51935a3..f11b559 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -30,130 +30,129 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class AudioOutput; - - /** - * Interface via which MMF client APIs for both audio and video can be - * accessed. - */ - class AbstractMediaPlayer : public AbstractPlayer - { - Q_OBJECT - - protected: - AbstractMediaPlayer(); - explicit AbstractMediaPlayer(const AbstractPlayer& player); - ~AbstractMediaPlayer(); - - public: - // MediaObjectInterface - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual bool isSeekable() const; - virtual Phonon::ErrorType errorType() const; - virtual QString errorString() const; - virtual Phonon::State state() const; - virtual MediaSource source() const; - virtual void setFileSource(const Phonon::MediaSource&, RFile&); - virtual void setNextSource(const MediaSource &source); - - // VolumeObserver - virtual void volumeChanged(qreal volume); - - protected: - // AbstractPlayer - virtual void doSetTickInterval(qint32 interval); - - protected: - virtual void doPlay() = 0; - virtual void doPause() = 0; - virtual void doStop() = 0; - virtual void doSeek(qint64 pos) = 0; - virtual int setDeviceVolume(int mmfVolume) = 0; - virtual int openFile(RFile& file) = 0; - virtual void close() = 0; - - protected: - bool tickTimerRunning() const; - void startTickTimer(); - void stopTickTimer(); - void maxVolumeChanged(int maxVolume); - - /** - * Defined private state enumeration in order to add GroundState - */ - enum PrivateState - { - LoadingState = Phonon::LoadingState, - StoppedState = Phonon::StoppedState, - PlayingState = Phonon::PlayingState, - BufferingState = Phonon::BufferingState, - PausedState = Phonon::PausedState, - ErrorState = Phonon::ErrorState, - GroundState - }; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - Phonon::State phononState() const; - - /** - * Converts PrivateState into the corresponding Phonon::State - */ - static Phonon::State phononState(PrivateState state); - - /** - * Changes state and emits stateChanged() - */ - void changeState(PrivateState newState); - - /** - * Records error and changes state to ErrorState - */ - void setError(Phonon::ErrorType error); - - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - private: - void doVolumeChanged(); - - Q_SIGNALS: - void tick(qint64 time); - void stateChanged(Phonon::State oldState, - Phonon::State newState); - - private Q_SLOTS: - /** - * Receives signal from m_tickTimer - */ - void tick(); - - private: - PrivateState m_state; - Phonon::ErrorType m_error; - - /** - * This flag is set to true if play is called when the object is - * in a Loading state. Once loading is complete, playback will - * be started. - */ - bool m_playPending; - - QScopedPointer m_tickTimer; - - qreal m_volume; - int m_mmfMaxVolume; - - MediaSource m_source; - MediaSource m_nextSource; - - }; - } +namespace MMF +{ +class AudioOutput; + +/** + * Interface via which MMF client APIs for both audio and video can be + * accessed. + */ +class AbstractMediaPlayer : public AbstractPlayer +{ + Q_OBJECT + +protected: + AbstractMediaPlayer(); + explicit AbstractMediaPlayer(const AbstractPlayer& player); + ~AbstractMediaPlayer(); + +public: + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual bool isSeekable() const; + virtual Phonon::ErrorType errorType() const; + virtual QString errorString() const; + virtual Phonon::State state() const; + virtual MediaSource source() const; + virtual void setFileSource(const Phonon::MediaSource&, RFile&); + virtual void setNextSource(const MediaSource &source); + + // VolumeObserver + virtual void volumeChanged(qreal volume); + +protected: + // AbstractPlayer + virtual void doSetTickInterval(qint32 interval); + +protected: + virtual void doPlay() = 0; + virtual void doPause() = 0; + virtual void doStop() = 0; + virtual void doSeek(qint64 pos) = 0; + virtual int setDeviceVolume(int mmfVolume) = 0; + virtual int openFile(RFile& file) = 0; + virtual void close() = 0; + +protected: + bool tickTimerRunning() const; + void startTickTimer(); + void stopTickTimer(); + void maxVolumeChanged(int maxVolume); + + /** + * Defined private state enumeration in order to add GroundState + */ + enum PrivateState { + LoadingState = Phonon::LoadingState, + StoppedState = Phonon::StoppedState, + PlayingState = Phonon::PlayingState, + BufferingState = Phonon::BufferingState, + PausedState = Phonon::PausedState, + ErrorState = Phonon::ErrorState, + GroundState + }; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + Phonon::State phononState() const; + + /** + * Converts PrivateState into the corresponding Phonon::State + */ + static Phonon::State phononState(PrivateState state); + + /** + * Changes state and emits stateChanged() + */ + void changeState(PrivateState newState); + + /** + * Records error and changes state to ErrorState + */ + void setError(Phonon::ErrorType error); + + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + +private: + void doVolumeChanged(); + +Q_SIGNALS: + void tick(qint64 time); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + +private Q_SLOTS: + /** + * Receives signal from m_tickTimer + */ + void tick(); + +private: + PrivateState m_state; + Phonon::ErrorType m_error; + + /** + * This flag is set to true if play is called when the object is + * in a Loading state. Once loading is complete, playback will + * be started. + */ + bool m_playPending; + + QScopedPointer m_tickTimer; + + qreal m_volume; + int m_mmfMaxVolume; + + MediaSource m_source; + MediaSource m_nextSource; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 328ab37..c6f0f6b 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -30,19 +30,19 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::AbstractPlayer::AbstractPlayer() - : m_videoOutput(NULL) - , m_tickInterval(DefaultTickInterval) - , m_transitionTime(0) - , m_prefinishMark(0) + : m_videoOutput(NULL) + , m_tickInterval(DefaultTickInterval) + , m_transitionTime(0) + , m_prefinishMark(0) { } MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) - : m_videoOutput(player.m_videoOutput) - , m_tickInterval(player.tickInterval()) - , m_transitionTime(player.transitionTime()) - , m_prefinishMark(player.prefinishMark()) + : m_videoOutput(player.m_videoOutput) + , m_tickInterval(player.tickInterval()) + , m_transitionTime(player.transitionTime()) + , m_prefinishMark(player.prefinishMark()) { } @@ -64,17 +64,17 @@ void MMF::AbstractPlayer::setTickInterval(qint32 interval) qint32 MMF::AbstractPlayer::prefinishMark() const { - return m_prefinishMark; + return m_prefinishMark; } void MMF::AbstractPlayer::setPrefinishMark(qint32 mark) { - m_prefinishMark = mark; + m_prefinishMark = mark; } qint32 MMF::AbstractPlayer::transitionTime() const { - return m_transitionTime; + return m_transitionTime; } void MMF::AbstractPlayer::setTransitionTime(qint32 time) @@ -95,7 +95,7 @@ void MMF::AbstractPlayer::setVideoOutput(VideoOutput* videoOutput) void MMF::AbstractPlayer::videoOutputChanged() { - // Default behaviour is empty - overridden by VideoPlayer + // Default behaviour is empty - overridden by VideoPlayer } diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 399cd5d..da0fe51 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -34,77 +34,77 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class VideoOutput; - - /** - * @short Interface which abstracts from MediaObject the current - * media type - * - * This may be: - * - Nothing, in which case this interface is implemented by - * DummyPlayer - * - Audio, in which case the implementation is AudioPlayer - * - Video, in which case the implementation is VideoPlayer - */ - class AbstractPlayer : public QObject - , public VolumeObserver - { - // Required although this class has no signals or slots - // Without this, qobject_cast will fail - Q_OBJECT - - public: - AbstractPlayer(); - explicit AbstractPlayer(const AbstractPlayer& player); - - // MediaObjectInterface (implemented) - qint32 tickInterval() const; - void setTickInterval(qint32); - void setTransitionTime(qint32); - qint32 transitionTime() const; - void setPrefinishMark(qint32); - qint32 prefinishMark() const; - - // MediaObjectInterface (abstract) - virtual void play() = 0; - virtual void pause() = 0; - virtual void stop() = 0; - virtual void seek(qint64 milliseconds) = 0; - virtual bool hasVideo() const = 0; - virtual bool isSeekable() const = 0; - virtual qint64 currentTime() const = 0; - virtual Phonon::State state() const = 0; - virtual QString errorString() const = 0; - virtual Phonon::ErrorType errorType() const = 0; - virtual qint64 totalTime() const = 0; - virtual Phonon::MediaSource source() const = 0; - // This is a temporary hack to work around KErrInUse from MMF - // client utility OpenFileL calls - //virtual void setSource(const Phonon::MediaSource &) = 0; - virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; - virtual void setNextSource(const Phonon::MediaSource &) = 0; - - void setVideoOutput(VideoOutput* videoOutput); - - protected: - virtual void videoOutputChanged(); - - private: - virtual void doSetTickInterval(qint32 interval) = 0; - - protected: - // Not owned - VideoOutput* m_videoOutput; - - private: - qint32 m_tickInterval; - qint32 m_transitionTime; - qint32 m_prefinishMark; - - }; - } +namespace MMF +{ +class VideoOutput; + +/** + * @short Interface which abstracts from MediaObject the current + * media type + * + * This may be: + * - Nothing, in which case this interface is implemented by + * DummyPlayer + * - Audio, in which case the implementation is AudioPlayer + * - Video, in which case the implementation is VideoPlayer + */ +class AbstractPlayer : public QObject + , public VolumeObserver +{ + // Required although this class has no signals or slots + // Without this, qobject_cast will fail + Q_OBJECT + +public: + AbstractPlayer(); + explicit AbstractPlayer(const AbstractPlayer& player); + + // MediaObjectInterface (implemented) + qint32 tickInterval() const; + void setTickInterval(qint32); + void setTransitionTime(qint32); + qint32 transitionTime() const; + void setPrefinishMark(qint32); + qint32 prefinishMark() const; + + // MediaObjectInterface (abstract) + virtual void play() = 0; + virtual void pause() = 0; + virtual void stop() = 0; + virtual void seek(qint64 milliseconds) = 0; + virtual bool hasVideo() const = 0; + virtual bool isSeekable() const = 0; + virtual qint64 currentTime() const = 0; + virtual Phonon::State state() const = 0; + virtual QString errorString() const = 0; + virtual Phonon::ErrorType errorType() const = 0; + virtual qint64 totalTime() const = 0; + virtual Phonon::MediaSource source() const = 0; + // This is a temporary hack to work around KErrInUse from MMF + // client utility OpenFileL calls + //virtual void setSource(const Phonon::MediaSource &) = 0; + virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; + virtual void setNextSource(const Phonon::MediaSource &) = 0; + + void setVideoOutput(VideoOutput* videoOutput); + +protected: + virtual void videoOutputChanged(); + +private: + virtual void doSetTickInterval(qint32 interval) = 0; + +protected: + // Not owned + VideoOutput* m_videoOutput; + +private: + qint32 m_tickInterval; + qint32 m_transitionTime; + qint32 m_prefinishMark; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 099c899..909e568 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -33,9 +33,9 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) - , m_volume(InitialVolume) - , m_observer(NULL) +MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) + , m_volume(InitialVolume) + , m_observer(NULL) { } @@ -47,7 +47,7 @@ MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) qreal MMF::AudioOutput::volume() const { - return m_volume; + return m_volume; } void MMF::AudioOutput::setVolume(qreal volume) @@ -55,18 +55,16 @@ void MMF::AudioOutput::setVolume(qreal volume) TRACE_CONTEXT(AudioOutput::setVolume, EAudioApi); TRACE_ENTRY("observer 0x%08x volume %f", m_observer, volume); - if(volume != m_volume) - { - if(m_observer) - { - m_observer->volumeChanged(volume); - } - - m_volume = volume; - TRACE("emit volumeChanged(%f)", volume) - emit volumeChanged(volume); + if (volume != m_volume) { + if (m_observer) { + m_observer->volumeChanged(volume); + } + + m_volume = volume; + TRACE("emit volumeChanged(%f)", volume) + emit volumeChanged(volume); } - + TRACE_EXIT_0(); } @@ -88,9 +86,8 @@ bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer) { m_observer = observer; - if(m_observer) - { - m_observer->volumeChanged(m_volume); + if (m_observer) { + m_observer->volumeChanged(m_volume); } } diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index ab90c44..001190f 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -25,66 +25,66 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class Backend; - class VolumeObserver; - - /** - * @short AudioOutputInterface implementation for MMF. - * - * Forwards volume commands to the VolumeObserver instance, - * which is provided by the backend when MediaNode objects are - * connected. - * - * \section volume Volume - * - * Phonon's concept on volume is from 0.0 to 1.0, and from 1< it does - * voltage multiplication. CDrmPlayerUtility goes from 1 to - * CDrmPlayerUtility::MaxVolume(). We apply some basic math to convert - * between the two. - * - * @author Frans Englich - */ - class AudioOutput : public QObject - , public AudioOutputInterface - { - Q_OBJECT - Q_INTERFACES(Phonon::AudioOutputInterface) - - public: - AudioOutput(Backend *backend, QObject *parent); - virtual qreal volume() const; - virtual void setVolume(qreal volume); - - virtual int outputDevice() const; - - /** - * Has no effect. - */ - virtual bool setOutputDevice(int); - - /** - * Has no effect. - */ - virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); - - /** - * Called by backend when nodes are connected. - */ - void setVolumeObserver(VolumeObserver* observer); - - Q_SIGNALS: - void volumeChanged(qreal volume); - void audioDeviceFailed(); - - private: - qreal m_volume; - - // Not owned - VolumeObserver* m_observer; - }; - } +namespace MMF +{ +class Backend; +class VolumeObserver; + +/** + * @short AudioOutputInterface implementation for MMF. + * + * Forwards volume commands to the VolumeObserver instance, + * which is provided by the backend when MediaNode objects are + * connected. + * + * \section volume Volume + * + * Phonon's concept on volume is from 0.0 to 1.0, and from 1< it does + * voltage multiplication. CDrmPlayerUtility goes from 1 to + * CDrmPlayerUtility::MaxVolume(). We apply some basic math to convert + * between the two. + * + * @author Frans Englich + */ +class AudioOutput : public QObject + , public AudioOutputInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::AudioOutputInterface) + +public: + AudioOutput(Backend *backend, QObject *parent); + virtual qreal volume() const; + virtual void setVolume(qreal volume); + + virtual int outputDevice() const; + + /** + * Has no effect. + */ + virtual bool setOutputDevice(int); + + /** + * Has no effect. + */ + virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); + + /** + * Called by backend when nodes are connected. + */ + void setVolumeObserver(VolumeObserver* observer); + +Q_SIGNALS: + void volumeChanged(qreal volume); + void audioDeviceFailed(); + +private: + qreal m_volume; + + // Not owned + VolumeObserver* m_observer; +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 50048c8..1229625 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -30,32 +30,31 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioPlayer::AudioPlayer() : m_player(NULL) +MMF::AudioPlayer::AudioPlayer() : m_player(NULL) { - construct(); + construct(); } MMF::AudioPlayer::AudioPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) - , m_player(NULL) + : AbstractMediaPlayer(player) + , m_player(NULL) { - construct(); + construct(); } void MMF::AudioPlayer::construct() { - TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); - TRACE_ENTRY_0(); - - // TODO: is this the correct way to handle errors which occur when - // creating a Symbian object in the constructor of a Qt object? - TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); - if(KErrNone != err) - { - changeState(ErrorState); - } - - TRACE_EXIT_0(); + TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); + TRACE_ENTRY_0(); + + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? + TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); + if (KErrNone != err) { + changeState(ErrorState); + } + + TRACE_EXIT_0(); } MMF::AudioPlayer::~AudioPlayer() @@ -74,17 +73,17 @@ MMF::AudioPlayer::~AudioPlayer() void MMF::AudioPlayer::doPlay() { - m_player->Play(); + m_player->Play(); } void MMF::AudioPlayer::doPause() { - m_player->Pause(); + m_player->Pause(); } void MMF::AudioPlayer::doStop() { - m_player->Stop(); + m_player->Stop(); } void MMF::AudioPlayer::doSeek(qint64 ms) @@ -94,30 +93,29 @@ void MMF::AudioPlayer::doSeek(qint64 ms) int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) { - return m_player->SetVolume(mmfVolume); + return m_player->SetVolume(mmfVolume); } int MMF::AudioPlayer::openFile(RFile& file) { - TRAPD(err, m_player->OpenFileL(file)); - + TRAPD(err, m_player->OpenFileL(file)); + #ifdef QT_PHONON_MMF_AUDIO_DRM - if(KErrNone == err) - { + if (KErrNone == err) { // There appears to be a bug in the CDrmPlayerUtility implementation (at least // in S60 5.x) whereby the player does not check whether the loading observer // pointer is null before dereferencing it. Therefore we must register for // loading notification, even though we do nothing in the callback functions. m_player->RegisterForAudioLoadingNotification(*this); - } + } #endif - - return err; + + return err; } void MMF::AudioPlayer::close() { - m_player->Close(); + m_player->Close(); } bool MMF::AudioPlayer::hasVideo() const @@ -134,17 +132,14 @@ qint64 MMF::AudioPlayer::currentTime() const qint64 result = 0; - if(KErrNone == err) - { + if (KErrNone == err) { result = toMilliSeconds(us); - } - else - { - TRACE("GetPosition err %d", err); - - // If we don't cast away constness here, we simply have to ignore - // the error. - const_cast(this)->setError(NormalError); + } else { + TRACE("GetPosition err %d", err); + + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast(this)->setError(NormalError); } return result; @@ -162,10 +157,10 @@ qint64 MMF::AudioPlayer::totalTime() const #ifdef QT_PHONON_MMF_AUDIO_DRM void MMF::AudioPlayer::MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &) + const TTimeIntervalMicroSeconds &) #else void MMF::AudioPlayer::MapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &) + const TTimeIntervalMicroSeconds &) #endif { TRACE_CONTEXT(AudioPlayer::MapcInitComplete, EAudioInternal); @@ -173,15 +168,12 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - if(KErrNone == aError) - { - maxVolumeChanged(m_player->MaxVolume()); + if (KErrNone == aError) { + maxVolumeChanged(m_player->MaxVolume()); - emit totalTimeChanged(totalTime()); - changeState(StoppedState); - } - else - { + emit totalTimeChanged(totalTime()); + changeState(StoppedState); + } else { // TODO: set different error states according to value of aError? setError(NormalError); } @@ -200,33 +192,30 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) stopTickTimer(); - if(KErrNone == aError) - { + if (KErrNone == aError) { changeState(StoppedState); // TODO: move on to m_nextSource - } - else - { + } else { // TODO: do something with aError? setError(NormalError); } -/* - if(aError == KErrNone) { - if(m_nextSource.type() == MediaSource::Empty) { - emit finished(); - } else { - setSource(m_nextSource); - m_nextSource = MediaSource(); - } + /* + if(aError == KErrNone) { + if(m_nextSource.type() == MediaSource::Empty) { + emit finished(); + } else { + setSource(m_nextSource); + m_nextSource = MediaSource(); + } - changeState(StoppedState); - } - else { - m_error = NormalError; - changeState(ErrorState); - } -*/ + changeState(StoppedState); + } + else { + m_error = NormalError; + changeState(ErrorState); + } + */ TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index cdb6cb9..424985c 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -38,70 +38,70 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * @short Wrapper over MMF audio client utility - */ - class AudioPlayer : public AbstractMediaPlayer - , public MPlayerObserverType // typedef +namespace MMF +{ +/** + * @short Wrapper over MMF audio client utility + */ +class AudioPlayer : public AbstractMediaPlayer + , public MPlayerObserverType // typedef #ifdef QT_PHONON_MMF_AUDIO_DRM - , public MAudioLoadingObserver + , public MAudioLoadingObserver #endif - { - Q_OBJECT - - public: - AudioPlayer(); - explicit AudioPlayer(const AbstractPlayer& player); - virtual ~AudioPlayer(); - - // AbstractMediaPlayer - virtual void doPlay(); - virtual void doPause(); - virtual void doStop(); - virtual void doSeek(qint64 milliseconds); - virtual int setDeviceVolume(int mmfVolume); - virtual int openFile(RFile& file); - virtual void close(); - - // MediaObjectInterface - virtual bool hasVideo() const; - virtual qint64 currentTime() const; - virtual qint64 totalTime() const; +{ + Q_OBJECT + +public: + AudioPlayer(); + explicit AudioPlayer(const AbstractPlayer& player); + virtual ~AudioPlayer(); + + // AbstractMediaPlayer + virtual void doPlay(); + virtual void doPause(); + virtual void doStop(); + virtual void doSeek(qint64 milliseconds); + virtual int setDeviceVolume(int mmfVolume); + virtual int openFile(RFile& file); + virtual void close(); + + // MediaObjectInterface + virtual bool hasVideo() const; + virtual qint64 currentTime() const; + virtual qint64 totalTime() const; #ifdef QT_PHONON_MMF_AUDIO_DRM - // MDrmAudioPlayerCallback - virtual void MdapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MdapcPlayComplete(TInt aError); - - // MAudioLoadingObserver - virtual void MaloLoadingStarted(); - virtual void MaloLoadingComplete(); + // MDrmAudioPlayerCallback + virtual void MdapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MdapcPlayComplete(TInt aError); + + // MAudioLoadingObserver + virtual void MaloLoadingStarted(); + virtual void MaloLoadingComplete(); #else - // MMdaAudioPlayerCallback - virtual void MapcInitComplete(TInt aError, - const TTimeIntervalMicroSeconds &aDuration); - virtual void MapcPlayComplete(TInt aError); + // MMdaAudioPlayerCallback + virtual void MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds &aDuration); + virtual void MapcPlayComplete(TInt aError); #endif - Q_SIGNALS: - void totalTimeChanged(qint64 length); - void finished(); - - private: - void construct(); - - private: - /** - * Using CPlayerType typedef in order to be able to easily switch between - * CMdaAudioPlayerUtility and CDrmPlayerUtility - */ - CPlayerType* m_player; - - }; - } +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void finished(); + +private: + void construct(); + +private: + /** + * Using CPlayerType typedef in order to be able to easily switch between + * CMdaAudioPlayerUtility and CDrmPlayerUtility + */ + CPlayerType* m_player; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 236ef28..71e51d9 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -34,49 +34,48 @@ QT_BEGIN_NAMESPACE using namespace Phonon; using namespace Phonon::MMF; -Backend::Backend(QObject *parent) : QObject(parent) +Backend::Backend(QObject *parent) : QObject(parent) { - TRACE_CONTEXT(Backend::Backend, EBackend); - TRACE_ENTRY_0(); + TRACE_CONTEXT(Backend::Backend, EBackend); + TRACE_ENTRY_0(); setProperty("identifier", QLatin1String("phonon_mmf")); setProperty("backendName", QLatin1String("MMF")); setProperty("backendComment", QLatin1String("Backend using Symbian Multimedia Framework (MMF)")); setProperty("backendVersion", QLatin1String("0.1")); setProperty("backendWebsite", QLatin1String("http://www.qtsoftware.com/")); - + TRACE_EXIT_0(); } QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &) { - TRACE_CONTEXT(Backend::createObject, EBackend); - TRACE_ENTRY("class %d", c); - - QObject* result = NULL; - - switch(c) - { - case AudioOutputClass: - result = new AudioOutput(this, parent); - break; - - case MediaObjectClass: - result = new MediaObject(parent); - break; - - case VolumeFaderEffectClass: - case VisualizationClass: - case VideoDataOutputClass: - case EffectClass: - break; - - case VideoWidgetClass: - result = new VideoWidget(qobject_cast(parent)); - break; - - default: - TRACE_PANIC(InvalidBackendInterfaceClass); + TRACE_CONTEXT(Backend::createObject, EBackend); + TRACE_ENTRY("class %d", c); + + QObject* result = NULL; + + switch (c) { + case AudioOutputClass: + result = new AudioOutput(this, parent); + break; + + case MediaObjectClass: + result = new MediaObject(parent); + break; + + case VolumeFaderEffectClass: + case VisualizationClass: + case VideoDataOutputClass: + case EffectClass: + break; + + case VideoWidgetClass: + result = new VideoWidget(qobject_cast(parent)); + break; + + default: + TRACE_PANIC(InvalidBackendInterfaceClass); } TRACE_RETURN("0x%08x", result); @@ -99,46 +98,44 @@ bool Backend::startConnectionChange(QSet) bool Backend::connectNodes(QObject *source, QObject *target) { - TRACE_CONTEXT(Backend::connectNodes, EBackend); - TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); + TRACE_CONTEXT(Backend::connectNodes, EBackend); + TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - MediaObject *const mediaObject = qobject_cast(source); + MediaObject *const mediaObject = qobject_cast(source); AudioOutput *const audioOutput = qobject_cast(target); VideoWidget *const videoWidget = qobject_cast(target); - + bool result = false; - - if(mediaObject and audioOutput) - { - TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); - audioOutput->setVolumeObserver(mediaObject); - result = true; + + if (mediaObject and audioOutput) { + TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); + audioOutput->setVolumeObserver(mediaObject); + result = true; } - - if(mediaObject and videoWidget) - { - TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); - mediaObject->setVideoOutput(&videoWidget->videoOutput()); - result = true; - } - + + if (mediaObject and videoWidget) { + TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); + mediaObject->setVideoOutput(&videoWidget->videoOutput()); + result = true; + } + TRACE_RETURN("%d", result); } bool Backend::disconnectNodes(QObject *source, QObject *target) { - TRACE_CONTEXT(Backend::disconnectNodes, EBackend); - TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - - MediaObject *const mediaObject = qobject_cast(source); - AudioOutput *const audioOutput = qobject_cast(target); - VideoWidget *const videoWidget = qobject_cast(target); - - bool result = true; - - // TODO: disconnection - - TRACE_RETURN("%d", result); + TRACE_CONTEXT(Backend::disconnectNodes, EBackend); + TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); + + MediaObject *const mediaObject = qobject_cast(source); + AudioOutput *const audioOutput = qobject_cast(target); + VideoWidget *const videoWidget = qobject_cast(target); + + bool result = true; + + // TODO: disconnection + + TRACE_RETURN("%d", result); } bool Backend::endConnectionChange(QSet) @@ -148,40 +145,38 @@ bool Backend::endConnectionChange(QSet) void getAvailableMimeTypesL(QStringList& result) { - RApaLsSession apaSession; - User::LeaveIfError(apaSession.Connect()); - CleanupClosePushL(apaSession); - - static const TInt DataTypeArrayGranularity = 8; - CDataTypeArray* array = new (ELeave) CDataTypeArray(DataTypeArrayGranularity); - CleanupStack::PushL(array); - - apaSession.GetSupportedDataTypesL(*array); - - for(TInt i=0; iCount(); ++i) - { - const TPtrC mimeType = array->At(i).Des(); - const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType); - if(MediaTypeAudio == mediaType or MediaTypeVideo == mediaType) - { - result.append(qt_TDesC2QString(mimeType)); - } - } - - CleanupStack::PopAndDestroy(2); // apaSession, array + RApaLsSession apaSession; + User::LeaveIfError(apaSession.Connect()); + CleanupClosePushL(apaSession); + + static const TInt DataTypeArrayGranularity = 8; + CDataTypeArray* array = new(ELeave) CDataTypeArray(DataTypeArrayGranularity); + CleanupStack::PushL(array); + + apaSession.GetSupportedDataTypesL(*array); + + for (TInt i = 0; i < array->Count(); ++i) { + const TPtrC mimeType = array->At(i).Des(); + const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType); + if (MediaTypeAudio == mediaType or MediaTypeVideo == mediaType) { + result.append(qt_TDesC2QString(mimeType)); + } + } + + CleanupStack::PopAndDestroy(2); // apaSession, array } QStringList Backend::availableMimeTypes() const { - QStringList result; - - // There is no way to return an error from this function, so we just - // have to trap and ignore exceptions... - TRAP_IGNORE(getAvailableMimeTypesL(result)); - - result.sort(); - - return result; + QStringList result; + + // There is no way to return an error from this function, so we just + // have to trap and ignore exceptions... + TRAP_IGNORE(getAvailableMimeTypesL(result)); + + result.sort(); + + return result; } Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend); diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index b448187..7598fa7 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -26,29 +26,29 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class Backend : public QObject - , public BackendInterface - { - Q_OBJECT - Q_INTERFACES(Phonon::BackendInterface) - public: - Backend(QObject *parent = 0); - - virtual QObject *createObject(BackendInterface::Class c, QObject *parent, const QList &args); - virtual QList objectDescriptionIndexes(ObjectDescriptionType type) const; - virtual QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const; - virtual bool startConnectionChange(QSet); - virtual bool connectNodes(QObject *, QObject *); - virtual bool disconnectNodes(QObject *, QObject *); - virtual bool endConnectionChange(QSet); - virtual QStringList availableMimeTypes() const; - - Q_SIGNALS: - void objectDescriptionChanged(ObjectDescriptionType); - }; - } +namespace MMF +{ +class Backend : public QObject + , public BackendInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::BackendInterface) +public: + Backend(QObject *parent = 0); + + virtual QObject *createObject(BackendInterface::Class c, QObject *parent, const QList &args); + virtual QList objectDescriptionIndexes(ObjectDescriptionType type) const; + virtual QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const; + virtual bool startConnectionChange(QSet); + virtual bool connectNodes(QObject *, QObject *); + virtual bool disconnectNodes(QObject *, QObject *); + virtual bool endConnectionChange(QSet); + virtual QStringList availableMimeTypes() const; + +Q_SIGNALS: + void objectDescriptionChanged(ObjectDescriptionType); +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 37a25d1..674e767 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -21,11 +21,11 @@ along with this library. If not, see . #include -// The following macros are for switching on / off various bits of code, +// The following macros are for switching on / off various bits of code, // in order to debug the current problems with video visibility. // If this is defined, then VideoOutput is essentially just a typedef for -// QWidget. This is to allow us to test whether the QWidget function +// QWidget. This is to allow us to test whether the QWidget function // overrides present in VideoOutput (e.g. sizeHint, paintEvent etc) may // be the cause of the visibility problems. //#define PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET @@ -40,18 +40,17 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - static const qint32 DefaultTickInterval = 10; - static const qreal InitialVolume = 0.5; - - enum MediaType - { - MediaTypeUnknown, - MediaTypeAudio, - MediaTypeVideo - }; - } +namespace MMF +{ +static const qint32 DefaultTickInterval = 10; +static const qreal InitialVolume = 0.5; + +enum MediaType { + MediaTypeUnknown, + MediaTypeAudio, + MediaTypeVideo +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index dc7f8d1..dc55af7 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -29,13 +29,13 @@ using namespace Phonon::MMF; MMF::DummyPlayer::DummyPlayer() { - + } MMF::DummyPlayer::DummyPlayer(const AbstractPlayer& player) - : AbstractPlayer(player) + : AbstractPlayer(player) { - + } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 12e3bd8..b2725df 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -25,51 +25,51 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class AudioOutput; - - /** - * @short Stub implementation of AbstractPlayer. - * - * The functions of this class are: - * - Allow MediaObject to call a subset of the MediaObjectInterface - * API, before SetSource has been called. - * - Cache any parameters which are set in this state (e.g. - * prefinish mark), so that they can be copied into the 'real' - * AbstractPlayer implementation once a source has been loaded. - */ - class DummyPlayer : public AbstractPlayer - { - public: - DummyPlayer(); - DummyPlayer(const AbstractPlayer& player); - - // MediaObjectInterface - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual bool hasVideo() const; - virtual bool isSeekable() const; - virtual qint64 currentTime() const; - virtual Phonon::State state() const; - virtual QString errorString() const; - virtual Phonon::ErrorType errorType() const; - virtual qint64 totalTime() const; - virtual MediaSource source() const; - // virtual void setSource(const MediaSource &); - virtual void setFileSource(const Phonon::MediaSource&, RFile&); - virtual void setNextSource(const MediaSource &source); - - // VolumeObserver - virtual void volumeChanged(qreal volume); - - // AbstractPlayer - virtual void doSetTickInterval(qint32 interval); - - }; - } +namespace MMF +{ +class AudioOutput; + +/** + * @short Stub implementation of AbstractPlayer. + * + * The functions of this class are: + * - Allow MediaObject to call a subset of the MediaObjectInterface + * API, before SetSource has been called. + * - Cache any parameters which are set in this state (e.g. + * prefinish mark), so that they can be copied into the 'real' + * AbstractPlayer implementation once a source has been loaded. + */ +class DummyPlayer : public AbstractPlayer +{ +public: + DummyPlayer(); + DummyPlayer(const AbstractPlayer& player); + + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + // virtual void setSource(const MediaSource &); + virtual void setFileSource(const Phonon::MediaSource&, RFile&); + virtual void setNextSource(const MediaSource &source); + + // VolumeObserver + virtual void volumeChanged(qreal volume); + + // AbstractPlayer + virtual void doSetTickInterval(qint32 interval); + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 91ed859..bf55781 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -32,8 +32,8 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::MediaObject::MediaObject(QObject *parent) : QObject(parent) - , m_recognizerOpened(false) +MMF::MediaObject::MediaObject(QObject *parent) : QObject(parent) + , m_recognizerOpened(false) { m_player.reset(new DummyPlayer()); @@ -64,74 +64,63 @@ MMF::MediaObject::~MediaObject() bool MMF::MediaObject::openRecognizer() { - TRACE_CONTEXT(MediaObject::openRecognizer, EAudioInternal); - - if(!m_recognizerOpened) - { - TInt err = m_recognizer.Connect(); - if(KErrNone != err) - { - TRACE("RApaLsSession::Connect error %d", err); - return false; - } - - err = m_fileServer.Connect(); - if(KErrNone != err) - { - TRACE("RFs::Connect error %d", err); - return false; - } - - // This must be called in order to be able to share file handles with - // the recognizer server (see fileMediaType function). - err = m_fileServer.ShareProtected(); - if(KErrNone != err) - { - TRACE("RFs::ShareProtected error %d", err); - return false; - } - - m_recognizerOpened = true; - } - - return true; + TRACE_CONTEXT(MediaObject::openRecognizer, EAudioInternal); + + if (!m_recognizerOpened) { + TInt err = m_recognizer.Connect(); + if (KErrNone != err) { + TRACE("RApaLsSession::Connect error %d", err); + return false; + } + + err = m_fileServer.Connect(); + if (KErrNone != err) { + TRACE("RFs::Connect error %d", err); + return false; + } + + // This must be called in order to be able to share file handles with + // the recognizer server (see fileMediaType function). + err = m_fileServer.ShareProtected(); + if (KErrNone != err) { + TRACE("RFs::ShareProtected error %d", err); + return false; + } + + m_recognizerOpened = true; + } + + return true; } MMF::MediaType MMF::MediaObject::fileMediaType - (const QString& fileName) +(const QString& fileName) { - TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal); - - MediaType result = MediaTypeUnknown; - - if(openRecognizer()) - { - QHBufC fileNameSymbian = Utils::symbianFilename(fileName); - - m_file.Close(); - TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead|EFileShareReadersOnly); - - if(KErrNone == err) - { - TDataRecognitionResult recognizerResult; - err = m_recognizer.RecognizeData(m_file, recognizerResult); - if(KErrNone == err) - { - const TPtrC mimeType = recognizerResult.iDataType.Des(); - result = Utils::mimeTypeToMediaType(mimeType); - } - else - { - TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err); - } - } - else - { - TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err); - } - } - - return result; + TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal); + + MediaType result = MediaTypeUnknown; + + if (openRecognizer()) { + QHBufC fileNameSymbian = Utils::symbianFilename(fileName); + + m_file.Close(); + TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly); + + if (KErrNone == err) { + TDataRecognitionResult recognizerResult; + err = m_recognizer.RecognizeData(m_file, recognizerResult); + if (KErrNone == err) { + const TPtrC mimeType = recognizerResult.iDataType.Des(); + result = Utils::mimeTypeToMediaType(mimeType); + } else { + TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err); + } + } else { + TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err); + } + } + + return result; } @@ -157,9 +146,8 @@ void MMF::MediaObject::stop() void MMF::MediaObject::seek(qint64 ms) { m_player->seek(ms); - - if(state() == PausedState or state() == PlayingState) - { + + if (state() == PausedState or state() == PlayingState) { emit tick(currentTime()); } } @@ -216,130 +204,117 @@ MediaSource MMF::MediaObject::source() const void MMF::MediaObject::setSource(const MediaSource &source) { - createPlayer(source); - + createPlayer(source); + // This is a hack to work around KErrInUse from MMF client utility // OpenFileL calls m_player->setFileSource(source, m_file); - + emit currentSourceChanged(source); } void MMF::MediaObject::createPlayer(const MediaSource &source) { - TRACE_CONTEXT(MediaObject::createPlayer, EAudioApi); + TRACE_CONTEXT(MediaObject::createPlayer, EAudioApi); TRACE_ENTRY("state %d source.type %d", state(), source.type()); - TRACE_ENTRY("source.type %d", source.type()); - - MediaType mediaType = MediaTypeUnknown; - - AbstractPlayer* oldPlayer = m_player.data(); - - const bool oldPlayerHasVideo = oldPlayer->hasVideo(); - const bool oldPlayerSeekable = oldPlayer->isSeekable(); - - // Determine media type - switch(source.type()) - { - case MediaSource::LocalFile: - mediaType = fileMediaType(source.fileName()); - break; - - case MediaSource::Url: - // TODO: support detection of media type from HTTP streams - TRACE_0("Network streaming not supported yet"); - /* - * TODO: handle error - * - m_error = NormalError; - changeState(ErrorState); - */ - break; - - case MediaSource::Invalid: - case MediaSource::Disc: - case MediaSource::Stream: - TRACE_0("Unsupported media type"); - /* - * TODO: handle error - * - m_error = NormalError; - changeState(ErrorState); - */ - break; - - case MediaSource::Empty: - TRACE_0("Empty media source"); - break; - } - - AbstractPlayer* newPlayer = NULL; - - // Construct newPlayer using oldPlayer (if not NULL) in order to copy - // parameters (volume, prefinishMark, transitionTime) which may have - // been set on oldPlayer. - - switch(mediaType) - { - case MediaTypeUnknown: - TRACE_0("Media type could not be determined"); - if(oldPlayer) - { - newPlayer = new DummyPlayer(*oldPlayer); - } - else - { - newPlayer = new DummyPlayer(); - } - /* - * TODO: handle error? - * - m_error = NormalError; - changeState(ErrorState); - */ - break; - - case MediaTypeAudio: - if(oldPlayer) - { - newPlayer = new AudioPlayer(*oldPlayer); - } - else - { - newPlayer = new AudioPlayer(); - } - break; - - case MediaTypeVideo: - if(oldPlayer) - { - newPlayer = new VideoPlayer(*oldPlayer); - } - else - { - newPlayer = new VideoPlayer(); - } - break; - } - - m_player.reset(newPlayer); - - if(oldPlayerHasVideo != hasVideo()) - { - emit hasVideoChanged(hasVideo()); - } - - if(oldPlayerSeekable != isSeekable()) - { - emit seekableChanged(isSeekable()); - } - - connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64))); - connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); - connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); - connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); - - TRACE_EXIT_0(); + TRACE_ENTRY("source.type %d", source.type()); + + MediaType mediaType = MediaTypeUnknown; + + AbstractPlayer* oldPlayer = m_player.data(); + + const bool oldPlayerHasVideo = oldPlayer->hasVideo(); + const bool oldPlayerSeekable = oldPlayer->isSeekable(); + + // Determine media type + switch (source.type()) { + case MediaSource::LocalFile: + mediaType = fileMediaType(source.fileName()); + break; + + case MediaSource::Url: + // TODO: support detection of media type from HTTP streams + TRACE_0("Network streaming not supported yet"); + /* + * TODO: handle error + * + m_error = NormalError; + changeState(ErrorState); + */ + break; + + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + TRACE_0("Unsupported media type"); + /* + * TODO: handle error + * + m_error = NormalError; + changeState(ErrorState); + */ + break; + + case MediaSource::Empty: + TRACE_0("Empty media source"); + break; + } + + AbstractPlayer* newPlayer = NULL; + + // Construct newPlayer using oldPlayer (if not NULL) in order to copy + // parameters (volume, prefinishMark, transitionTime) which may have + // been set on oldPlayer. + + switch (mediaType) { + case MediaTypeUnknown: + TRACE_0("Media type could not be determined"); + if (oldPlayer) { + newPlayer = new DummyPlayer(*oldPlayer); + } else { + newPlayer = new DummyPlayer(); + } + /* + * TODO: handle error? + * + m_error = NormalError; + changeState(ErrorState); + */ + break; + + case MediaTypeAudio: + if (oldPlayer) { + newPlayer = new AudioPlayer(*oldPlayer); + } else { + newPlayer = new AudioPlayer(); + } + break; + + case MediaTypeVideo: + if (oldPlayer) { + newPlayer = new VideoPlayer(*oldPlayer); + } else { + newPlayer = new VideoPlayer(); + } + break; + } + + m_player.reset(newPlayer); + + if (oldPlayerHasVideo != hasVideo()) { + emit hasVideoChanged(hasVideo()); + } + + if (oldPlayerSeekable != isSeekable()) { + emit seekableChanged(isSeekable()); + } + + connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64))); + connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); + connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); + connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); + + TRACE_EXIT_0(); } void MMF::MediaObject::setNextSource(const MediaSource &source) diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index d9c32ce..c53b908 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -34,94 +34,94 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class AbstractPlayer; - class VideoOutput; - - /** - * @short Facade class which wraps MMF client utility instance - */ - class MediaObject : public QObject - , public MediaObjectInterface - , public VolumeObserver - { - Q_OBJECT - Q_INTERFACES(Phonon::MediaObjectInterface) - - public: - MediaObject(QObject *parent); - virtual ~MediaObject(); - - // MediaObjectInterface - virtual void play(); - virtual void pause(); - virtual void stop(); - virtual void seek(qint64 milliseconds); - virtual qint32 tickInterval() const; - virtual void setTickInterval(qint32 interval); - virtual bool hasVideo() const; - virtual bool isSeekable() const; - virtual qint64 currentTime() const; - virtual Phonon::State state() const; - virtual QString errorString() const; - virtual Phonon::ErrorType errorType() const; - virtual qint64 totalTime() const; - virtual MediaSource source() const; - virtual void setSource(const MediaSource &); - virtual void setNextSource(const MediaSource &source); - virtual qint32 prefinishMark() const; - virtual void setPrefinishMark(qint32); - virtual qint32 transitionTime() const; - virtual void setTransitionTime(qint32); - - // VolumeObserver - void volumeChanged(qreal volume); - - void setVideoOutput(VideoOutput* videoOutput); - - Q_SIGNALS: - void totalTimeChanged(qint64 length); - void hasVideoChanged(bool hasVideo); - void seekableChanged(bool seekable); - // TODO: emit bufferStatus from MediaObject - void bufferStatus(int); - // TODO: emit aboutToFinish from MediaObject - void aboutToFinish(); - // TODO: emit prefinishMarkReached from MediaObject - void prefinishMarkReached(qint32); - // TODO: emit metaDataChanged from MediaObject - void metaDataChanged(const QMultiMap& metaData); - void currentSourceChanged(const MediaSource& source); - void stateChanged(Phonon::State oldState, - Phonon::State newState); - void finished(); - void tick(qint64 time); - - private: - void createPlayer(const MediaSource &source); - bool openRecognizer(); - - // Audio / video media type recognition - MediaType fileMediaType(const QString& fileName); - // TODO: urlMediaType function - - static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); - - private: - // Audio / video media type recognition - bool m_recognizerOpened; - RApaLsSession m_recognizer; - RFs m_fileServer; - - // Storing the file handle here to work around KErrInUse error - // from MMF player utility OpenFileL functions - RFile m_file; - - QScopedPointer m_player; - - }; - } +namespace MMF +{ +class AbstractPlayer; +class VideoOutput; + +/** + * @short Facade class which wraps MMF client utility instance + */ +class MediaObject : public QObject + , public MediaObjectInterface + , public VolumeObserver +{ + Q_OBJECT + Q_INTERFACES(Phonon::MediaObjectInterface) + +public: + MediaObject(QObject *parent); + virtual ~MediaObject(); + + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual qint32 tickInterval() const; + virtual void setTickInterval(qint32 interval); + virtual bool hasVideo() const; + virtual bool isSeekable() const; + virtual qint64 currentTime() const; + virtual Phonon::State state() const; + virtual QString errorString() const; + virtual Phonon::ErrorType errorType() const; + virtual qint64 totalTime() const; + virtual MediaSource source() const; + virtual void setSource(const MediaSource &); + virtual void setNextSource(const MediaSource &source); + virtual qint32 prefinishMark() const; + virtual void setPrefinishMark(qint32); + virtual qint32 transitionTime() const; + virtual void setTransitionTime(qint32); + + // VolumeObserver + void volumeChanged(qreal volume); + + void setVideoOutput(VideoOutput* videoOutput); + +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void hasVideoChanged(bool hasVideo); + void seekableChanged(bool seekable); + // TODO: emit bufferStatus from MediaObject + void bufferStatus(int); + // TODO: emit aboutToFinish from MediaObject + void aboutToFinish(); + // TODO: emit prefinishMarkReached from MediaObject + void prefinishMarkReached(qint32); + // TODO: emit metaDataChanged from MediaObject + void metaDataChanged(const QMultiMap& metaData); + void currentSourceChanged(const MediaSource& source); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + void finished(); + void tick(qint64 time); + +private: + void createPlayer(const MediaSource &source); + bool openRecognizer(); + + // Audio / video media type recognition + MediaType fileMediaType(const QString& fileName); + // TODO: urlMediaType function + + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + +private: + // Audio / video media type recognition + bool m_recognizerOpened; + RApaLsSession m_recognizer; + RFs m_fileServer; + + // Storing the file handle here to work around KErrInUse error + // from MMF player utility OpenFileL functions + RFile m_file; + + QScopedPointer m_player; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index eb367f6..df9ceae 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -38,8 +38,7 @@ QHBufC MMF::Utils::symbianFilename(const QString& qtFilename) QHBufC result(qtFilename); TInt pos = result->Find(ForwardSlash); - while(pos != KErrNotFound) - { + while (pos != KErrNotFound) { result->Des().Replace(pos, 1, BackwardSlash); pos = result->Find(ForwardSlash); } @@ -54,18 +53,15 @@ _LIT(KMimePrefixVideo, "video/"); MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) { - MediaType result = MediaTypeUnknown; - - if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) - { - result = MediaTypeAudio; - } - else if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) - { - result = MediaTypeVideo; - } - - return result; + MediaType result = MediaTypeUnknown; + + if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) { + result = MediaTypeAudio; + } else if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) { + result = MediaTypeVideo; + } + + return result; } diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index e2b5e59..c0487a7 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -20,7 +20,7 @@ along with this library. If not, see . #define PHONON_MMF_UTILS_H #include -#include // for RDebug +#include // for RDebug #include "defs.h" @@ -28,136 +28,132 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * Panic codes for fatal errors - */ - enum PanicCode - { - InvalidStatePanic = 1, - InvalidMediaTypePanic = 2, - InvalidBackendInterfaceClass = 3 - }; - - namespace Utils - { - /** - * Raise a fatal exception - */ - void panic(PanicCode code); - - /** - * Translate forward slashes to backslashes - * - * \note This function is a temporary measure, for use until the - * responsibility for constructing valid file paths is - * determined. - */ - QHBufC symbianFilename(const QString& qtFilename); - - /** - * Determines whether the provided MIME type is an audio or video - * type. If it is neither, the function returns MediaTypeUnknown. - */ - MediaType mimeTypeToMediaType(const TDesC& mimeType); - } - - /** - * Available trace categories; - */ - enum TTraceCategory - { - /** - * Backend - */ - EBackend = 0x00000001, - - /** - * Functions which map directly to the public Phonon audio API - */ - EAudioApi = 0x00000010, - - /** - * Internal functions in the audio implementation - */ - EAudioInternal = 0x00000020, - - /** - * Functions which map directly to the public Phonon video API - */ - EVideoApi = 0x00010000, - - /** - * Internal functions in the video implementation - */ - EVideoInternal = 0x00020000 - }; - - /** - * Mask indicating which trace categories are enabled - * - * Note that, at the moment, this is a compiled static constant. For - * runtime control over enabled trace categories, this could be replaced - * by a per-thread singleton object which owns the trace mask, and which - * exposes an API allowing it to be modified. - */ - static const TUint KTraceMask = 0xffffffff; - - /** - * Data structure used by tracing macros - */ - class TTraceContext - { - public: - TTraceContext(const TText* aFunction, const TUint aAddr, - const TUint aCategory=0) +namespace MMF +{ +/** + * Panic codes for fatal errors + */ +enum PanicCode { + InvalidStatePanic = 1, + InvalidMediaTypePanic = 2, + InvalidBackendInterfaceClass = 3 +}; + +namespace Utils +{ +/** + * Raise a fatal exception + */ +void panic(PanicCode code); + +/** + * Translate forward slashes to backslashes + * + * \note This function is a temporary measure, for use until the + * responsibility for constructing valid file paths is + * determined. + */ +QHBufC symbianFilename(const QString& qtFilename); + +/** + * Determines whether the provided MIME type is an audio or video + * type. If it is neither, the function returns MediaTypeUnknown. + */ +MediaType mimeTypeToMediaType(const TDesC& mimeType); +} + +/** + * Available trace categories; + */ +enum TTraceCategory { + /** + * Backend + */ + EBackend = 0x00000001, + + /** + * Functions which map directly to the public Phonon audio API + */ + EAudioApi = 0x00000010, + + /** + * Internal functions in the audio implementation + */ + EAudioInternal = 0x00000020, + + /** + * Functions which map directly to the public Phonon video API + */ + EVideoApi = 0x00010000, + + /** + * Internal functions in the video implementation + */ + EVideoInternal = 0x00020000 +}; + +/** + * Mask indicating which trace categories are enabled + * + * Note that, at the moment, this is a compiled static constant. For + * runtime control over enabled trace categories, this could be replaced + * by a per-thread singleton object which owns the trace mask, and which + * exposes an API allowing it to be modified. + */ +static const TUint KTraceMask = 0xffffffff; + +/** + * Data structure used by tracing macros + */ +class TTraceContext +{ +public: + TTraceContext(const TText* aFunction, const TUint aAddr, + const TUint aCategory = 0) : iFunction(aFunction), - iAddr(aAddr), - iCategory(aCategory) - { } - - /** - * Check whether iCategory appears in the trace mask - */ - TBool Enabled() const - { - return (iCategory == 0) or (iCategory & KTraceMask); - } - - const TText* iFunction; // Name of function - const TUint iAddr; // 'this' pointer - const TUint iCategory; - }; - - // Macros used internally by the trace system - #define _TRACE_PRINT RDebug::Print - #define _TRACE_TEXT(x) (TPtrC((const TText *)(x))) - #define _TRACE_MODULE Phonon::MMF - - // Macros available for use by implementation code + iAddr(aAddr), + iCategory(aCategory) { } + + /** + * Check whether iCategory appears in the trace mask + */ + TBool Enabled() const { + return (iCategory == 0) or(iCategory & KTraceMask); + } + + const TText* iFunction; // Name of function + const TUint iAddr; // 'this' pointer + const TUint iCategory; +}; + +// Macros used internally by the trace system +#define _TRACE_PRINT RDebug::Print +#define _TRACE_TEXT(x) (TPtrC((const TText *)(x))) +#define _TRACE_MODULE Phonon::MMF + +// Macros available for use by implementation code #ifdef _DEBUG - #define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat); - #define TRACE_ENTRY_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } - #define TRACE_ENTRY(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } - #define TRACE_EXIT_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } - #define TRACE_EXIT(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } - #define TRACE_RETURN(string, result) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "r Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, result); } return result; - #define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code); - #define TRACE_0(string) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); } - #define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat); +#define TRACE_ENTRY_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } +#define TRACE_ENTRY(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#define TRACE_EXIT_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } +#define TRACE_EXIT(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#define TRACE_RETURN(string, result) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "r Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, result); } return result; +#define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code); +#define TRACE_0(string) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); } +#define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } #else - #define TRACE_CONTEXT(_fn, _cat) - #define TRACE_ENTRY_0() - #define TRACE_ENTRY(string, args...) - #define TRACE_EXIT_0() - #define TRACE_EXIT(string, args...) - #define TRACE_RETURN(string, result) return result; - #define TRACE_PANIC(code) Utils::panic(code); - #define TRACE_0(string) - #define TRACE(string, args...) +#define TRACE_CONTEXT(_fn, _cat) +#define TRACE_ENTRY_0() +#define TRACE_ENTRY(string, args...) +#define TRACE_EXIT_0() +#define TRACE_EXIT(string, args...) +#define TRACE_RETURN(string, result) return result; +#define TRACE_PANIC(code) Utils::panic(code); +#define TRACE_0(string) +#define TRACE(string, args...) #endif - } +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 6534b7b..53178cb 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -34,24 +34,24 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::VideoOutput::VideoOutput(QWidget* parent) - : QWidget(parent) - , m_observer(NULL) + : QWidget(parent) + , m_observer(NULL) { - TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); - TRACE_ENTRY("parent 0x%08x", parent); + TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); + TRACE_ENTRY("parent 0x%08x", parent); #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - setPalette(QPalette(Qt::black)); - //setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); - setAutoFillBackground(false); + setPalette(QPalette(Qt::black)); + //setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + setAutoFillBackground(false); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - + #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT - dump(); + dump(); #endif - - TRACE_EXIT_0(); + + TRACE_EXIT_0(); } #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT @@ -59,56 +59,54 @@ void VideoOutput::dump() { TRACE_CONTEXT(VideoOutput::dump, EVideoInternal); TRACE_ENTRY_0(); - + TRACE("dumpObjectInfo this 0x%08x", this); this->dumpObjectInfo(); TRACE_0("Traversing up object tree ..."); QObject* node = this; QObject* root = this; - while(node) - { + while (node) { QWidget* widget = qobject_cast(node); const bool visible = widget ? widget->isVisible() : false; const QHBufC name(node->objectName()); TRACE("node 0x%08x name %S widget 0x%08x visible %d", node, name.data(), widget, visible); - + root = node; node = node->parent(); } - + TRACE("dumpObjectInfo root 0x%08x", root); root->dumpObjectInfo(); TRACE_0("+ dumpObjectTree"); root->dumpObjectTree(); TRACE_0("- dumpObjectTree"); - + TRACE("isVisible %d", isVisible()); TRACE("pos %d %d", x(), y()); TRACE("size %d %d", size().width(), size().height()); TRACE("maxSize %d %d", maximumWidth(), maximumHeight()); TRACE("sizeHint %d %d", sizeHint().width(), sizeHint().height()); - + QWidget* parentWidget = qobject_cast(parent()); - if(parentWidget) - { + if (parentWidget) { TRACE("parent.isVisible %d", parentWidget->isVisible()); TRACE("parent.pos %d %d", parentWidget->x(), parentWidget->y()); TRACE("parent.size %d %d", parentWidget->size().width(), parentWidget->size().height()); TRACE("parent.maxSize %d %d", parentWidget->maximumWidth(), parentWidget->maximumHeight()); TRACE("parent.sizeHint %d %d", parentWidget->sizeHint().width(), parentWidget->sizeHint().height()); } - + TRACE_EXIT_0(); } #endif // PHONON_MMF_DEBUG_VIDEO_OUTPUT MMF::VideoOutput::~VideoOutput() { - TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); - TRACE_ENTRY_0(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } void MMF::VideoOutput::setFrameSize(const QSize& frameSize) @@ -118,11 +116,10 @@ void MMF::VideoOutput::setFrameSize(const QSize& frameSize) #else TRACE_CONTEXT(VideoOutput::setFrameSize, EVideoInternal); TRACE("oldSize %d %d newSize %d %d", - m_frameSize.width(), m_frameSize.height(), - frameSize.width(), frameSize.height()); - - if(frameSize != m_frameSize) - { + m_frameSize.width(), m_frameSize.height(), + frameSize.width(), frameSize.height()); + + if (frameSize != m_frameSize) { m_frameSize = frameSize; updateGeometry(); } @@ -133,7 +130,7 @@ void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) { TRACE_CONTEXT(VideoOutput::setObserver, EVideoInternal); TRACE("observer 0x%08x", observer); - + m_observer = observer; } @@ -147,35 +144,34 @@ void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) QSize MMF::VideoOutput::sizeHint() const { TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); - + // TODO: replace this with a more sensible default QSize result(320, 240); - - if(!m_frameSize.isNull()) - { + + if (!m_frameSize.isNull()) { result = m_frameSize; } - + TRACE(" result %d %d", result.width(), result.height()); return result; } void MMF::VideoOutput::paintEvent(QPaintEvent* event) { - TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); - TRACE("rect %d %d - %d %d", - event->rect().left(), event->rect().top(), - event->rect().right(), event->rect().bottom()); - TRACE("regions %d", event->region().numRects()); - TRACE("type %d", event->type()); - - QWidget::paintEvent(event); + TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); + TRACE("rect %d %d - %d %d", + event->rect().left(), event->rect().top(), + event->rect().right(), event->rect().bottom()); + TRACE("regions %d", event->region().numRects()); + TRACE("type %d", event->type()); + + QWidget::paintEvent(event); } QPaintEngine* MMF::VideoOutput::paintEngine() const { TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); - + QPaintEngine* const engine = QWidget::paintEngine(); TRACE_RETURN("0x%08x", engine); @@ -183,30 +179,28 @@ QPaintEngine* MMF::VideoOutput::paintEngine() const void MMF::VideoOutput::resizeEvent(QResizeEvent* event) { - TRACE_CONTEXT(VideoOutput::resizeEvent, EVideoInternal); - TRACE("%d %d -> %d %d", - event->oldSize().width(), event->oldSize().height(), - event->size().width(), event->size().height()); - - QWidget::resizeEvent(event); - - if(m_observer) - { - m_observer->videoOutputRegionChanged(); - } + TRACE_CONTEXT(VideoOutput::resizeEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldSize().width(), event->oldSize().height(), + event->size().width(), event->size().height()); + + QWidget::resizeEvent(event); + + if (m_observer) { + m_observer->videoOutputRegionChanged(); + } } void MMF::VideoOutput::moveEvent(QMoveEvent* event) { - TRACE_CONTEXT(VideoOutput::moveEvent, EVideoInternal); - TRACE("%d %d -> %d %d", - event->oldPos().x(), event->oldPos().y(), - event->pos().x(), event->pos().y()); - - QWidget::moveEvent(event); - - if(m_observer) - { + TRACE_CONTEXT(VideoOutput::moveEvent, EVideoInternal); + TRACE("%d %d -> %d %d", + event->oldPos().x(), event->oldPos().y(), + event->pos().x(), event->pos().y()); + + QWidget::moveEvent(event); + + if (m_observer) { m_observer->videoOutputRegionChanged(); } } diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index b8e22ca..0da6ea0 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -26,43 +26,43 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class VideoOutputObserver; - - class VideoOutput : public QWidget - { - Q_OBJECT - - public: - explicit VideoOutput(QWidget* parent); - ~VideoOutput(); - - void setFrameSize(const QSize& size); - void setObserver(VideoOutputObserver* observer); - - protected: - #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - // Override QWidget functions - QSize sizeHint() const; - void paintEvent(QPaintEvent* event); - void resizeEvent(QResizeEvent* event); - void moveEvent(QMoveEvent* event); - QPaintEngine* paintEngine() const; - #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET +namespace MMF +{ +class VideoOutputObserver; + +class VideoOutput : public QWidget +{ + Q_OBJECT + +public: + explicit VideoOutput(QWidget* parent); + ~VideoOutput(); + + void setFrameSize(const QSize& size); + void setObserver(VideoOutputObserver* observer); + +protected: +#ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET + // Override QWidget functions + QSize sizeHint() const; + void paintEvent(QPaintEvent* event); + void resizeEvent(QResizeEvent* event); + void moveEvent(QMoveEvent* event); + QPaintEngine* paintEngine() const; +#endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT - public: - void dump(); +public: + void dump(); #endif - - private: - QSize m_frameSize; - - // Not owned - VideoOutputObserver* m_observer; - }; - } + +private: + QSize m_frameSize; + + // Not owned + VideoOutputObserver* m_observer; +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutputobserver.h b/src/3rdparty/phonon/mmf/videooutputobserver.h index d38ff87..e3ba305 100644 --- a/src/3rdparty/phonon/mmf/videooutputobserver.h +++ b/src/3rdparty/phonon/mmf/videooutputobserver.h @@ -25,18 +25,18 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * Interface via which VideoOutput notifies VideoPlayer of changes to the - * video output screen region. - */ - class VideoOutputObserver - { - public: - virtual void videoOutputRegionChanged() = 0; - }; - } +namespace MMF +{ +/** + * Interface via which VideoOutput notifies VideoPlayer of changes to the + * video output screen region. + */ +class VideoOutputObserver +{ +public: + virtual void videoOutputRegionChanged() = 0; +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index ba06379..f008edd 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -20,7 +20,7 @@ along with this library. If not, see . #include #include -#include // For CCoeEnv +#include // For CCoeEnv #include #include "videoplayer.h" @@ -36,70 +36,68 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::VideoPlayer::VideoPlayer() - : m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) - , m_totalTime(0) + : m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) + , m_totalTime(0) { - construct(); + construct(); } MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) - , m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) - , m_totalTime(0) + : AbstractMediaPlayer(player) + , m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) + , m_totalTime(0) { - construct(); + construct(); } void MMF::VideoPlayer::construct() { - TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); - TRACE_ENTRY_0(); - - if(!m_videoOutput) - { - m_dummyVideoOutput.reset(new VideoOutput(NULL)); - } - - videoOutput().setObserver(this); - - const TInt priority = 0; - const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; - - getNativeWindowSystemHandles(); - - // TODO: is this the correct way to handle errors which occur when - // creating a Symbian object in the constructor of a Qt object? - TRAPD(err, - m_player = CVideoPlayerUtility::NewL - ( - *this, - priority, preference, - *m_wsSession, *m_screenDevice, - *m_window, - m_windowRect, m_clipRect - ) - ); - - if(KErrNone != err) - { - changeState(ErrorState); - } - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); + TRACE_ENTRY_0(); + + if (!m_videoOutput) { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } + + videoOutput().setObserver(this); + + const TInt priority = 0; + const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; + + getNativeWindowSystemHandles(); + + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? + TRAPD(err, + m_player = CVideoPlayerUtility::NewL + ( + *this, + priority, preference, + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect + ) + ); + + if (KErrNone != err) { + changeState(ErrorState); + } + + TRACE_EXIT_0(); } MMF::VideoPlayer::~VideoPlayer() { - TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); + TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); TRACE_ENTRY_0(); - - delete m_player; - - TRACE_EXIT_0(); + + delete m_player; + + TRACE_EXIT_0(); } //----------------------------------------------------------------------------- @@ -107,35 +105,33 @@ MMF::VideoPlayer::~VideoPlayer() //----------------------------------------------------------------------------- void MMF::VideoPlayer::doPlay() -{ - m_player->Play(); +{ + m_player->Play(); } void MMF::VideoPlayer::doPause() { - TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); - - TRAPD(err, m_player->PauseL()); - if(KErrNone != err) - { - TRACE("PauseL error %d", err); - setError(NormalError); - } + TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); + + TRAPD(err, m_player->PauseL()); + if (KErrNone != err) { + TRACE("PauseL error %d", err); + setError(NormalError); + } } void MMF::VideoPlayer::doStop() { - m_player->Stop(); + m_player->Stop(); } void MMF::VideoPlayer::doSeek(qint64 ms) { TRACE_CONTEXT(VideoPlayer::doSeek, EVideoApi); - + TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms * 1000))); - if(KErrNone != err) - { + if (KErrNone != err) { TRACE("SetPositionL error %d", err); setError(NormalError); } @@ -143,48 +139,45 @@ void MMF::VideoPlayer::doSeek(qint64 ms) int MMF::VideoPlayer::setDeviceVolume(int mmfVolume) { - TRAPD(err, m_player->SetVolumeL(mmfVolume)); - return err; + TRAPD(err, m_player->SetVolumeL(mmfVolume)); + return err; } int MMF::VideoPlayer::openFile(RFile& file) { - TRAPD(err, m_player->OpenFileL(file)); - return err; + TRAPD(err, m_player->OpenFileL(file)); + return err; } void MMF::VideoPlayer::close() { - m_player->Close(); + m_player->Close(); } bool MMF::VideoPlayer::hasVideo() const { - return true; + return true; } qint64 MMF::VideoPlayer::currentTime() const { - TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); + TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); - TTimeIntervalMicroSeconds us; + TTimeIntervalMicroSeconds us; TRAPD(err, us = m_player->PositionL()) qint64 result = 0; - if(KErrNone == err) - { + if (KErrNone == err) { result = toMilliSeconds(us); + } else { + TRACE("PositionL error %d", err); + + // If we don't cast away constness here, we simply have to ignore + // the error. + const_cast(this)->setError(NormalError); } - else - { - TRACE("PositionL error %d", err); - - // If we don't cast away constness here, we simply have to ignore - // the error. - const_cast(this)->setError(NormalError); - } - + return result; } @@ -200,60 +193,54 @@ qint64 MMF::VideoPlayer::totalTime() const void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); + TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); TRACE_ENTRY("state %d error %d", state(), aError); __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - if(KErrNone == aError) - { - m_player->Prepare(); - } - else - { - // TODO: set different error states according to value of aError? - setError(NormalError); - } - + if (KErrNone == aError) { + m_player->Prepare(); + } else { + // TODO: set different error states according to value of aError? + setError(NormalError); + } + TRACE_EXIT_0(); } void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); - TRACE_ENTRY("state %d error %d", state(), aError); + TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - + TRAPD(err, doPrepareCompleteL(aError)); - - if(KErrNone == err) - { - maxVolumeChanged(m_player->MaxVolume()); - - videoOutput().setFrameSize(m_frameSize); + + if (KErrNone == err) { + maxVolumeChanged(m_player->MaxVolume()); + + videoOutput().setFrameSize(m_frameSize); emit totalTimeChanged(totalTime()); changeState(StoppedState); - } - else - { - // TODO: set different error states according to value of aError? - setError(NormalError); - } - - TRACE_EXIT_0(); + } else { + // TODO: set different error states according to value of aError? + setError(NormalError); + } + + TRACE_EXIT_0(); } void MMF::VideoPlayer::doPrepareCompleteL(TInt aError) { User::LeaveIfError(aError); - + // Get frame size TSize size; m_player->VideoFrameSizeL(size); m_frameSize = QSize(size.iWidth, size.iHeight); - + // Get duration m_totalTime = toMilliSeconds(m_player->DurationL()); } @@ -261,36 +248,36 @@ void MMF::VideoPlayer::doPrepareCompleteL(TInt aError) void MMF::VideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); - TRACE_ENTRY("state %d error %d", state(), aError); - - // TODO - Q_UNUSED(aFrame); - Q_UNUSED(aError); // suppress warnings in release builds - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); + TRACE_ENTRY("state %d error %d", state(), aError); + + // TODO + Q_UNUSED(aFrame); + Q_UNUSED(aError); // suppress warnings in release builds + + TRACE_EXIT_0(); } void MMF::VideoPlayer::MvpuoPlayComplete(TInt aError) { - TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) - TRACE_ENTRY("state %d error %d", state(), aError); + TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) + TRACE_ENTRY("state %d error %d", state(), aError); - // TODO - Q_UNUSED(aError); // suppress warnings in release builds - - TRACE_EXIT_0(); + // TODO + Q_UNUSED(aError); // suppress warnings in release builds + + TRACE_EXIT_0(); } void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) { - TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); - TRACE_ENTRY("state %d", state()); + TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); + TRACE_ENTRY("state %d", state()); - // TODO - Q_UNUSED(aEvent); - - TRACE_EXIT_0(); + // TODO + Q_UNUSED(aEvent); + + TRACE_EXIT_0(); } @@ -302,28 +289,27 @@ void MMF::VideoPlayer::videoOutputRegionChanged() { TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); TRACE_ENTRY_0(); - + #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT videoOutput().dump(); #endif - + getNativeWindowSystemHandles(); - + TRAPD(err, - m_player->SetDisplayWindowL - ( - *m_wsSession, *m_screenDevice, - *m_window, - m_windowRect, m_clipRect - ) - ); - - if(KErrNone != err) - { + m_player->SetDisplayWindowL + ( + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect + ) + ); + + if (KErrNone != err) { TRACE("SetDisplayWindowL error %d", err); setError(NormalError); } - + TRACE_EXIT_0(); } @@ -334,81 +320,80 @@ void MMF::VideoPlayer::videoOutputRegionChanged() VideoOutput& MMF::VideoPlayer::videoOutput() { - TRACE_CONTEXT(VideoPlayer::videoOutput, EVideoInternal); - TRACE("videoOutput 0x%08x dummy 0x%08x", m_videoOutput, m_dummyVideoOutput.data()); + TRACE_CONTEXT(VideoPlayer::videoOutput, EVideoInternal); + TRACE("videoOutput 0x%08x dummy 0x%08x", m_videoOutput, m_dummyVideoOutput.data()); - return m_videoOutput ? *m_videoOutput : *m_dummyVideoOutput; + return m_videoOutput ? *m_videoOutput : *m_dummyVideoOutput; } void MMF::VideoPlayer::videoOutputChanged() { - TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); - TRACE_ENTRY_0(); - - // Lazily construct a dummy output if needed here - if(!m_videoOutput and m_dummyVideoOutput.isNull()) - { - m_dummyVideoOutput.reset(new VideoOutput(NULL)); - } - - videoOutput().setObserver(this); - - videoOutput().setFrameSize(m_frameSize); - - videoOutputRegionChanged(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); + TRACE_ENTRY_0(); + + // Lazily construct a dummy output if needed here + if (!m_videoOutput and m_dummyVideoOutput.isNull()) { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } + + videoOutput().setObserver(this); + + videoOutput().setFrameSize(m_frameSize); + + videoOutputRegionChanged(); + + TRACE_EXIT_0(); } void MMF::VideoPlayer::getNativeWindowSystemHandles() { - TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); - - VideoOutput& output = videoOutput(); - CCoeControl* const control = output.winId(); - - TRACE("control 0x%08x", control); - TRACE("control IsVisible %d", control->IsVisible()); - TRACE("control IsDimmed %d", control->IsDimmed()); - TRACE("control HasBorder %d", control->HasBorder()); - TRACE("control Position %d %d", - control->Position().iX, control->Position().iY); - TRACE("control Rect %d %d - %d %d", - control->Rect().iTl.iX, control->Rect().iTl.iY, - control->Rect().iBr.iX, control->Rect().iBr.iY); - TRACE("control OwnsWindow %d", control->OwnsWindow()); - - CCoeEnv* const coeEnv = control->ControlEnv(); - - m_wsSession = &(coeEnv->WsSession()); - - TRACE("session Handle 0x%08x", m_wsSession->Handle()); - - m_screenDevice = coeEnv->ScreenDevice(); - - TRACE("device WsHandle 0x%08x", m_screenDevice->WsHandle()); - - m_window = control->DrawableWindow(); - - TRACE("window ClientHandle 0x%08x", m_window->ClientHandle()); - TRACE("window WsHandle 0x%08x", m_window->WsHandle()); - TRACE("window WindowGroupId %d", m_window->WindowGroupId()); - TRACE("window Position %d %d", - m_window->Position().iX, m_window->Position().iY); - TRACE("window AbsPosition %d %d", - m_window->AbsPosition().iX, m_window->AbsPosition().iY); - TRACE("window Size %d %d", - m_window->Size().iWidth, m_window->Size().iHeight); - + TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); + + VideoOutput& output = videoOutput(); + CCoeControl* const control = output.winId(); + + TRACE("control 0x%08x", control); + TRACE("control IsVisible %d", control->IsVisible()); + TRACE("control IsDimmed %d", control->IsDimmed()); + TRACE("control HasBorder %d", control->HasBorder()); + TRACE("control Position %d %d", + control->Position().iX, control->Position().iY); + TRACE("control Rect %d %d - %d %d", + control->Rect().iTl.iX, control->Rect().iTl.iY, + control->Rect().iBr.iX, control->Rect().iBr.iY); + TRACE("control OwnsWindow %d", control->OwnsWindow()); + + CCoeEnv* const coeEnv = control->ControlEnv(); + + m_wsSession = &(coeEnv->WsSession()); + + TRACE("session Handle 0x%08x", m_wsSession->Handle()); + + m_screenDevice = coeEnv->ScreenDevice(); + + TRACE("device WsHandle 0x%08x", m_screenDevice->WsHandle()); + + m_window = control->DrawableWindow(); + + TRACE("window ClientHandle 0x%08x", m_window->ClientHandle()); + TRACE("window WsHandle 0x%08x", m_window->WsHandle()); + TRACE("window WindowGroupId %d", m_window->WindowGroupId()); + TRACE("window Position %d %d", + m_window->Position().iX, m_window->Position().iY); + TRACE("window AbsPosition %d %d", + m_window->AbsPosition().iX, m_window->AbsPosition().iY); + TRACE("window Size %d %d", + m_window->Size().iWidth, m_window->Size().iHeight); + #ifdef PHONON_MMF_HARD_CODE_VIDEO_RECT - // HACK: why isn't control->Rect updated following a call to - // updateGeometry on the parent widget? - m_windowRect = TRect(0,100,320,250); + // HACK: why isn't control->Rect updated following a call to + // updateGeometry on the parent widget? + m_windowRect = TRect(0, 100, 320, 250); #else - m_windowRect = control->Rect(); + m_windowRect = control->Rect(); #endif - - m_clipRect = m_windowRect; + + m_clipRect = m_windowRect; } diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index f8b1486..da373ab 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -29,81 +29,81 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * @short Wrapper over MMF video client utility - * - * See - * How to - * play a video file using CVideoPlayerUtility - */ - class VideoPlayer : public AbstractMediaPlayer - , public MVideoPlayerUtilityObserver - , public VideoOutputObserver - { - Q_OBJECT - - public: - VideoPlayer(); - explicit VideoPlayer(const AbstractPlayer& player); - virtual ~VideoPlayer(); - - // AbstractPlayer - virtual void doPlay(); - virtual void doPause(); - virtual void doStop(); - virtual void doSeek(qint64 milliseconds); - virtual int setDeviceVolume(int mmfVolume); - virtual int openFile(RFile& file); - virtual void close(); - - // MediaObjectInterface - virtual bool hasVideo() const; - virtual qint64 currentTime() const; - virtual qint64 totalTime() const; - - // MVideoPlayerUtilityObserver - virtual void MvpuoOpenComplete(TInt aError); - virtual void MvpuoPrepareComplete(TInt aError); - virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); - virtual void MvpuoPlayComplete(TInt aError); - virtual void MvpuoEvent(const TMMFEvent &aEvent); - - // VideoOutputObserver - virtual void videoOutputRegionChanged(); - - Q_SIGNALS: - void totalTimeChanged(qint64 length); - void finished(); - - private: - void construct(); - VideoOutput& videoOutput(); - - void doPrepareCompleteL(TInt aError); - - // AbstractPlayer - virtual void videoOutputChanged(); - - void getNativeWindowSystemHandles(); - - private: - CVideoPlayerUtility* m_player; - QScopedPointer m_dummyVideoOutput; - - // Not owned - RWsSession* m_wsSession; - CWsScreenDevice* m_screenDevice; - RWindowBase* m_window; - TRect m_windowRect; - TRect m_clipRect; - - QSize m_frameSize; - qint64 m_totalTime; - - }; - } +namespace MMF +{ +/** + * @short Wrapper over MMF video client utility + * + * See + * How to + * play a video file using CVideoPlayerUtility + */ +class VideoPlayer : public AbstractMediaPlayer + , public MVideoPlayerUtilityObserver + , public VideoOutputObserver +{ + Q_OBJECT + +public: + VideoPlayer(); + explicit VideoPlayer(const AbstractPlayer& player); + virtual ~VideoPlayer(); + + // AbstractPlayer + virtual void doPlay(); + virtual void doPause(); + virtual void doStop(); + virtual void doSeek(qint64 milliseconds); + virtual int setDeviceVolume(int mmfVolume); + virtual int openFile(RFile& file); + virtual void close(); + + // MediaObjectInterface + virtual bool hasVideo() const; + virtual qint64 currentTime() const; + virtual qint64 totalTime() const; + + // MVideoPlayerUtilityObserver + virtual void MvpuoOpenComplete(TInt aError); + virtual void MvpuoPrepareComplete(TInt aError); + virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); + virtual void MvpuoPlayComplete(TInt aError); + virtual void MvpuoEvent(const TMMFEvent &aEvent); + + // VideoOutputObserver + virtual void videoOutputRegionChanged(); + +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void finished(); + +private: + void construct(); + VideoOutput& videoOutput(); + + void doPrepareCompleteL(TInt aError); + + // AbstractPlayer + virtual void videoOutputChanged(); + + void getNativeWindowSystemHandles(); + +private: + CVideoPlayerUtility* m_player; + QScopedPointer m_dummyVideoOutput; + + // Not owned + RWsSession* m_wsSession; + CWsScreenDevice* m_screenDevice; + RWindowBase* m_window; + TRect m_windowRect; + TRect m_clipRect; + + QSize m_frameSize; + qint64 m_totalTime; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index ae94e5e..be3c752 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -29,11 +29,11 @@ using namespace Phonon::MMF; // Constants //----------------------------------------------------------------------------- -static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio = - Phonon::VideoWidget::AspectRatioAuto; +static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio = + Phonon::VideoWidget::AspectRatioAuto; static const qreal DefaultBrightness = 1.0; -static const Phonon::VideoWidget::ScaleMode DefaultScaleMode = - Phonon::VideoWidget::FitInView; +static const Phonon::VideoWidget::ScaleMode DefaultScaleMode = + Phonon::VideoWidget::FitInView; static const qreal DefaultContrast = 1.0; static const qreal DefaultHue = 1.0; static const qreal DefaultSaturation = 1.0; @@ -44,27 +44,27 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : QObject(parent) - , m_widget(new VideoOutput(parent)) - , m_aspectRatio(DefaultAspectRatio) - , m_brightness(DefaultBrightness) - , m_scaleMode(DefaultScaleMode) - , m_contrast(DefaultContrast) - , m_hue(DefaultHue) - , m_saturation(DefaultSaturation) + : QObject(parent) + , m_widget(new VideoOutput(parent)) + , m_aspectRatio(DefaultAspectRatio) + , m_brightness(DefaultBrightness) + , m_scaleMode(DefaultScaleMode) + , m_contrast(DefaultContrast) + , m_hue(DefaultHue) + , m_saturation(DefaultSaturation) { - TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); - TRACE_ENTRY_0(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } MMF::VideoWidget::~VideoWidget() { - TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi); - TRACE_ENTRY_0(); - - TRACE_EXIT_0(); + TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } @@ -74,91 +74,91 @@ MMF::VideoWidget::~VideoWidget() Phonon::VideoWidget::AspectRatio MMF::VideoWidget::aspectRatio() const { - return m_aspectRatio; + return m_aspectRatio; } void MMF::VideoWidget::setAspectRatio - (Phonon::VideoWidget::AspectRatio aspectRatio) +(Phonon::VideoWidget::AspectRatio aspectRatio) { - TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi); - TRACE("aspectRatio %d", aspectRatio); + TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi); + TRACE("aspectRatio %d", aspectRatio); - m_aspectRatio = aspectRatio; + m_aspectRatio = aspectRatio; } qreal MMF::VideoWidget::brightness() const { - return m_brightness; + return m_brightness; } void MMF::VideoWidget::setBrightness(qreal brightness) { - TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi); - TRACE("brightness %f", brightness); + TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi); + TRACE("brightness %f", brightness); - m_brightness = brightness; + m_brightness = brightness; } Phonon::VideoWidget::ScaleMode MMF::VideoWidget::scaleMode() const { - return m_scaleMode; + return m_scaleMode; } void MMF::VideoWidget::setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode) { - TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi); - TRACE("setScaleMode %d", setScaleMode); + TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi); + TRACE("setScaleMode %d", setScaleMode); - m_scaleMode = scaleMode; + m_scaleMode = scaleMode; } qreal MMF::VideoWidget::contrast() const { - return m_contrast; + return m_contrast; } void MMF::VideoWidget::setContrast(qreal contrast) { - TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi); - TRACE("contrast %f", contrast); + TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi); + TRACE("contrast %f", contrast); - m_contrast = contrast; + m_contrast = contrast; } qreal MMF::VideoWidget::hue() const { - return m_hue; + return m_hue; } void MMF::VideoWidget::setHue(qreal hue) { - TRACE_CONTEXT(VideoWidget::setHue, EVideoApi); - TRACE("hue %f", hue); + TRACE_CONTEXT(VideoWidget::setHue, EVideoApi); + TRACE("hue %f", hue); - m_hue = hue; + m_hue = hue; } qreal MMF::VideoWidget::saturation() const { - return m_saturation; + return m_saturation; } void MMF::VideoWidget::setSaturation(qreal saturation) { - TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi); - TRACE("saturation %f", saturation); + TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi); + TRACE("saturation %f", saturation); - m_saturation = saturation; + m_saturation = saturation; } QWidget* MMF::VideoWidget::widget() { - return m_widget.data(); + return m_widget.data(); } VideoOutput& MMF::VideoWidget::videoOutput() { - return *static_cast(widget()); + return *static_cast(widget()); } diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 799121b..e2e1f33 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -27,49 +27,49 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - class VideoOutput; - - class VideoWidget : public QObject - , public Phonon::VideoWidgetInterface - { - Q_OBJECT - Q_INTERFACES(Phonon::VideoWidgetInterface) - - public: - VideoWidget(QWidget* parent); - ~VideoWidget(); - - // VideoWidgetInterface - virtual Phonon::VideoWidget::AspectRatio aspectRatio() const; - virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio aspectRatio); - virtual qreal brightness() const; - virtual void setBrightness(qreal brightness); - virtual Phonon::VideoWidget::ScaleMode scaleMode() const; - virtual void setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode); - virtual qreal contrast() const; - virtual void setContrast(qreal constrast); - virtual qreal hue() const; - virtual void setHue(qreal hue); - virtual qreal saturation() const; - virtual void setSaturation(qreal saturation); - virtual QWidget *widget(); - - VideoOutput& videoOutput(); - - private: - QScopedPointer m_widget; - - Phonon::VideoWidget::AspectRatio m_aspectRatio; - qreal m_brightness; - Phonon::VideoWidget::ScaleMode m_scaleMode; - qreal m_contrast; - qreal m_hue; - qreal m_saturation; - - }; - } +namespace MMF +{ +class VideoOutput; + +class VideoWidget : public QObject + , public Phonon::VideoWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::VideoWidgetInterface) + +public: + VideoWidget(QWidget* parent); + ~VideoWidget(); + + // VideoWidgetInterface + virtual Phonon::VideoWidget::AspectRatio aspectRatio() const; + virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio aspectRatio); + virtual qreal brightness() const; + virtual void setBrightness(qreal brightness); + virtual Phonon::VideoWidget::ScaleMode scaleMode() const; + virtual void setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode); + virtual qreal contrast() const; + virtual void setContrast(qreal constrast); + virtual qreal hue() const; + virtual void setHue(qreal hue); + virtual qreal saturation() const; + virtual void setSaturation(qreal saturation); + virtual QWidget *widget(); + + VideoOutput& videoOutput(); + +private: + QScopedPointer m_widget; + + Phonon::VideoWidget::AspectRatio m_aspectRatio; + qreal m_brightness; + Phonon::VideoWidget::ScaleMode m_scaleMode; + qreal m_contrast; + qreal m_hue; + qreal m_saturation; + +}; +} } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/volumeobserver.h b/src/3rdparty/phonon/mmf/volumeobserver.h index d6717cba..bedd3de 100644 --- a/src/3rdparty/phonon/mmf/volumeobserver.h +++ b/src/3rdparty/phonon/mmf/volumeobserver.h @@ -25,18 +25,18 @@ QT_BEGIN_NAMESPACE namespace Phonon { - namespace MMF - { - /** - * Interface used by AudioOutput to pass volume control commands - * back along the audio path to the MediaObject. - */ - class VolumeObserver - { - public: - virtual void volumeChanged(qreal volume) = 0; - }; - } +namespace MMF +{ +/** + * Interface used by AudioOutput to pass volume control commands + * back along the audio path to the MediaObject. + */ +class VolumeObserver +{ +public: + virtual void volumeChanged(qreal volume) = 0; +}; +} } QT_END_NAMESPACE -- cgit v0.12 From 9dea8a0b902fbfb778d8ba231a5cdc283c314e17 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 14:27:15 +0100 Subject: Oops: fixed 'Made non-toplevel widgets window-owning' --- src/gui/kernel/qapplication_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 3a7fc4b..854fa07 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -320,7 +320,7 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) // We cannot assume that parentless widgets are top-level QWidget *const parent = qobject_cast(qwidget->parent()); - if (topLevel or parent) + if (topLevel or !parent) CreateWindowL(S60->windowGroup()); else CreateWindowL(parent->winId()); -- cgit v0.12 From e649b8ea97ca730559d19c7b11b210c2c89f64fa Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 15:16:10 +0100 Subject: Removed call to CCoeControl::SetContainerWindowL for child widgets --- src/gui/kernel/qwidget_s60.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index f8a5be5..7c7212f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -358,9 +358,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); - WId parentw = parentWidget->effectiveWinId(); - QT_TRAP_THROWING(control->SetContainerWindowL(*parentw)); - q->setAttribute(Qt::WA_WState_Created); int x, y, w, h; data.crect.getRect(&x, &y, &w, &h); -- cgit v0.12 From fdb821a7ea5273f5f0c9088e9c01f018db380c69 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 15:20:20 +0100 Subject: Removed qobject_cast as per suggestion from Jason Barron --- src/gui/kernel/qapplication_s60.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 854fa07..c0f574f 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -316,14 +316,11 @@ QSymbianControl::QSymbianControl(QWidget *w) void QSymbianControl::ConstructL(bool topLevel, bool desktop) { if (!desktop) - { - // We cannot assume that parentless widgets are top-level - QWidget *const parent = qobject_cast(qwidget->parent()); - - if (topLevel or !parent) + { + if (topLevel or !parentWidget()) CreateWindowL(S60->windowGroup()); else - CreateWindowL(parent->winId()); + CreateWindowL(parentWidget()->winId()); SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); -- cgit v0.12 From 1f26eb79dfdc6850a6bde3a5fa0127b8e938bdba Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 27 Aug 2009 17:28:51 +0100 Subject: First draft of QWidgetPrivate::setWSGeometry for S60 --- src/gui/kernel/qapplication_s60.cpp | 4 +- src/gui/kernel/qwidget_s60.cpp | 151 +++++++++++++++++++++++++++++++++++- 2 files changed, 151 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index c0f574f..9d44481 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -317,10 +317,10 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) { if (!desktop) { - if (topLevel or !parentWidget()) + if (topLevel or !qwidget->parentWidget()) CreateWindowL(S60->windowGroup()); else - CreateWindowL(parentWidget()->winId()); + CreateWindowL(qwidget->parentWidget()->winId()); SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 7c7212f..ba45bdd 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -150,9 +150,156 @@ void QWidgetPrivate::setSoftKeys_sys(const QList &softkeys) #endif } -void QWidgetPrivate::setWSGeometry(bool /* dontShow */, const QRect & /* rect */) -{ +void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) +{ + // Note: based on x11 implementation + + static const int XCOORD_MAX = 16383; + static const int WRECT_MAX = 16383; + + Q_Q(QWidget); + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); + + /* + There are up to four different coordinate systems here: + Qt coordinate system for this widget. + X coordinate system for this widget (relative to wrect). + Qt coordinate system for parent + X coordinate system for parent (relative to parent's wrect). + */ + + QRect validRange(-XCOORD_MAX,-XCOORD_MAX, 2*XCOORD_MAX, 2*XCOORD_MAX); + QRect wrectRange(-WRECT_MAX,-WRECT_MAX, 2*WRECT_MAX, 2*WRECT_MAX); + QRect wrect; + //xrect is the X geometry of my widget. (starts out in parent's Qt coord sys, and ends up in parent's X coord sys) + QRect xrect = data.crect; + + const QWidget *const parent = q->parentWidget(); + QRect parentWRect = parent->data->wrect; + + if (parentWRect.isValid()) { + // parent is clipped, and we have to clip to the same limit as parent + if (!parentWRect.contains(xrect)) { + xrect &= parentWRect; + wrect = xrect; + //translate from parent's to my Qt coord sys + wrect.translate(-data.crect.topLeft()); + } + //translate from parent's Qt coords to parent's X coords + xrect.translate(-parentWRect.topLeft()); + + } else { + // parent is not clipped, we may or may not have to clip + + if (data.wrect.isValid() && QRect(QPoint(),data.crect.size()).contains(data.wrect)) { + // This is where the main optimization is: we are already + // clipped, and if our clip is still valid, we can just + // move our window, and do not need to move or clip + // children + + QRect vrect = xrect & parent->rect(); + vrect.translate(-data.crect.topLeft()); //the part of me that's visible through parent, in my Qt coords + if (data.wrect.contains(vrect)) { + xrect = data.wrect; + xrect.translate(data.crect.topLeft()); + if (data.winid) + data.winid->SetPosition(TPoint(xrect.x(), xrect.y())); + return; + } + } + + if (!validRange.contains(xrect)) { + // we are too big, and must clip + xrect &=wrectRange; + wrect = xrect; + wrect.translate(-data.crect.topLeft()); + //parent's X coord system is equal to parent's Qt coord + //sys, so we don't need to map xrect. + } + + } + + // unmap if we are outside the valid window system coord system + bool outsideRange = !xrect.isValid(); + bool mapWindow = false; + if (q->testAttribute(Qt::WA_OutsideWSRange) != outsideRange) { + q->setAttribute(Qt::WA_OutsideWSRange, outsideRange); + if (outsideRange) { + if (data.winid) + data.winid->DrawableWindow()->SetVisible(EFalse); + q->setAttribute(Qt::WA_Mapped, false); + } else if (!q->isHidden()) { + mapWindow = true; + } + } + + if (outsideRange) + return; + + bool jump = (data.wrect != wrect); + data.wrect = wrect; + + // and now recursively for all children... + // ### can be optimized + for (int i = 0; i < children.size(); ++i) { + QObject *object = children.at(i); + if (object->isWidgetType()) { + QWidget *w = static_cast(object); + if (!w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) + w->d_func()->setWSGeometry(jump); + } + } + + if (data.winid) { + // move ourselves to the new position and map (if necessary) after + // the movement. Rationale: moving unmapped windows is much faster + // than moving mapped windows + if (!parent->internalWinId()) + xrect.translate(parent->mapTo(q->nativeParentWidget(), QPoint(0, 0))); + data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); + } + if (mapWindow and !dontShow) { + q->setAttribute(Qt::WA_Mapped); + if (q->internalWinId()) + q->internalWinId()->DrawableWindow()->SetVisible(ETrue); + } + +/* + * Not present in Windows port, so we omit it here aswell ... + * + //to avoid flicker, we have to show children after the helper widget has moved + if (jump) { + for (int i = 0; i < children.size(); ++i) { + QObject *object = children.at(i); + if (object->isWidgetType()) { + QWidget *w = static_cast(object); + if (!w->testAttribute(Qt::WA_OutsideWSRange) && !w->testAttribute(Qt::WA_Mapped) && !w->isHidden()) { + w->setAttribute(Qt::WA_Mapped); + if (w->internalWinId()) + XMapWindow(dpy, w->data->winid); + } + } + } + } +*/ + +/* + * TODO: how to invalidate part of the control? + * + if (jump && data.winid) + data.winid->Draw(TRect(0, 0, wrect.width(), wrect.height())); +*/ + +/* + * Not present in Windows port, so we omit it here aswell ... + * + if (mapWindow && !dontShow) { + q->setAttribute(Qt::WA_Mapped); + if (data.winid) + XMapWindow(dpy, data.winid); + } +*/ } void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) -- cgit v0.12 From ffe1fb8198b707c1a081f6cf3748e867053d74e3 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 28 Aug 2009 07:33:08 +0100 Subject: Experimenting to try and get video to be visible --- src/3rdparty/phonon/mmf/videooutput.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 53178cb..f9f145a 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -41,10 +41,12 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) TRACE_ENTRY("parent 0x%08x", parent); #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - setPalette(QPalette(Qt::black)); + //QPalette palette(Qt::black); + //palette.setColor(QPalette::Window, Qt::transparent); + //setPalette(palette); //setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); - setAutoFillBackground(false); + //setAttribute(Qt::WA_NoSystemBackground, true); + //setAutoFillBackground(false); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT @@ -156,6 +158,7 @@ QSize MMF::VideoOutput::sizeHint() const return result; } +#include // TEMPORARY void MMF::VideoOutput::paintEvent(QPaintEvent* event) { TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); @@ -165,7 +168,13 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) TRACE("regions %d", event->region().numRects()); TRACE("type %d", event->type()); - QWidget::paintEvent(event); +/* + QPainter painter; + painter.begin(this); + painter.setBrush(QColor(0, 0, 0, 0)); + painter.drawRects(event->region().rects()); + painter.end(); +*/ } QPaintEngine* MMF::VideoOutput::paintEngine() const -- cgit v0.12 From 8987b495c5026976e23d910e68c7892c4c81e586 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 28 Aug 2009 13:24:07 +0100 Subject: Added code to VideoOutput for painting the video region (currently commented out) --- src/3rdparty/phonon/mmf/videooutput.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index f9f145a..6810f10 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -21,6 +21,7 @@ along with this library. If not, see . #include "videooutputobserver.h" #include +#include #include #include @@ -153,12 +154,11 @@ QSize MMF::VideoOutput::sizeHint() const if (!m_frameSize.isNull()) { result = m_frameSize; } - + TRACE(" result %d %d", result.width(), result.height()); return result; } -#include // TEMPORARY void MMF::VideoOutput::paintEvent(QPaintEvent* event) { TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal); @@ -171,7 +171,8 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) /* QPainter painter; painter.begin(this); - painter.setBrush(QColor(0, 0, 0, 0)); + painter.setBrush(QColor(255, 0, 0, 255)); // opaque red + //painter.setBrush(QColor(0, 0, 0, 0)); // transparent black painter.drawRects(event->region().rects()); painter.end(); */ @@ -194,7 +195,7 @@ void MMF::VideoOutput::resizeEvent(QResizeEvent* event) event->size().width(), event->size().height()); QWidget::resizeEvent(event); - + if (m_observer) { m_observer->videoOutputRegionChanged(); } -- cgit v0.12 From b806fe453139ca67d192fda7fa6de8d23889c7c6 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 28 Aug 2009 13:25:38 +0100 Subject: Further modifications to native window resizing code --- src/gui/kernel/qapplication_s60.cpp | 8 ++++++++ src/gui/kernel/qwidget_s60.cpp | 39 +++++++++++++------------------------ 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 9d44481..b369168 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -320,6 +320,14 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) if (topLevel or !qwidget->parentWidget()) CreateWindowL(S60->windowGroup()); else + /** + * TODO: in order to avoid creating windows for all ancestors of + * this widget up to the root window, the parameter passed to + * CreateWindowL should be + * qwidget->parentWidget()->effectiveWinId(). However, if we do + * this, then we need to take care of re-parenting when a window + * is created for a widget between this one and the root window. + */ CreateWindowL(qwidget->parentWidget()->winId()); SetFocusing(true); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index ba45bdd..3cc810e 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -202,8 +202,10 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) if (data.wrect.contains(vrect)) { xrect = data.wrect; xrect.translate(data.crect.topLeft()); - if (data.winid) - data.winid->SetPosition(TPoint(xrect.x(), xrect.y())); + if (data.winid) { + data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); + data.winid->DrawNow(); + } return; } } @@ -258,16 +260,10 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) if (!parent->internalWinId()) xrect.translate(parent->mapTo(q->nativeParentWidget(), QPoint(0, 0))); data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); + if(!jump) + data.winid->DrawNow(); } - if (mapWindow and !dontShow) { - q->setAttribute(Qt::WA_Mapped); - if (q->internalWinId()) - q->internalWinId()->DrawableWindow()->SetVisible(ETrue); - } - -/* - * Not present in Windows port, so we omit it here aswell ... - * + //to avoid flicker, we have to show children after the helper widget has moved if (jump) { for (int i = 0; i < children.size(); ++i) { @@ -277,29 +273,20 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) if (!w->testAttribute(Qt::WA_OutsideWSRange) && !w->testAttribute(Qt::WA_Mapped) && !w->isHidden()) { w->setAttribute(Qt::WA_Mapped); if (w->internalWinId()) - XMapWindow(dpy, w->data->winid); + w->data->winid->DrawableWindow()->SetVisible(ETrue); } } } } -*/ -/* - * TODO: how to invalidate part of the control? - * if (jump && data.winid) - data.winid->Draw(TRect(0, 0, wrect.width(), wrect.height())); -*/ - -/* - * Not present in Windows port, so we omit it here aswell ... - * - if (mapWindow && !dontShow) { + data.winid->DrawNow(TRect(0, 0, wrect.width(), wrect.height())); + + if (mapWindow and !dontShow) { q->setAttribute(Qt::WA_Mapped); - if (data.winid) - XMapWindow(dpy, data.winid); + if (q->internalWinId()) + q->internalWinId()->DrawableWindow()->SetVisible(ETrue); } -*/ } void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) -- cgit v0.12 From 316ae5a88b71993de3e1e2e16f8b82c4e9c7a1cf Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 28 Aug 2009 15:04:54 +0100 Subject: Deferred call to CVideoPlayerUtility::SetDisplayWindowL until MMF controller has been loaded --- src/3rdparty/phonon/mmf/videoplayer.cpp | 35 +++++++++++++++++++++++++++++++-- src/3rdparty/phonon/mmf/videoplayer.h | 9 ++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index f008edd..7f08405 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -40,6 +40,7 @@ MMF::VideoPlayer::VideoPlayer() , m_screenDevice(NULL) , m_window(NULL) , m_totalTime(0) + , m_mmfOutputChangePending(false) { construct(); } @@ -50,6 +51,7 @@ MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) , m_screenDevice(NULL) , m_window(NULL) , m_totalTime(0) + , m_mmfOutputChangePending(false) { construct(); } @@ -222,6 +224,12 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) videoOutput().setFrameSize(m_frameSize); + // See comment in updateMmfOutput + if(m_mmfOutputChangePending) { + TRACE_0("MMF output change pending - pushing now"); + updateMmfOutput(); + } + emit totalTimeChanged(totalTime()); changeState(StoppedState); } else { @@ -288,7 +296,7 @@ void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) void MMF::VideoPlayer::videoOutputRegionChanged() { TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); - TRACE_ENTRY_0(); + TRACE_ENTRY("state %d", state()); #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT videoOutput().dump(); @@ -296,6 +304,27 @@ void MMF::VideoPlayer::videoOutputRegionChanged() getNativeWindowSystemHandles(); + // See comment in updateMmfOutput + if(state() == LoadingState) + m_mmfOutputChangePending = true; + else + updateMmfOutput(); + + TRACE_EXIT_0(); +} + +void MMF::VideoPlayer::updateMmfOutput() +{ + TRACE_CONTEXT(VideoPlayer::updateMmfOutput, EVideoInternal); + TRACE_ENTRY_0(); + + // Calling SetDisplayWindowL is a no-op unless the MMF controller has + // been loaded, so we shouldn't do it. Instead, the + // m_mmfOutputChangePending flag is used to record the fact that we + // need to call SetDisplayWindowL, and this is checked in + // MvpuoPrepareComplete, at which point the MMF controller has been + // loaded. + TRAPD(err, m_player->SetDisplayWindowL ( @@ -309,7 +338,9 @@ void MMF::VideoPlayer::videoOutputRegionChanged() TRACE("SetDisplayWindowL error %d", err); setError(NormalError); } - + + m_mmfOutputChangePending = false; + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index da373ab..1fad4c4 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -85,9 +85,10 @@ private: // AbstractPlayer virtual void videoOutputChanged(); - + void getNativeWindowSystemHandles(); - + void updateMmfOutput(); + private: CVideoPlayerUtility* m_player; QScopedPointer m_dummyVideoOutput; @@ -98,10 +99,12 @@ private: RWindowBase* m_window; TRect m_windowRect; TRect m_clipRect; - + QSize m_frameSize; qint64 m_totalTime; + bool m_mmfOutputChangePending; + }; } } -- cgit v0.12 From 8b9d50a2d83fb05e1b32814c341936daf6628452 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 28 Aug 2009 18:29:23 +0100 Subject: Modified show_sys to call ActivateL on all window-owning controls --- src/gui/kernel/qapplication_s60.cpp | 4 ++++ src/gui/kernel/qwidget_s60.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index b369168..67b974e 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -330,6 +330,10 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) */ CreateWindowL(qwidget->parentWidget()->winId()); + // Necessary in order to be able to track the activation status of + // the control's window + qwidget->d_func()->createTLExtra(); + SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); } diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 3cc810e..94f5963 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -521,7 +521,7 @@ void QWidgetPrivate::show_sys() return; } - if (q->isWindow() && q->internalWinId()) { + if (q->internalWinId()) { WId id = q->internalWinId(); if (!extra->topextra->activated) { @@ -529,12 +529,15 @@ void QWidgetPrivate::show_sys() extra->topextra->activated = 1; } id->MakeVisible(true); - id->SetFocus(true); + + if(q->isWindow()) + id->SetFocus(true); // Force setting of the icon after window is made visible, // this is needed even WA_SetWindowIcon is not set, as in that case we need // to reset to the application level window icon - setWindowIcon_sys(true); + if(q->isWindow()) + setWindowIcon_sys(true); } invalidateBuffer(q->rect()); -- cgit v0.12 From 764aebf14e5f8f72c91a4370803dfa4521aafbbc Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 28 Aug 2009 18:52:59 +0100 Subject: Video playback now visible; flickering problems now observed --- src/3rdparty/phonon/mmf/videooutput.cpp | 30 ++++++++--------------- src/3rdparty/phonon/mmf/videooutput.h | 1 - src/3rdparty/phonon/mmf/videoplayer.cpp | 42 +++++++++++++++++++++++++++------ 3 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 6810f10..ef5b154 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -42,10 +42,14 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) TRACE_ENTRY("parent 0x%08x", parent); #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - //QPalette palette(Qt::black); + QPalette palette(Qt::black); //palette.setColor(QPalette::Window, Qt::transparent); - //setPalette(palette); - //setAttribute(Qt::WA_OpaquePaintEvent, true); + setPalette(palette); + + // Widget redraws all of its pixels when it receives a paint event, so Qt + // does not need to erase it before generating paint events. + setAttribute(Qt::WA_OpaquePaintEvent, true); + //setAttribute(Qt::WA_NoSystemBackground, true); //setAutoFillBackground(false); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET @@ -168,23 +172,11 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) TRACE("regions %d", event->region().numRects()); TRACE("type %d", event->type()); -/* QPainter painter; painter.begin(this); - painter.setBrush(QColor(255, 0, 0, 255)); // opaque red - //painter.setBrush(QColor(0, 0, 0, 0)); // transparent black + painter.setBrush(QColor(0, 0, 0, 255)); // opaque black painter.drawRects(event->region().rects()); painter.end(); -*/ -} - -QPaintEngine* MMF::VideoOutput::paintEngine() const -{ - TRACE_CONTEXT(VideoOutput::sizeHint, EVideoApi); - - QPaintEngine* const engine = QWidget::paintEngine(); - - TRACE_RETURN("0x%08x", engine); } void MMF::VideoOutput::resizeEvent(QResizeEvent* event) @@ -196,9 +188,8 @@ void MMF::VideoOutput::resizeEvent(QResizeEvent* event) QWidget::resizeEvent(event); - if (m_observer) { + if (m_observer) m_observer->videoOutputRegionChanged(); - } } void MMF::VideoOutput::moveEvent(QMoveEvent* event) @@ -210,9 +201,8 @@ void MMF::VideoOutput::moveEvent(QMoveEvent* event) QWidget::moveEvent(event); - if (m_observer) { + if (m_observer) m_observer->videoOutputRegionChanged(); - } } #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 0da6ea0..bcd9cb4 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -48,7 +48,6 @@ protected: void paintEvent(QPaintEvent* event); void resizeEvent(QResizeEvent* event); void moveEvent(QMoveEvent* event); - QPaintEngine* paintEngine() const; #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET #ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 7f08405..f2f93fa 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -74,6 +74,13 @@ void MMF::VideoPlayer::construct() // TODO: is this the correct way to handle errors which occur when // creating a Symbian object in the constructor of a Qt object? + + // TODO: check whether videoOutput is visible? If not, then the + // corresponding window will not be active, meaning that the + // clipping region will be set to empty and the video will not be + // visible. If this is the case, we should set m_mmfOutputChangePending + // and respond to future showEvents from the videoOutput widget. + TRAPD(err, m_player = CVideoPlayerUtility::NewL ( @@ -108,6 +115,14 @@ MMF::VideoPlayer::~VideoPlayer() void MMF::VideoPlayer::doPlay() { + TRACE_CONTEXT(VideoPlayer::doPlay, EVideoApi); + + // See comment in updateMmfOutput + if(m_mmfOutputChangePending) { + TRACE_0("MMF output change pending - pushing now"); + updateMmfOutput(); + } + m_player->Play(); } @@ -298,10 +313,6 @@ void MMF::VideoPlayer::videoOutputRegionChanged() TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); TRACE_ENTRY("state %d", state()); -#ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT - videoOutput().dump(); -#endif - getNativeWindowSystemHandles(); // See comment in updateMmfOutput @@ -325,6 +336,12 @@ void MMF::VideoPlayer::updateMmfOutput() // MvpuoPrepareComplete, at which point the MMF controller has been // loaded. + // TODO: check whether videoOutput is visible? If not, then the + // corresponding window will not be active, meaning that the + // clipping region will be set to empty and the video will not be + // visible. If this is the case, we should set m_mmfOutputChangePending + // and respond to future showEvents from the videoOutput widget. + TRAPD(err, m_player->SetDisplayWindowL ( @@ -420,11 +437,22 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() // HACK: why isn't control->Rect updated following a call to // updateGeometry on the parent widget? m_windowRect = TRect(0, 100, 320, 250); + m_clipRect = m_windowRect; #else - m_windowRect = control->Rect(); -#endif - + m_windowRect = TRect( + control->DrawableWindow()->AbsPosition(), + control->DrawableWindow()->Size()); + + //m_clipRect = control->Rect(); m_clipRect = m_windowRect; +#endif + + TRACE("windowRect %d %d - %d %d", + m_windowRect.iTl.iX, m_windowRect.iTl.iY, + m_windowRect.iBr.iX, m_windowRect.iBr.iY); + TRACE("clipRect %d %d - %d %d", + m_clipRect.iTl.iX, m_clipRect.iTl.iY, + m_clipRect.iBr.iX, m_clipRect.iBr.iY); } -- cgit v0.12 From 74b5571063e70f6be8ff5f2bee25ef61ad179f73 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 1 Sep 2009 11:20:32 +0100 Subject: Modified hide_sys to correctly mirror action of show_sys --- src/gui/kernel/qwidget_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 94f5963..a516266 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -549,7 +549,7 @@ void QWidgetPrivate::hide_sys() Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); deactivateWidgetCleanup(); WId id = q->internalWinId(); - if (q->isWindow() && id) { + if (id) { if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged() id->SetFocus(false); id->MakeVisible(false); -- cgit v0.12 From 4ffa56ca6763e67f9acdbb59cd8f8112099c97eb Mon Sep 17 00:00:00 2001 From: Sarah Smith Date: Fri, 4 Sep 2009 15:27:51 +1000 Subject: Fix compile breakage Missing inline from private header causes undef symbol error. Also added dep for a private header missing. Reviewed-by: Lincoln Ramsay --- src/gui/painting/painting.pri | 1 + src/gui/painting/qoutlinemapper.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 5abac2f..8343cb9 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -22,6 +22,7 @@ HEADERS += \ painting/qpainter_p.h \ painting/qpainterpath.h \ painting/qpainterpath_p.h \ + painting/qvectorpath_p.h \ painting/qpathclipper_p.h \ painting/qpdf_p.h \ painting/qpen.h \ diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index 216b8c6..fa2151a 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -45,6 +45,8 @@ #include +#include + QT_BEGIN_NAMESPACE static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; -- cgit v0.12 From 2f8ad3dad31ee96798cb17d8a782b78ae4c1eabc Mon Sep 17 00:00:00 2001 From: Sarah Smith Date: Fri, 4 Sep 2009 15:34:09 +1000 Subject: Remove redundant include Fix race. Reviewed-by: Trust Me --- src/gui/painting/qoutlinemapper.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index e162f77..8d04a84 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -45,8 +45,6 @@ #include -#include - QT_BEGIN_NAMESPACE static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; -- cgit v0.12 From 991b6bc973238a6fd73c4c71e7c642b8cc455df3 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 4 Sep 2009 11:06:08 +0200 Subject: Fix a regression with QListView::setRowHidden() when a root index is set When setRowHidden() was called after a root index was set then it would not actually hide the row, if a root index is not set then it worked fine. Task-number: 260879 Reviewed-by: Jan-Arve --- src/gui/itemviews/qlistview.cpp | 8 ++++---- tests/auto/qlistview/tst_qlistview.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 35b44b4..1212194 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -549,16 +549,16 @@ void QListView::setRowHidden(int row, bool hide) const bool hidden = d->isHidden(row); if (d->viewMode == ListMode) { if (hide && !hidden) - d->hiddenRows.append(d->model->index(row, 0)); + d->hiddenRows.append(d->model->index(row, 0, rootIndex())); else if (!hide && hidden) - d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0))); + d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0, rootIndex()))); d->doDelayedItemsLayout(); } else { if (hide && !hidden) { d->dynamicListView->removeItem(row); - d->hiddenRows.append(d->model->index(row, 0)); + d->hiddenRows.append(d->model->index(row, 0, rootIndex())); } else if (!hide && hidden) { - d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0))); + d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0, rootIndex()))); d->dynamicListView->insertItem(row); } if (d->resizeMode == Adjust) diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index b52bef0..27c6a05 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -417,6 +417,18 @@ void tst_QListView::hideRows() view.setRowHidden(0, false); QVERIFY(!view.isRowHidden(0)); + QStandardItemModel sim(0); + QStandardItem *root = new QStandardItem("Root row"); + for (int i=0;i<5;i++) + root->appendRow(new QStandardItem(QString("Row %1").arg(i))); + sim.appendRow(root); + view.setModel(&sim); + view.setRootIndex(root->index()); + QVERIFY(!view.isRowHidden(0)); + view.setRowHidden(0, true); + QVERIFY(view.isRowHidden(0)); + view.setRowHidden(0, false); + QVERIFY(!view.isRowHidden(0)); } -- cgit v0.12 From 19a65fca4af242269b354f82212556f88eb03eaa Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 4 Sep 2009 12:05:41 +0200 Subject: fix text eliding for arabic and syriac Arabic and Syriac are connected scripts where the letter shape changes depending on the context. Text eliding should not affect that letter shape if the truncation happens in the middle of a word. The patch ensures that by adding a Unicode ZWJ character between the text and the eliding in case the character would connect in the full string. Reviewed-by: Simon Hausmann --- src/gui/text/qtextengine.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 2b84c6c..ba9145e 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2245,6 +2245,28 @@ void QTextEngine::indexAdditionalFormats() } } +/* These two helper functions are used to determine whether we need to insert a ZWJ character + between the text that gets truncated and the ellipsis. This is important to get + correctly shaped results for arabic text. +*/ +static bool nextCharJoins(const QString &string, int pos) +{ + while (pos < string.length() && string.at(pos).category() == QChar::Mark_NonSpacing) + ++pos; + if (pos == string.length()) + return false; + return string.at(pos).joining() != QChar::OtherJoining; +} + +static bool prevCharJoins(const QString &string, int pos) +{ + while (pos > 0 && string.at(pos - 1).category() == QChar::Mark_NonSpacing) + --pos; + if (pos == 0) + return false; + return (string.at(pos - 1).joining() == QChar::Dual || string.at(pos - 1).joining() == QChar::Center); +} + QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags) const { // qDebug() << "elidedText; available width" << width.toReal() << "text width:" << this->width(0, layoutData->string.length()).toReal(); @@ -2345,6 +2367,9 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int } while (nextBreak < layoutData->string.length() && currentWidth < availableWidth); + if (nextCharJoins(layoutData->string, pos)) + ellipsisText.prepend(QChar(0x200d) /* ZWJ */); + return layoutData->string.left(pos) + ellipsisText; } else if (mode == Qt::ElideLeft) { QFixed currentWidth; @@ -2362,6 +2387,9 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int } while (nextBreak > 0 && currentWidth < availableWidth); + if (prevCharJoins(layoutData->string, pos)) + ellipsisText.append(QChar(0x200d) /* ZWJ */); + return ellipsisText + layoutData->string.mid(pos); } else if (mode == Qt::ElideMiddle) { QFixed leftWidth; @@ -2391,6 +2419,11 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int && nextRightBreak > 0 && leftWidth + rightWidth < availableWidth); + if (nextCharJoins(layoutData->string, leftPos)) + ellipsisText.prepend(QChar(0x200d) /* ZWJ */); + if (prevCharJoins(layoutData->string, rightPos)) + ellipsisText.append(QChar(0x200d) /* ZWJ */); + return layoutData->string.left(leftPos) + ellipsisText + layoutData->string.mid(rightPos); } -- cgit v0.12 From 39fe2d324fd72d003ec5ac5779bc1b2c2c1cf45c Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 4 Sep 2009 11:44:03 +0200 Subject: Fixed once-in-a-while failing tst_QGraphicsItem::selected test. Added event information in QTest::mouse* warning message. Reviewed-by: Olivier --- src/testlib/qtestmouse.h | 7 +++++-- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 9d23c8b..665b784 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -67,6 +67,7 @@ QT_MODULE(Test) namespace QTest { enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDClick, MouseMove }; + const char *mouseActionNames[] = { "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" }; static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1) @@ -113,8 +114,10 @@ namespace QTest QTEST_ASSERT(false); } QSpontaneKeyEvent::setSpontaneous(&me); - if (!qApp->notify(widget, &me)) - QTest::qWarn("Mouse event not accepted by receiving widget"); + if (!qApp->notify(widget, &me)) { + QString warning("Mouse event \"%1\" not accepted by receiving widget"); + QTest::qWarn(warning.arg(mouseActionNames[static_cast(action)]).toAscii().data()); + } } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index aa1f2b8..408decc 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -1239,6 +1239,7 @@ void tst_QGraphicsItem::selected() QVERIFY(!item->isSelected()); // Click inside and check that it's selected + QTest::mouseMove(view.viewport()); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item->scenePos())); QCOMPARE(item->values.size(), 11); QCOMPARE(item->values.last(), true); @@ -1246,7 +1247,6 @@ void tst_QGraphicsItem::selected() // Click outside and check that it's not selected QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item->scenePos() + QPointF(item->boundingRect().width(), item->boundingRect().height()))); - QCOMPARE(item->values.size(), 12); QCOMPARE(item->values.last(), false); QVERIFY(!item->isSelected()); -- cgit v0.12 From 3944904b361b5a585a6e07bf17528d4739caed39 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Fri, 4 Sep 2009 12:17:34 +0200 Subject: Doc: Review of docs for QGraphicsItem::ItemUsesExtendedStyleOption. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: 253733 Reviewed-by: Bjørn Erik Nilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b7c2e26..cdcb0c4 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -303,13 +303,17 @@ drop shadow effects and for decoration objects that follow the parent item's geometry without drawing on top of it. - \value ItemUsesExtendedStyleOption The item makes use of either the - exposedRect or matrix member of the QStyleOptionGraphicsItem. Implementers - of QGraphicsItem subclasses should set that flag if this data is required. - By default, the exposedRect is initialized to the item's boundingRect and - the matrix is untransformed. Enable this flag for more fine-grained values. - Use QStyleOptionGraphicsItem::levelOfDetailFromTransform() for a more - fine-grained value. + \value ItemUsesExtendedStyleOption The item makes use of either + \l{QStyleOptionGraphicsItem::}{exposedRect} or + \l{QStyleOptionGraphicsItem::}{matrix} in QStyleOptionGraphicsItem. By default, + the \l{QStyleOptionGraphicsItem::}{exposedRect} is initialized to the item's + boundingRect() and the \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. + You can enable this flag for the style options to be set up with more + fine-grained values. + Note that QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag + and always initialized to 1. Use + QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need a higher + value. \value ItemHasNoContents The item does not paint anything (i.e., calling paint() on the item has no effect). You should set this flag on items that -- cgit v0.12 From 228153b29c3e235fa5d40ff09f8403fa2e8f7226 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Jan 2009 16:07:27 +0100 Subject: Fix oversize-buffer support for aligning. Since Vector initialises VectorBase with the value of inlineBuffer(), it does so before the m_inlineBuffer member has had a chance to initialise. This lead to dereferencing of uninitialised pointers and, as was expected, crashes. --- src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h index e3cb718..11c20a9 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h @@ -67,10 +67,11 @@ namespace WTF { template struct AlignedBuffer { AlignedBufferChar oversizebuffer[size + 64]; - AlignedBufferChar *buffer; - inline AlignedBuffer() : buffer(oversizebuffer) + AlignedBufferChar *buffer() { - buffer += 64 - (reinterpret_cast(buffer) & 0x3f); + AlignedBufferChar *ptr = oversizebuffer; + ptr += 64 - (reinterpret_cast(ptr) & 0x3f); + return ptr; } }; #endif @@ -440,7 +441,11 @@ namespace WTF { using Base::m_capacity; static const size_t m_inlineBufferSize = inlineCapacity * sizeof(T); + #ifdef WTF_ALIGNED T* inlineBuffer() { return reinterpret_cast(m_inlineBuffer.buffer); } + #else + T* inlineBuffer() { return reinterpret_cast(m_inlineBuffer.buffer()); } + #endif AlignedBuffer m_inlineBuffer; }; -- cgit v0.12 From 6f1ff47beeee6a6af489df58813ebd87237c93b0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 23 Jul 2009 16:55:01 +0200 Subject: Fix linking with SunCC 5.9: de-inline the operator new and delete in ParserArenaDeletable. If you mark functions as "inline", the compiler doesn't have to emit out-of-line copies. What happens is that Nodes.h declares these functions, but the inline bodies are in NodeConstructors.h. ParserArena.cpp used these functions, but didn't include NodeConstructor.h. I could have added the missing #include, but this is error-prone, since you have to remember to do that. Moving the bodies into Nodes.h was also not possible, because it requires JSC::Parser to be defined and Parser.h needs to #include "Nodes.h". So the solution is to de-inline. --- .../webkit/JavaScriptCore/parser/NodeConstructors.h | 17 ----------------- .../webkit/JavaScriptCore/parser/ParserArena.cpp | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/NodeConstructors.h b/src/3rdparty/webkit/JavaScriptCore/parser/NodeConstructors.h index c256190..a4374d3 100644 --- a/src/3rdparty/webkit/JavaScriptCore/parser/NodeConstructors.h +++ b/src/3rdparty/webkit/JavaScriptCore/parser/NodeConstructors.h @@ -27,23 +27,6 @@ namespace JSC { - inline void* ParserArenaDeletable::operator new(size_t size, JSGlobalData* globalData) - { - ParserArenaDeletable* deletable = static_cast(fastMalloc(size)); - globalData->parser->arena().deleteWithArena(deletable); - return deletable; - } - - inline void* ParserArenaDeletable::operator new(size_t size) - { - return fastMalloc(size); - } - - inline void ParserArenaDeletable::operator delete(void* p) - { - fastFree(p); - } - inline ParserArenaRefCounted::ParserArenaRefCounted(JSGlobalData* globalData) { globalData->parser->arena().derefWithArena(adoptRef(this)); diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/ParserArena.cpp b/src/3rdparty/webkit/JavaScriptCore/parser/ParserArena.cpp index 2617506..78c5196 100644 --- a/src/3rdparty/webkit/JavaScriptCore/parser/ParserArena.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/parser/ParserArena.cpp @@ -24,6 +24,7 @@ */ #include "config.h" +#include "Parser.h" #include "ParserArena.h" #include "Nodes.h" @@ -57,4 +58,21 @@ void ParserArena::reset() m_refCountedObjects.shrink(0); } +void* ParserArenaDeletable::operator new(size_t size, JSGlobalData* globalData) +{ + ParserArenaDeletable* deletable = static_cast(fastMalloc(size)); + globalData->parser->arena().deleteWithArena(deletable); + return deletable; +} + +void* ParserArenaDeletable::operator new(size_t size) +{ + return fastMalloc(size); +} + +void ParserArenaDeletable::operator delete(void* p) +{ + fastFree(p); +} + } -- cgit v0.12 From b9fdc5636c166e26195d783378ff4da43b755bc5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 19 Jul 2009 15:14:06 +0200 Subject: Fix compilation error on Solaris: mmap/munmap take/return a char*, not void*. "../JavaScriptCore/interpreter/RegisterFile.h", line 128: Error: Using static_cast to convert from char* to JSC::Register* not allowed. Error: Formal argument 1 of type char* in call to munmap(char*, unsigned) is being passed JSC::Register*. --- src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp | 2 +- src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp index 06ddefc..29a13ca 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp @@ -34,7 +34,7 @@ namespace JSC { RegisterFile::~RegisterFile() { #if HAVE(MMAP) - munmap(m_buffer, ((m_max - m_start) + m_maxGlobals) * sizeof(Register)); + munmap(reinterpret_cast(m_buffer), ((m_max - m_start) + m_maxGlobals) * sizeof(Register)); #elif HAVE(VIRTUALALLOC) VirtualFree(m_buffer, 0, MEM_RELEASE); #else diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.h b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.h index 5a34d11..14e189e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.h +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.h @@ -105,7 +105,7 @@ namespace JSC { ReturnValueRegister = -4, ArgumentCount = -3, Callee = -2, - OptionalCalleeArguments = -1, + OptionalCalleeArguments = -1 }; enum { ProgramCodeThisRegister = -CallFrameHeaderSize - 1 }; @@ -174,7 +174,7 @@ namespace JSC { size_t bufferLength = (capacity + maxGlobals) * sizeof(Register); #if HAVE(MMAP) - m_buffer = static_cast(mmap(0, bufferLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, VM_TAG_FOR_REGISTERFILE_MEMORY, 0)); + m_buffer = reinterpret_cast(mmap(0, bufferLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, VM_TAG_FOR_REGISTERFILE_MEMORY, 0)); if (m_buffer == MAP_FAILED) { #if PLATFORM(WINCE) fprintf(stderr, "Could not allocate register file: %d\n", GetLastError()); -- cgit v0.12 From bd3c95917dfe2c2740403176935bf84ada9df403 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Jul 2009 14:18:35 +0200 Subject: Fix compilation with Sun CC 5.9: moving elements in a vector requires source not to be const I don't know why the compiler couldn't call src->~T() on a const T *src, but fact is it couldn't. In any case, since move is copying the source and deleting it, formally the argument shouldn't be const anyway. --- src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h index 11c20a9..7decc4a 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Vector.h @@ -129,7 +129,7 @@ namespace WTF { template struct VectorMover { - static void move(const T* src, const T* srcEnd, T* dst) + static void move(T* src, const T* srcEnd, T* dst) { while (src != srcEnd) { new (dst) T(*src); @@ -138,7 +138,7 @@ namespace WTF { ++src; } } - static void moveOverlapping(const T* src, const T* srcEnd, T* dst) + static void moveOverlapping(T* src, const T* srcEnd, T* dst) { if (src > dst) move(src, srcEnd, dst); @@ -157,11 +157,11 @@ namespace WTF { template struct VectorMover { - static void move(const T* src, const T* srcEnd, T* dst) + static void move(T* src, const T* srcEnd, T* dst) { memcpy(dst, src, reinterpret_cast(srcEnd) - reinterpret_cast(src)); } - static void moveOverlapping(const T* src, const T* srcEnd, T* dst) + static void moveOverlapping(T* src, const T* srcEnd, T* dst) { memmove(dst, src, reinterpret_cast(srcEnd) - reinterpret_cast(src)); } @@ -254,12 +254,12 @@ namespace WTF { VectorInitializer::needsInitialization, VectorTraits::canInitializeWithMemset, T>::initialize(begin, end); } - static void move(const T* src, const T* srcEnd, T* dst) + static void move(T* src, const T* srcEnd, T* dst) { VectorMover::canMoveWithMemcpy, T>::move(src, srcEnd, dst); } - static void moveOverlapping(const T* src, const T* srcEnd, T* dst) + static void moveOverlapping(T* src, const T* srcEnd, T* dst) { VectorMover::canMoveWithMemcpy, T>::moveOverlapping(src, srcEnd, dst); } -- cgit v0.12 From 37b26723280e7fbda5fb3a5960105eda25f5c53f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 3 Sep 2009 14:06:41 +0200 Subject: Remove comma at end of enum. Some compilers are more picky than others. Conflicts: src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h --- src/3rdparty/webkit/JavaScriptCore/wtf/MessageQueue.h | 2 +- src/3rdparty/webkit/WebCore/bridge/npapi.h | 3 ++- src/3rdparty/webkit/WebCore/dom/ExceptionCode.h | 2 +- src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h | 2 +- src/3rdparty/webkit/WebCore/editing/EditorInsertAction.h | 2 +- src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h | 2 +- src/3rdparty/webkit/WebCore/loader/FrameLoader.h | 2 +- src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h | 2 +- src/3rdparty/webkit/WebCore/platform/PlatformKeyboardEvent.h | 2 +- src/3rdparty/webkit/WebCore/platform/ScrollTypes.h | 4 ++-- src/3rdparty/webkit/WebCore/platform/graphics/BitmapImage.h | 2 +- src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h | 2 +- src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.h | 2 +- src/3rdparty/webkit/WebCore/platform/network/ResourceHandleClient.h | 2 +- src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.h | 2 +- src/3rdparty/webkit/WebCore/platform/text/StringImpl.h | 2 +- src/3rdparty/webkit/WebCore/platform/text/TextCodec.h | 2 +- src/3rdparty/webkit/WebCore/plugins/PluginQuirkSet.h | 2 +- src/3rdparty/webkit/WebCore/rendering/RenderLayer.h | 2 +- 19 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/MessageQueue.h b/src/3rdparty/webkit/JavaScriptCore/wtf/MessageQueue.h index 12291cc..070b76c 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/MessageQueue.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/MessageQueue.h @@ -41,7 +41,7 @@ namespace WTF { enum MessageQueueWaitResult { MessageQueueTerminated, // Queue was destroyed while waiting for message. MessageQueueTimeout, // Timeout was specified and it expired. - MessageQueueMessageReceived, // A message was successfully received and returned. + MessageQueueMessageReceived // A message was successfully received and returned. }; template diff --git a/src/3rdparty/webkit/WebCore/bridge/npapi.h b/src/3rdparty/webkit/WebCore/bridge/npapi.h index 07fed86..2ff657e 100644 --- a/src/3rdparty/webkit/WebCore/bridge/npapi.h +++ b/src/3rdparty/webkit/WebCore/bridge/npapi.h @@ -350,9 +350,10 @@ typedef enum { NPPVpluginWantsAllNetworkStreams = 18, /* Checks to see if the plug-in would like the browser to load the "src" attribute. */ - NPPVpluginCancelSrcStream = 20, + NPPVpluginCancelSrcStream = 20 #ifdef XP_MACOSX + , /* Used for negotiating drawing models */ NPPVpluginDrawingModel = 1000, /* Used for negotiating event models */ diff --git a/src/3rdparty/webkit/WebCore/dom/ExceptionCode.h b/src/3rdparty/webkit/WebCore/dom/ExceptionCode.h index 58b18e2..08bffa6 100644 --- a/src/3rdparty/webkit/WebCore/dom/ExceptionCode.h +++ b/src/3rdparty/webkit/WebCore/dom/ExceptionCode.h @@ -57,7 +57,7 @@ namespace WebCore { NETWORK_ERR = 19, ABORT_ERR = 20, URL_MISMATCH_ERR = 21, - QUOTA_EXCEEDED_ERR = 22, + QUOTA_EXCEEDED_ERR = 22 }; enum ExceptionType { diff --git a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h index 3f8febc..f95f0045 100644 --- a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h +++ b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h @@ -45,7 +45,7 @@ namespace WebCore { enum MessageDestination { InspectorControllerDestination, - ConsoleDestination, + ConsoleDestination }; class ScriptExecutionContext { diff --git a/src/3rdparty/webkit/WebCore/editing/EditorInsertAction.h b/src/3rdparty/webkit/WebCore/editing/EditorInsertAction.h index 5b732dc..b8b137d 100644 --- a/src/3rdparty/webkit/WebCore/editing/EditorInsertAction.h +++ b/src/3rdparty/webkit/WebCore/editing/EditorInsertAction.h @@ -32,7 +32,7 @@ namespace WebCore { enum EditorInsertAction { EditorInsertActionTyped, EditorInsertActionPasted, - EditorInsertActionDropped, + EditorInsertActionDropped }; } // namespace diff --git a/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h b/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h index cc3627d..fdd854c 100644 --- a/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h +++ b/src/3rdparty/webkit/WebCore/generated/CSSPropertyNames.h @@ -275,7 +275,7 @@ enum CSSPropertyID { CSSPropertyGlyphOrientationVertical = 1268, CSSPropertyKerning = 1269, CSSPropertyTextAnchor = 1270, - CSSPropertyWritingMode = 1271, + CSSPropertyWritingMode = 1271 }; const int firstCSSProperty = 1001; diff --git a/src/3rdparty/webkit/WebCore/loader/FrameLoader.h b/src/3rdparty/webkit/WebCore/loader/FrameLoader.h index 58bf2c0..c41e491 100644 --- a/src/3rdparty/webkit/WebCore/loader/FrameLoader.h +++ b/src/3rdparty/webkit/WebCore/loader/FrameLoader.h @@ -355,7 +355,7 @@ namespace WebCore { enum LocalLoadPolicy { AllowLocalLoadsForAll, // No restriction on local loads. AllowLocalLoadsForLocalAndSubstituteData, - AllowLocalLoadsForLocalOnly, + AllowLocalLoadsForLocalOnly }; static void setLocalLoadPolicy(LocalLoadPolicy); static bool restrictAccessToLocal(); diff --git a/src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h b/src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h index c264b47..b3823ba 100644 --- a/src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h +++ b/src/3rdparty/webkit/WebCore/loader/FrameLoaderTypes.h @@ -42,7 +42,7 @@ namespace WebCore { enum PolicyAction { PolicyUse, PolicyDownload, - PolicyIgnore, + PolicyIgnore }; enum FrameLoadType { diff --git a/src/3rdparty/webkit/WebCore/platform/PlatformKeyboardEvent.h b/src/3rdparty/webkit/WebCore/platform/PlatformKeyboardEvent.h index 4a6bc9e..d9701b7 100644 --- a/src/3rdparty/webkit/WebCore/platform/PlatformKeyboardEvent.h +++ b/src/3rdparty/webkit/WebCore/platform/PlatformKeyboardEvent.h @@ -81,7 +81,7 @@ namespace WebCore { AltKey = 1 << 0, CtrlKey = 1 << 1, MetaKey = 1 << 2, - ShiftKey = 1 << 3, + ShiftKey = 1 << 3 }; Type type() const { return m_type; } diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollTypes.h b/src/3rdparty/webkit/WebCore/platform/ScrollTypes.h index eba9055..b0df470 100644 --- a/src/3rdparty/webkit/WebCore/platform/ScrollTypes.h +++ b/src/3rdparty/webkit/WebCore/platform/ScrollTypes.h @@ -53,7 +53,7 @@ namespace WebCore { enum ScrollbarControlStateMask { ActiveScrollbarState = 1, EnabledScrollbarState = 1 << 1, - PressedScrollbarState = 1 << 2, + PressedScrollbarState = 1 << 2 }; enum ScrollbarPart { @@ -67,7 +67,7 @@ namespace WebCore { ForwardButtonEndPart = 1 << 6, ScrollbarBGPart = 1 << 7, TrackBGPart = 1 << 8, - AllParts = 0xffffffff, + AllParts = 0xffffffff }; enum ScrollbarButtonsPlacement { diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/BitmapImage.h b/src/3rdparty/webkit/WebCore/platform/graphics/BitmapImage.h index 8b770a1..a3a0493 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/BitmapImage.h +++ b/src/3rdparty/webkit/WebCore/platform/graphics/BitmapImage.h @@ -150,7 +150,7 @@ protected: enum RepetitionCountStatus { Unknown, // We haven't checked the source's repetition count. Uncertain, // We have a repetition count, but it might be wrong (some GIFs have a count after the image data, and will report "loop once" until all data has been decoded). - Certain, // The repetition count is known to be correct. + Certain // The repetition count is known to be correct. }; BitmapImage(NativeImagePtr, ImageObserver* = 0); diff --git a/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h b/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h index 9c2a9d7..494e2bb 100644 --- a/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h +++ b/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h @@ -52,7 +52,7 @@ namespace WebCore { DisposeNotSpecified, // Leave frame in framebuffer DisposeKeep, // Leave frame in framebuffer DisposeOverwriteBgcolor, // Clear frame to transparent - DisposeOverwritePrevious, // Clear frame to previous framebuffer contents + DisposeOverwritePrevious // Clear frame to previous framebuffer contents }; #if PLATFORM(SKIA) typedef uint32_t PixelData; diff --git a/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.h b/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.h index 9a73cff..b7d4574 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.h +++ b/src/3rdparty/webkit/WebCore/platform/network/ProtectionSpace.h @@ -46,7 +46,7 @@ enum ProtectionSpaceAuthenticationScheme { ProtectionSpaceAuthenticationSchemeHTTPDigest = 3, ProtectionSpaceAuthenticationSchemeHTMLForm = 4, ProtectionSpaceAuthenticationSchemeNTLM = 5, - ProtectionSpaceAuthenticationSchemeNegotiate = 6, + ProtectionSpaceAuthenticationSchemeNegotiate = 6 }; class ProtectionSpace { diff --git a/src/3rdparty/webkit/WebCore/platform/network/ResourceHandleClient.h b/src/3rdparty/webkit/WebCore/platform/network/ResourceHandleClient.h index c99be54..b8a8cbb 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ResourceHandleClient.h +++ b/src/3rdparty/webkit/WebCore/platform/network/ResourceHandleClient.h @@ -56,7 +56,7 @@ namespace WebCore { enum CacheStoragePolicy { StorageAllowed, StorageAllowedInMemoryOnly, - StorageNotAllowed, + StorageNotAllowed }; class ResourceHandleClient { diff --git a/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.h b/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.h index 2d87d6e..740ebed 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.h +++ b/src/3rdparty/webkit/WebCore/platform/network/ResourceRequestBase.h @@ -41,7 +41,7 @@ namespace WebCore { UseProtocolCachePolicy, // normal load ReloadIgnoringCacheData, // reload ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data - ReturnCacheDataDontLoad, // results of a post - allow stale data and only use cache + ReturnCacheDataDontLoad // results of a post - allow stale data and only use cache }; const int unspecifiedTimeoutInterval = INT_MAX; diff --git a/src/3rdparty/webkit/WebCore/platform/text/StringImpl.h b/src/3rdparty/webkit/WebCore/platform/text/StringImpl.h index 38439ed..4325925 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/StringImpl.h +++ b/src/3rdparty/webkit/WebCore/platform/text/StringImpl.h @@ -199,7 +199,7 @@ private: enum StringImplFlags { HasTerminatingNullCharacter, - InTable, + InTable }; unsigned m_length; diff --git a/src/3rdparty/webkit/WebCore/platform/text/TextCodec.h b/src/3rdparty/webkit/WebCore/platform/text/TextCodec.h index 3c74165..36d7c6e 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/TextCodec.h +++ b/src/3rdparty/webkit/WebCore/platform/text/TextCodec.h @@ -51,7 +51,7 @@ namespace WebCore { // Encodes the character as en entity as above, but escaped // non-alphanumeric characters. This is used in URLs. // For example, U+6DE would be "%26%231758%3B". - URLEncodedEntitiesForUnencodables, + URLEncodedEntitiesForUnencodables }; typedef char UnencodableReplacementArray[32]; diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginQuirkSet.h b/src/3rdparty/webkit/WebCore/plugins/PluginQuirkSet.h index b652c6e..8183050 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginQuirkSet.h +++ b/src/3rdparty/webkit/WebCore/plugins/PluginQuirkSet.h @@ -45,7 +45,7 @@ namespace WebCore { PluginQuirkDontClipToZeroRectWhenScrolling = 1 << 9, PluginQuirkDontSetNullWindowHandleOnDestroy = 1 << 10, PluginQuirkDontAllowMultipleInstances = 1 << 11, - PluginQuirkRequiresGtkToolKit = 1 << 12, + PluginQuirkRequiresGtkToolKit = 1 << 12 }; class PluginQuirkSet { diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h index 1772c66..541002f 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderLayer.h @@ -298,7 +298,7 @@ public: enum UpdateLayerPositionsFlag { DoFullRepaint = 1, CheckForRepaint = 1 << 1, - UpdateCompositingLayers = 1 << 2, + UpdateCompositingLayers = 1 << 2 }; typedef unsigned UpdateLayerPositionsFlags; void updateLayerPositions(UpdateLayerPositionsFlags = DoFullRepaint | UpdateCompositingLayers); -- cgit v0.12 From fd348f0cc28db4a20b06102b419139c0f1473aec Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 3 Sep 2009 14:07:49 +0200 Subject: Fix compilation with Sun CC 5.9: ambiguity in ?: Error: Ambiguous "?:" expression, second operand of type "WTF::PassRefPtr" and third operand of type "int" can be converted to one another. Error: Ambiguous "?:" expression, second operand of type "WTF::PassRefPtr" and third operand of type "int" can be converted to one another. [and others similar] Conflicts: src/3rdparty/webkit/WebCore/workers/WorkerContext.cpp --- .../webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp | 2 +- src/3rdparty/webkit/WebCore/editing/CompositeEditCommand.cpp | 2 +- src/3rdparty/webkit/WebCore/editing/markup.cpp | 2 +- src/3rdparty/webkit/WebCore/html/HTMLParser.cpp | 4 ++-- src/3rdparty/webkit/WebCore/loader/DocumentLoader.cpp | 2 +- .../webkit/WebCore/loader/appcache/ApplicationCacheGroup.cpp | 2 +- src/3rdparty/webkit/WebCore/loader/archive/ArchiveFactory.cpp | 2 +- src/3rdparty/webkit/WebCore/loader/archive/ArchiveResource.cpp | 6 +++--- src/3rdparty/webkit/WebCore/loader/icon/IconDatabase.cpp | 2 +- src/3rdparty/webkit/WebCore/page/DOMWindow.cpp | 2 +- src/3rdparty/webkit/WebCore/page/animation/AnimationBase.cpp | 2 +- src/3rdparty/webkit/WebCore/rendering/RenderLayer.cpp | 4 ++-- src/3rdparty/webkit/WebCore/rendering/RenderScrollbar.cpp | 2 +- src/3rdparty/webkit/WebCore/rendering/RenderTextFragment.cpp | 2 +- src/3rdparty/webkit/WebCore/svg/SVGElement.cpp | 2 +- src/3rdparty/webkit/WebCore/workers/Worker.cpp | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp index ce5518f..711beb4 100644 --- a/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp @@ -521,7 +521,7 @@ PassRefPtr BytecodeGenerator::newLabelScope(LabelScope::Type type, c m_labelScopes.removeLast(); // Allocate new label scope. - LabelScope scope(type, name, scopeDepth(), newLabel(), type == LabelScope::Loop ? newLabel() : PassRefPtr