From dcfda58e029042e8d7339833bdb2d6a90bd3e30f Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 1 Jul 2009 15:17:54 +0200 Subject: Hook in the MMF backend. --- src/plugins/phonon/mmf/mmf.pro | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/plugins/phonon/mmf/mmf.pro diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro new file mode 100644 index 0000000..0c4bff7 --- /dev/null +++ b/src/plugins/phonon/mmf/mmf.pro @@ -0,0 +1,54 @@ +DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend +QT += phonon +TARGET = phonon_mmf +PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf + +# 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 + + +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 3c3745c29d9fbae98b55a88b5ebccb0b29b4eed5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 4 Sep 2009 13:05:08 +0300 Subject: Fixed symbian-sbsv2 build break in apps using debug_and_release. Skipped addExclusiveBuilds function in debug_and_release.prf for all Symbian platforms, as it doesn't work with Symbian toolchain. Reviewed-by: Janne Anttila --- mkspecs/features/debug_and_release.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/debug_and_release.prf b/mkspecs/features/debug_and_release.prf index 19031ef..ef33789 100644 --- a/mkspecs/features/debug_and_release.prf +++ b/mkspecs/features/debug_and_release.prf @@ -1 +1 @@ -!macx-xcode:!symbian-abld:addExclusiveBuilds(debug, Debug, release, Release) +!macx-xcode:!symbian:addExclusiveBuilds(debug, Debug, release, Release) -- cgit v0.12 From 386800053d03f3f42bc5d0e0809059b534bac5d4 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 7 Sep 2009 11:26:02 +0100 Subject: Added visitor-based object tree dumping framework, which dumps details of Symbian control / window associated with each widget --- src/3rdparty/phonon/mmf/defs.h | 2 - src/3rdparty/phonon/mmf/objectdump.cpp | 527 +++++++++++++++++++++++++ src/3rdparty/phonon/mmf/objectdump.h | 164 ++++++++ src/3rdparty/phonon/mmf/objectdump_symbian.cpp | 129 ++++++ src/3rdparty/phonon/mmf/objectdump_symbian.h | 56 +++ src/3rdparty/phonon/mmf/objecttree.cpp | 102 +++++ src/3rdparty/phonon/mmf/objecttree.h | 115 ++++++ src/3rdparty/phonon/mmf/videooutput.cpp | 73 +--- src/3rdparty/phonon/mmf/videooutput.h | 8 +- src/3rdparty/phonon/mmf/videoplayer.cpp | 24 +- src/plugins/phonon/mmf/mmf.pro | 15 + 11 files changed, 1154 insertions(+), 61 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/objectdump.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump.h create mode 100644 src/3rdparty/phonon/mmf/objectdump_symbian.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump_symbian.h create mode 100644 src/3rdparty/phonon/mmf/objecttree.cpp create mode 100644 src/3rdparty/phonon/mmf/objecttree.h diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 674e767..60f363b 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -34,8 +34,6 @@ 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 - QT_BEGIN_NAMESPACE namespace Phonon diff --git a/src/3rdparty/phonon/mmf/objectdump.cpp b/src/3rdparty/phonon/mmf/objectdump.cpp new file mode 100644 index 0000000..50c6bf8 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump.cpp @@ -0,0 +1,527 @@ +/* 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 +#include + +#include "objectdump.h" +#include "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +//----------------------------------------------------------------------------- +// QObjectAnnotator +//----------------------------------------------------------------------------- + +QAnnotator::~QAnnotator() +{ + +} + + +//----------------------------------------------------------------------------- +// Annotators +//----------------------------------------------------------------------------- + +QList QAnnotatorBasic::annotation(const QObject& object) +{ + QList result; + + QByteArray array; + QTextStream stream(&array); + + stream << '[' << &object << ']'; + stream << ' '; + stream << object.metaObject()->className(); + + if(object.objectName() != "") + stream << " \"" << object.objectName() << '"'; + + if(object.isWidgetType()) + stream << " isWidget"; + + stream.flush(); + result.append(array); + return result; +} + +QList QAnnotatorWidget::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + QByteArray array; + QTextStream stream(&array); + + stream << "widget: "; + + if(widget->isVisible()) + stream << "visible "; + else + stream << "invisible "; + + stream << widget->x() << ',' << widget->y() << ' '; + stream << widget->size().width() << 'x'<< widget->size().height() << ' '; + + stream << "hint " << widget->sizeHint().width() << 'x' << widget->sizeHint().height(); + + stream.flush(); + result.append(array); + } + + return result; +} + + +//----------------------------------------------------------------------------- +// Base class for QDumperPrivate, QVisitorPrivate +//----------------------------------------------------------------------------- + +class QDumperBase +{ +public: + QDumperBase(); + ~QDumperBase(); + + void setPrefix(const QString& prefix); + void addAnnotator(QAnnotator* annotator); + +protected: + QByteArray m_prefix; + QList m_annotators; + +}; + +QDumperBase::QDumperBase() +{ + +} + +QDumperBase::~QDumperBase() +{ + QAnnotator* annotator; + foreach(annotator, m_annotators) + delete annotator; +} + +void QDumperBase::setPrefix(const QString& prefix) +{ + m_prefix = prefix.count() + ? (prefix + " ").toAscii() + : prefix.toAscii(); +} + +void QDumperBase::addAnnotator(QAnnotator* annotator) +{ + // Protect against an exception occurring during QList::append + QScopedPointer holder(annotator); + m_annotators.append(annotator); + holder.take(); +} + + +//----------------------------------------------------------------------------- +// QDumper +//----------------------------------------------------------------------------- + +class QDumperPrivate : public QDumperBase +{ +public: + QDumperPrivate(); + ~QDumperPrivate(); + + void dumpObject(const QObject& object); + +}; + + +QDumperPrivate::QDumperPrivate() +{ + +} + +QDumperPrivate::~QDumperPrivate() +{ + +} + +void QDumperPrivate::dumpObject(const QObject& object) +{ + QAnnotator* annotator; + foreach(annotator, m_annotators) { + + const QList annotations = annotator->annotation(object); + QByteArray annotation; + foreach(annotation, annotations) { + QByteArray buffer(m_prefix); + buffer.append(annotation); + qDebug() << buffer.constData(); + } + } +} + + +QDumper::QDumper() + : d_ptr(new QDumperPrivate) +{ + +} + +QDumper::~QDumper() +{ + +} + +void QDumper::setPrefix(const QString& prefix) +{ + d_func()->setPrefix(prefix); +} + +void QDumper::addAnnotator(QAnnotator* annotator) +{ + d_func()->addAnnotator(annotator); +} + +void QDumper::dumpObject(const QObject& object) +{ + d_func()->dumpObject(object); +} + + +//----------------------------------------------------------------------------- +// QVisitor +//----------------------------------------------------------------------------- + +class QVisitorPrivate : public QDumperBase +{ +public: + QVisitorPrivate(); + ~QVisitorPrivate(); + + void setIndent(unsigned indent); + + void visitNode(const QObject& object); + void visitComplete(); + +private: + class Node + { + public: + Node(); + ~Node(); + + QList m_annotation; + QList m_children; + + typedef QList::const_iterator child_iterator; + }; + +private: + Node* findNode(const QObject* object) const; + QByteArray branchBuffer(const QList& branches, bool isNodeLine, bool isLastChild) const; + void dumpRecursive(const Node& node, QList branches, bool isLastChild); + void dumpNode(const Node& node, const QList& branches, bool isLastChild); + +private: + unsigned m_indent; + + QScopedPointer m_root; + + // Hash table used to associate internal nodes with QObjects + typedef QHash Hash; + Hash m_hash; +}; + +static const unsigned DefaultIndent = 2; + +QVisitorPrivate::QVisitorPrivate() + : m_indent(DefaultIndent) +{ + +} + +QVisitorPrivate::~QVisitorPrivate() +{ + +} + +void QVisitorPrivate::setIndent(unsigned indent) +{ + m_indent = indent; +} + +// Builds up a mirror of the object tree, rooted in m_root, with each node +// storing annotations generated by +void QVisitorPrivate::visitNode(const QObject& object) +{ + QObject* const objectParent = object.parent(); + Node* const nodeParent = objectParent ? findNode(objectParent) : NULL; + + // Create a new node and store in scoped pointer for exception safety + Node* node = new Node; + QScopedPointer nodePtr(node); + + // Associate node with QObject + m_hash.insert(&object, node); + + // Insert node into internal tree + if(nodeParent) + { + nodeParent->m_children.append(nodePtr.take()); + } + else + { + Q_ASSERT(m_root.isNull()); + m_root.reset(nodePtr.take()); + } + + // Generate and store annotations + QAnnotator* annotator; + foreach(annotator, m_annotators) + node->m_annotation.append( annotator->annotation(object) ); +} + +void QVisitorPrivate::visitComplete() +{ + QList branches; + static const bool isLastChild = true; + dumpRecursive(*m_root, branches, isLastChild); + m_root.reset(NULL); +} + +QVisitorPrivate::Node* QVisitorPrivate::findNode(const QObject* object) const +{ + Hash::const_iterator i = m_hash.find(object); + return (m_hash.end() == i) ? NULL : *i; +} + +QByteArray QVisitorPrivate::branchBuffer + (const QList& branches, bool isNodeLine, bool isLastChild) const +{ + const int depth = branches.count(); + + const QByteArray indent(m_indent, ' '); + const QByteArray horiz(m_indent, '-'); + + QByteArray buffer; + QTextStream stream(&buffer); + + for (int i=0; i branches, bool isLastChild) +{ + dumpNode(node, branches, isLastChild); + + // Recurse down tree + const Node::child_iterator begin = node.m_children.begin(); + const Node::child_iterator end = node.m_children.end(); + for(Node::child_iterator i = begin; end != i; ++i) { + + isLastChild = (end == i + 1); + + if(begin == i) + branches.push_back(!isLastChild); + else + branches.back() = !isLastChild; + + static const bool isNodeLine = false; + const QByteArray buffer = branchBuffer(branches, isNodeLine, false); + qDebug() << buffer.constData(); + + dumpRecursive(**i, branches, isLastChild); + } +} + +void QVisitorPrivate::dumpNode + (const Node& node, const QList& branches, bool isLastChild) +{ + const QList::const_iterator + begin = node.m_annotation.begin(), end = node.m_annotation.end(); + + if(begin == end) { + // No annotations - just dump the object pointer + const bool isNodeLine = true; + QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); + qDebug() << NULL; // TODO + } + else { + // Dump annotations + for(QList::const_iterator i = begin; end != i; ++i) { + const bool isNodeLine = (begin == i); + QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); + buffer.append(*i); + qDebug() << buffer.constData(); + } + } +} + + +// QVisitorPrivate::Node + +QVisitorPrivate::Node::Node() +{ + +} + +QVisitorPrivate::Node::~Node() +{ + Node* child; + foreach(child, m_children) + delete child; +} + + +// QVisitor + +QVisitor::QVisitor() + : d_ptr(new QVisitorPrivate) +{ + +} + +QVisitor::~QVisitor() +{ + +} + +void QVisitor::setPrefix(const QString& prefix) +{ + d_func()->setPrefix(prefix); +} + +void QVisitor::setIndent(unsigned indent) +{ + d_func()->setIndent(indent); +} + +void QVisitor::addAnnotator(QAnnotator* annotator) +{ + d_func()->addAnnotator(annotator); +} + +void QVisitor::visitPrepare() +{ + // Do nothing +} + +void QVisitor::visitNode(const QObject& object) +{ + d_func()->visitNode(object); +} + +void QVisitor::visitComplete() +{ + d_func()->visitComplete(); +} + + +//----------------------------------------------------------------------------- +// Utility functions +//----------------------------------------------------------------------------- + +void addDefaultAnnotators_sys(QDumper& visitor); +void addDefaultAnnotators_sys(QVisitor& visitor); + +void addDefaultAnnotators(QDumper& dumper) +{ + dumper.addAnnotator(new QAnnotatorBasic); + dumper.addAnnotator(new QAnnotatorWidget); + + // Add platform-specific annotators + addDefaultAnnotators_sys(dumper); +} + +void addDefaultAnnotators(QVisitor& visitor) +{ + visitor.addAnnotator(new QAnnotatorBasic); + visitor.addAnnotator(new QAnnotatorWidget); + + // Add platform-specific annotators + addDefaultAnnotators_sys(visitor); +} + +void dumpTreeFromRoot(const QObject& root, QVisitor& visitor) +{ + // Set up iteration range + ObjectTree::DepthFirstConstIterator begin(root), end; + + // Invoke generic visitor algorithm + ObjectTree::visit(begin, end, visitor); +} + +void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor) +{ + // Walk up to root + const QObject* root = &leaf; + while(root->parent()) + { + root = root->parent(); + } + + dumpTreeFromRoot(*root, visitor); +} + +void dumpAncestors(const QObject& leaf, QVisitor& visitor) +{ + // Set up iteration range + ObjectTree::AncestorConstIterator begin(leaf), end; + + // Invoke generic visitor algorithm + ObjectTree::visit(begin, end, visitor); +} + + +} // namespace ObjectDump + +QT_END_NAMESPACE + + + diff --git a/src/3rdparty/phonon/mmf/objectdump.h b/src/3rdparty/phonon/mmf/objectdump.h new file mode 100644 index 0000000..4efc015 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump.h @@ -0,0 +1,164 @@ +/* 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 OBJECTDUMP_H +#define OBJECTDUMP_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +/** + * Abstract base for annotator classes invoked by QVisitor. + */ +class QAnnotator : public QObject +{ + Q_OBJECT +public: + virtual ~QAnnotator(); + virtual QList annotation(const QObject& object) = 0; +}; + +/** + * Annotator which replicates QObject::dumpObjectTree functionality. + */ +class QAnnotatorBasic : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +/** + * Annotator which returns widget information. + */ +class QAnnotatorWidget : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + + +class QDumperPrivate; + +/** + * Class used to dump information about individual QObjects. + */ +class QDumper : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDumper) + +public: + QDumper(); + ~QDumper(); + + /** + * Specify a prefix, to be printed on each line of output. + */ + void setPrefix(const QString& prefix); + + /** + * Takes ownership of annotator. + */ + void addAnnotator(QAnnotator* annotator); + + /** + * Invoke each annotator on the object and write to debug output. + */ + void dumpObject(const QObject& object); + +private: + QScopedPointer d_ptr; + +}; + + +class QVisitorPrivate; + +/** + * Visitor class which dumps information about nodes in the object tree. + */ +class QVisitor : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QVisitor) + +public: + QVisitor(); + ~QVisitor(); + + /** + * Specify a prefix, to be printed on each line of output. + */ + void setPrefix(const QString& prefix); + + /** + * Set number of spaces by which each level of the tree is indented. + */ + void setIndent(unsigned indent); + + /** + * Called by the visitor algorithm before starting the visit. + */ + void visitPrepare(); + + /** + * Called by the visitor algorithm as each node is visited. + */ + void visitNode(const QObject& object); + + /** + * Called by the visitor algorithm when the visit is complete. + */ + void visitComplete(); + + /** + * Takes ownership of annotator. + */ + void addAnnotator(QAnnotator* annotator); + +private: + QScopedPointer d_ptr; + +}; + + +//----------------------------------------------------------------------------- +// Utility functions +//----------------------------------------------------------------------------- + +void addDefaultAnnotators(QDumper& dumper); +void addDefaultAnnotators(QVisitor& visitor); + +void dumpTreeFromRoot(const QObject& root, QVisitor& visitor); +void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor); +void dumpAncestors(const QObject& leaf, QVisitor& visitor); + +} // namespace ObjectDump + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/objectdump_symbian.cpp new file mode 100644 index 0000000..54ebc55 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump_symbian.cpp @@ -0,0 +1,129 @@ +/* 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 "objectdump_symbian.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ +namespace Symbian +{ + +QList QAnnotatorControl::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + const CCoeControl* control = widget->effectiveWinId(); + if(control) { + + QByteArray array; + QTextStream stream(&array); + + stream << "control: " << control << ' '; + stream << "parent " << control->Parent() << ' '; + + if(control->IsVisible()) + stream << "visible "; + else + stream << "invisible "; + + stream << control->Position().iX << ',' << control->Position().iY << ' '; + stream << control->Size().iWidth << 'x' << control->Size().iHeight; + + if(control->OwnsWindow()) + stream << " ownsWindow "; + + stream.flush(); + result.append(array); + } + } + + return result; +} + +QList QAnnotatorWindow::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + const CCoeControl* control = widget->effectiveWinId(); + if(control) { + + RDrawableWindow& window = *(control->DrawableWindow()); + + QByteArray array; + QTextStream stream(&array); + + stream << "window: "; + + // Client-side window handle + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "cli " << reinterpret_cast(window.ClientHandle()) << ' '; + + // Server-side address of CWsWindow object + // This is useful for correlation with the window tree dumped by the window + // server (see RWsSession::LogCommand). + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "srv " << reinterpret_cast(window.WsHandle()) << ' '; + + stream << "group " << window.WindowGroupId() << ' '; + + // Client-side handle to the parent window. + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "parent " << reinterpret_cast(window.Parent()) << ' '; + + stream << window.Position().iX << ',' << window.Position().iY << ' '; + stream << '(' << window.AbsPosition().iX << ',' << window.AbsPosition().iY << ") "; + stream << window.Size().iWidth << 'x' << window.Size().iHeight; + + stream.flush(); + result.append(array); + } + } + + return result; +} + +} // namespace Symbian + +void addDefaultAnnotators_sys(QDumper& dumper) +{ + dumper.addAnnotator(new Symbian::QAnnotatorControl); + dumper.addAnnotator(new Symbian::QAnnotatorWindow); +} + +void addDefaultAnnotators_sys(QVisitor& visitor) +{ + visitor.addAnnotator(new Symbian::QAnnotatorControl); + visitor.addAnnotator(new Symbian::QAnnotatorWindow); +} + +} // namespace ObjectDump + +QT_END_NAMESPACE + + diff --git a/src/3rdparty/phonon/mmf/objectdump_symbian.h b/src/3rdparty/phonon/mmf/objectdump_symbian.h new file mode 100644 index 0000000..26ab308 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump_symbian.h @@ -0,0 +1,56 @@ +/* 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 OBJECTDUMP_SYMBIAN_H +#define OBJECTDUMP_SYMBIAN_H + +#include "objectdump.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ +namespace Symbian +{ + +/** + * Annotator which returns control information + */ +class QAnnotatorControl : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +/** + * Annotator which returns window information + */ +class QAnnotatorWindow : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +} // namespace Symbian +} // namespace ObjectDump + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/objecttree.cpp b/src/3rdparty/phonon/mmf/objecttree.cpp new file mode 100644 index 0000000..f9d1c93 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objecttree.cpp @@ -0,0 +1,102 @@ +/* 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 "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectTree +{ + +DepthFirstConstIterator::DepthFirstConstIterator() + : m_pointee(NULL) +{ + +} + +DepthFirstConstIterator::DepthFirstConstIterator + (const QObject& root) + : m_pointee(&root) +{ + +} + +DepthFirstConstIterator& + DepthFirstConstIterator::operator++() +{ + const QObjectList& children = m_pointee->children(); + + if (children.count() == 0) { + backtrack(); + } + else { + m_history.push(0); + m_pointee = children.first(); + } + + return *this; +} + +void DepthFirstConstIterator::backtrack() +{ + if (m_history.count()) { + const int index = m_history.top(); + m_history.pop(); + + const QObjectList& siblings = m_pointee->parent()->children(); + if (siblings.count() > index + 1) { + m_history.push(index + 1); + m_pointee = siblings[index + 1]; + } + else { + m_pointee = m_pointee->parent(); + backtrack(); + } + } + else { + // Reached end of search + m_pointee = NULL; + } +} + + + +AncestorConstIterator::AncestorConstIterator() +{ + +} + +AncestorConstIterator::AncestorConstIterator(const QObject& leaf) +{ + m_ancestors.push(&leaf); + QObject* ancestor = leaf.parent(); + while(ancestor) + { + m_ancestors.push(ancestor); + ancestor = ancestor->parent(); + } +} + +} // namespace ObjectTree + +QT_END_NAMESPACE + + + diff --git a/src/3rdparty/phonon/mmf/objecttree.h b/src/3rdparty/phonon/mmf/objecttree.h new file mode 100644 index 0000000..0c2031d --- /dev/null +++ b/src/3rdparty/phonon/mmf/objecttree.h @@ -0,0 +1,115 @@ +/* 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 OBJECTTREE_H +#define OBJECTTREE_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace ObjectTree +{ + +/** + * Depth-first iterator for QObject tree + */ +class DepthFirstConstIterator +{ +public: + DepthFirstConstIterator(); + DepthFirstConstIterator(const QObject& root); + + DepthFirstConstIterator& operator++(); + + inline bool operator==(const DepthFirstConstIterator& other) const + { return other.m_pointee == m_pointee; } + + inline bool operator!=(const DepthFirstConstIterator& other) const + { return other.m_pointee != m_pointee; } + + inline const QObject* operator->() const { return m_pointee; } + inline const QObject& operator*() const { return *m_pointee; } + +private: + void backtrack(); + +private: + const QObject* m_pointee; + QStack m_history; +}; + +/** + * Ancestor iterator for QObject tree + */ +class AncestorConstIterator +{ +public: + AncestorConstIterator(); + AncestorConstIterator(const QObject& root); + + inline AncestorConstIterator& operator++() + { m_ancestors.pop(); return *this; } + + inline bool operator==(const AncestorConstIterator& other) const + { return other.m_ancestors == m_ancestors; } + + inline bool operator!=(const AncestorConstIterator& other) const + { return other.m_ancestors != m_ancestors; } + + inline const QObject* operator->() const { return m_ancestors.top(); } + inline const QObject& operator*() const { return *m_ancestors.top(); } + +private: + QStack m_ancestors; + +}; + +/** + * Generic algorithm for visiting nodes in an object tree. Nodes in the + * tree are visited in a const context, therefore they are not modified + * by this algorithm. + * + * Visitor must provide functions with the following signatures: + * + * Called before visit begins + * void visitPrepare() + * + * Called on each node visited + * void visitNode(const QObject& object) + * + * Called when visit is complete + * void visitComplete() + */ +template +void visit(Iterator begin, Iterator end, Visitor& visitor) +{ + visitor.visitPrepare(); + + for( ; begin != end; ++begin) + visitor.visitNode(*begin); + + visitor.visitComplete(); +} + +} // namespace ObjectTree + +QT_END_NAMESPACE + +#endif // OBJECTTREE_H diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index c517c22..2544a97 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -20,6 +20,10 @@ along with this library. If not, see . #include "videooutput.h" #include "videooutputobserver.h" +#ifdef _DEBUG +#include "objectdump.h" +#endif + #include #include #include @@ -48,59 +52,10 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) setAutoFillBackground(false); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET -#ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT dump(); -#endif - - TRACE_EXIT_0(); -} - -#ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT -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; - 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) { - 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() { @@ -144,8 +99,6 @@ 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); @@ -153,7 +106,6 @@ QSize MMF::VideoOutput::sizeHint() const result = m_frameSize; } - TRACE(" result %d %d", result.width(), result.height()); return result; } @@ -166,6 +118,8 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) TRACE("regions %d", event->region().numRects()); TRACE("type %d", event->type()); + dump(); + /* QPainter painter; painter.begin(this); @@ -208,6 +162,19 @@ void MMF::VideoOutput::moveEvent(QMoveEvent* event) // Private functions //----------------------------------------------------------------------------- +void VideoOutput::dump() const +{ +#ifdef _DEBUG + TRACE_CONTEXT(VideoOutput::dump, EVideoInternal); + QScopedPointer visitor(new ObjectDump::QVisitor); + visitor->setPrefix("Phonon::MMF"); // to aid searchability of logs + ObjectDump::addDefaultAnnotators(*visitor); + TRACE("Dumping tree from leaf 0x%08x:", this); + //ObjectDump::dumpAncestors(*this, *visitor); + ObjectDump::dumpTreeFromLeaf(*this, *visitor); +#endif +} + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index bcd9cb4..566d065 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -50,11 +50,9 @@ protected: void moveEvent(QMoveEvent* event); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET -#ifdef PHONON_MMF_DEBUG_VIDEO_OUTPUT -public: - void dump(); -#endif - +private: + void dump() const; + private: QSize m_frameSize; diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 736d74f..a73c6ec 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -26,6 +26,10 @@ along with this library. If not, see . #include "videoplayer.h" #include "utils.h" +#ifdef _DEBUG +#include "objectdump.h" +#endif + QT_BEGIN_NAMESPACE using namespace Phonon; @@ -398,10 +402,17 @@ void MMF::VideoPlayer::videoOutputChanged() void MMF::VideoPlayer::getNativeWindowSystemHandles() { TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); + TRACE_ENTRY_0(); VideoOutput& output = videoOutput(); CCoeControl* const control = output.winId(); - + + CCoeEnv* const coeEnv = control->ControlEnv(); + m_wsSession = &(coeEnv->WsSession()); + m_screenDevice = coeEnv->ScreenDevice(); + m_window = control->DrawableWindow(); + +/* TRACE("control 0x%08x", control); TRACE("control IsVisible %d", control->IsVisible()); TRACE("control IsDimmed %d", control->IsDimmed()); @@ -434,6 +445,15 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() m_window->AbsPosition().iX, m_window->AbsPosition().iY); TRACE("window Size %d %d", m_window->Size().iWidth, m_window->Size().iHeight); +*/ + +#ifdef _DEBUG + QScopedPointer dumper(new ObjectDump::QDumper); + dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs + ObjectDump::addDefaultAnnotators(*dumper); + TRACE_0("Dumping VideoOutput:"); + dumper->dumpObject(output); +#endif #ifdef PHONON_MMF_HARD_CODE_VIDEO_RECT // HACK: why isn't control->Rect updated following a call to @@ -455,6 +475,8 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() TRACE("clipRect %d %d - %d %d", m_clipRect.iTl.iX, m_clipRect.iTl.iY, m_clipRect.iBr.iX, m_clipRect.iBr.iY); + + TRACE_EXIT_0(); } diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 1d9910b..56cc37a 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -49,6 +49,21 @@ SOURCES += \ $$PHONON_MMF_DIR/videooutput.cpp \ $$PHONON_MMF_DIR/videoplayer.cpp \ $$PHONON_MMF_DIR/videowidget.cpp + +# This is not mmfphonon-specific, and should be factored out into a separate +# library (QtCore?) at a later date +debug { +HEADERS += \ + $$PHONON_MMF_DIR/objectdump.h \ + $$PHONON_MMF_DIR/objectdump_symbian.h \ + $$PHONON_MMF_DIR/objecttree.h + +SOURCES += \ + $$PHONON_MMF_DIR/objectdump.cpp \ + $$PHONON_MMF_DIR/objectdump_symbian.cpp \ + $$PHONON_MMF_DIR/objecttree.cpp + +} LIBS += -lmediaclientvideo.lib # For CVideoPlayerUtility LIBS += -lcone.lib # For CCoeEnv -- cgit v0.12 From 3bcdd19ed5dc0328951c8cd917c4ae766a329f11 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 2 Sep 2009 17:49:43 +0100 Subject: Added logging to QWidgetPrivate and QSymbianControl --- src/gui/kernel/qapplication_s60.cpp | 42 ++++++- src/gui/kernel/qwidget_s60.cpp | 213 ++++++++++++++++++++++++++++++++++-- 2 files changed, 240 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 67b974e..765a1c1 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -70,6 +70,11 @@ #include "private/qstylesheetstyle_p.h" +#ifdef _DEBUG +#define DEBUG_QSYMBIANCONTROL +#include +#endif + QT_BEGIN_NAMESPACE #if defined(QT_DEBUG) @@ -330,6 +335,12 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) */ CreateWindowL(qwidget->parentWidget()->winId()); +#ifdef DEBUG_QSYMBIANCONTROL + qDebug() << "QSymbianControl::ConstructL [" << this + << "] widget" << qwidget + << "control" << qwidget->winId(); +#endif + // Necessary in order to be able to track the activation status of // the control's window qwidget->d_func()->createTLExtra(); @@ -606,12 +617,19 @@ TCoeInputCapabilities QSymbianControl::InputCapabilities() const void QSymbianControl::Draw(const TRect& r) const { QWindowSurface *surface = qwidget->windowSurface(); - if (!surface) - return; - - QPaintEngine *engine = surface->paintDevice()->paintEngine(); + QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; + +#ifdef DEBUG_QSYMBIANCONTROL + qDebug() << "QSymbianControl::Draw [" << this << "]" + << "rect " << r.iTl.iX << ',' << r.iTl.iY + << '-' << r.iBr.iX << ',' << r.iBr.iY + << "surface" << surface + << "engine" << engine; +#endif + if (!engine) return; + if (engine->type() == QPaintEngine::Raster) { QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); CFbsBitmap *bitmap = s60Surface->symbianBitmap(); @@ -625,12 +643,18 @@ void QSymbianControl::Draw(const TRect& r) const } void QSymbianControl::SizeChanged() -{ +{ CCoeControl::SizeChanged(); QSize oldSize = qwidget->size(); QSize newSize(Size().iWidth, Size().iHeight); +#ifdef DEBUG_QSYMBIANCONTROL + qDebug() << "QSymbianControl::SizeChanged [" << this << "]" + << oldSize.width() << 'x' << oldSize.height() + << "-" << newSize.width() << 'x' << newSize.height(); +#endif + if (oldSize != newSize) { QRect cr = qwidget->geometry(); cr.setSize(newSize); @@ -656,7 +680,13 @@ void QSymbianControl::PositionChanged() QPoint oldPos = qwidget->geometry().topLeft(); QPoint newPos(Position().iX, Position().iY); - + +#ifdef DEBUG_QSYMBIANCONTROL + qDebug() << "QSymbianControl::SizeChanged [" << this << "]" + << oldPos.x() << ',' << oldPos.y() + << "-" << newPos.x() << ',' << newPos.y(); +#endif + if (oldPos != newPos) { QRect cr = qwidget->geometry(); cr.moveTopLeft(newPos); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index a516266..210aff5 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -56,6 +56,11 @@ #include #endif +#ifdef _DEBUG +#define DEBUG_QWIDGET +#include +#endif + QT_BEGIN_NAMESPACE extern bool qt_nograb(); @@ -158,6 +163,12 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) static const int WRECT_MAX = 16383; Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "]" + << "q" << q; +#endif + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); /* @@ -203,6 +214,14 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) xrect = data.wrect; xrect.translate(data.crect.topLeft()); if (data.winid) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (1)" + << "control" << data.winid + << "SetExtent" << xrect.x() << ',' << xrect.y() + << xrect.width() << 'x' << xrect.height(); +#endif + data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); data.winid->DrawNow(); } @@ -227,8 +246,16 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) if (q->testAttribute(Qt::WA_OutsideWSRange) != outsideRange) { q->setAttribute(Qt::WA_OutsideWSRange, outsideRange); if (outsideRange) { - if (data.winid) + if (data.winid) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (2)" + << "control" << data.winid + << "SetVisible(EFalse)"; +#endif + data.winid->DrawableWindow()->SetVisible(EFalse); + } q->setAttribute(Qt::WA_Mapped, false); } else if (!q->isHidden()) { mapWindow = true; @@ -248,8 +275,16 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) QObject *object = children.at(i); if (object->isWidgetType()) { QWidget *w = static_cast(object); - if (!w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) + if (!w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (3)" + << "control" << data.winid + << "child" << w->d_func(); +#endif + w->d_func()->setWSGeometry(jump); + } } } @@ -259,9 +294,25 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) // than moving mapped windows if (!parent->internalWinId()) xrect.translate(parent->mapTo(q->nativeParentWidget(), QPoint(0, 0))); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (4)" + << "control" << data.winid + << "SetExtent" << xrect.x() << ',' << xrect.y() + << xrect.width() << 'x' << xrect.height(); +#endif + data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); - if(!jump) + if(!jump) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (5)" + << "control" << data.winid + << "DrawNow"; +#endif + data.winid->DrawNow(); + } } //to avoid flicker, we have to show children after the helper widget has moved @@ -272,26 +323,57 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) 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()) + if (w->internalWinId()) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (6)" + << "control" << data.winid + << "SetVisible(ETrue)"; +#endif + w->data->winid->DrawableWindow()->SetVisible(ETrue); + } } } } } - if (jump && data.winid) + if (jump && data.winid) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (7)" + << "control" << data.winid + << "DrawNow" << wrect.width() << 'x' << wrect.height(); +#endif + data.winid->DrawNow(TRect(0, 0, wrect.width(), wrect.height())); + } if (mapWindow and !dontShow) { q->setAttribute(Qt::WA_Mapped); - if (q->internalWinId()) + if (q->internalWinId()) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (8)" + << "control" << data.winid + << "SetVisible(ETrue)"; +#endif + q->internalWinId()->DrawableWindow()->SetVisible(ETrue); + } } } void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "]" + << "q" << q + << x << ',' << y << w << 'x' << h << isMove; +#endif + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if ((q->windowType() == Qt::Desktop)) @@ -325,13 +407,25 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if(q->isWindow()) { if (w == 0 || h == 0) { q->setAttribute(Qt::WA_OutsideWSRange, true); - if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) + if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (1)" + << "hide"; +#endif + hide_sys(); + } data.crect = QRect(x, y, w, h); data.window_state &= ~Qt::WindowFullScreen; } else if (q->isVisible() && q->testAttribute(Qt::WA_OutsideWSRange)) { q->setAttribute(Qt::WA_OutsideWSRange, false); +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (2)" + << "SetRect, show"; +#endif + // put the window in its place and show it q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); data.crect.setRect(x, y, w, h); @@ -340,6 +434,12 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) } else { QRect r = QRect(x, y, w, h); data.crect = r; + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (3)" + << "SetRect"; +#endif + q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); topData()->normalGeometry = data.crect; } @@ -362,8 +462,15 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (inTopLevelResize) tlwExtra->inTopLevelResize = true; } - if (q->testAttribute(Qt::WA_WState_Created)) - setWSGeometry(); + if (q->testAttribute(Qt::WA_WState_Created)) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (4)" + << "setWSGeometry"; +#endif + + setWSGeometry(); + } } if (q->isVisible()) { @@ -408,6 +515,19 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de bool desktop = (type == Qt::Desktop); //bool tool = (type == Qt::Tool || type == Qt::Drawer); +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::create_sys [" << this << "] " + << "q" << q; + qDebug() << "QWidgetPrivate::create_sys [" << this << "] " + << "type" << type + << "flags" << flags + << "parent" << parentWidget + << "topLevel" << topLevel + << "popup" << popup + << "dialog" << dialog + << "desktop" << desktop; +#endif + WId id = 0; if (popup) @@ -508,6 +628,11 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de void QWidgetPrivate::show_sys() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::show_sys [" << this << "] " + << "q" << q; +#endif if (q->testAttribute(Qt::WA_OutsideWSRange)) return; @@ -525,6 +650,14 @@ void QWidgetPrivate::show_sys() WId id = q->internalWinId(); if (!extra->topextra->activated) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::show_sys [" << this << "]" + << "id" << id + << "isWindow" << q->isWindow() + << "ActivateL"; +#endif + QT_TRAP_THROWING(id->ActivateL()); extra->topextra->activated = 1; } @@ -546,10 +679,23 @@ void QWidgetPrivate::show_sys() void QWidgetPrivate::hide_sys() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::hide_sys [" << this << "]" + << "q" << q; +#endif + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); deactivateWidgetCleanup(); WId id = q->internalWinId(); if (id) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::show_sys [" << this << "]" + << "id" << id + << "MakeVisible(false)"; +#endif + if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged() id->SetFocus(false); id->MakeVisible(false); @@ -574,6 +720,13 @@ void QWidgetPrivate::handleSymbianDeferredFocusChanged() { Q_Q(QWidget); WId control = q->internalWinId(); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::handleSymbianDeferredFocusChanged [" << this << "]" + << "q" << q + << "control" << control; +#endif + if (!control) { // This could happen if the widget was reparented, while the focuschange // was in the event queue. @@ -601,6 +754,12 @@ void QWidgetPrivate::handleSymbianDeferredFocusChanged() void QWidgetPrivate::raise_sys() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::raise_sys [" << this << "]" + << "q" << q; +#endif + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); QTLWExtra *tlwExtra = maybeTopData(); if (q->internalWinId() && tlwExtra) { @@ -611,6 +770,12 @@ void QWidgetPrivate::raise_sys() void QWidgetPrivate::lower_sys() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::lower_sys [" << this << "]" + << "q" << q; +#endif + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); QTLWExtra *tlwExtra = maybeTopData(); if (q->internalWinId() && tlwExtra) { @@ -640,6 +805,12 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) void QWidgetPrivate::reparentChildren() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::reparentChildren [" << this << "]" + << "q" << q; +#endif + QObjectList chlist = q->children(); for (int i = 0; i < chlist.size(); ++i) { // reparent children QObject *obj = chlist.at(i); @@ -670,6 +841,14 @@ void QWidgetPrivate::reparentChildren() void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setParent_sys [" << this << "]" + << "q" << q + << "parent" << parent + << "f" << f; +#endif + bool wasCreated = q->testAttribute(Qt::WA_WState_Created); if (q->isVisible() && q->parentWidget() && parent != q->parentWidget()) @@ -732,6 +911,11 @@ void QWidgetPrivate::setConstraints_sys() void QWidgetPrivate::s60UpdateIsOpaque() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::s60UpdateIsOpaque [" << this << "]" + << "q" << q; +#endif if (!q->testAttribute(Qt::WA_WState_Created) || !q->testAttribute(Qt::WA_TranslucentBackground)) return; @@ -1116,6 +1300,12 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const void QWidget::setWindowState(Qt::WindowStates newstate) { Q_D(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidget::setWindowState [" << this << "]" + << "newstate" << newstate; +#endif + Qt::WindowStates oldstate = windowState(); if (oldstate == newstate) return; @@ -1329,6 +1519,11 @@ void QWidget::releaseMouse() void QWidget::activateWindow() { Q_D(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidget::activateWindow [" << this << "]"; +#endif + QWidget *tlw = window(); if (tlw->isVisible()) { S60->windowGroup().SetOrdinalPosition(0); -- cgit v0.12 From 6705f143db308fb10dfc09988bc15874eebb75a8 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 2 Sep 2009 18:28:37 +0100 Subject: Added macros to QtGui for controlling whether widgets are window-owning There are two macros defined in src/gui/kernel/window_owning_control.h: If this is defined, then calling QWidget::winId causes a native window to be created for the associated control If QWIDGET_OWNS_WINDOW is defined, defining this macro means that the parent window for the newly created window is the parent widget's winId. This in turn means that calling QWidget::winId causes native windows to be created for all ancestors of the target widget. If this macro is undefined, the parent window is the parent widget's effectiveWinId. --- src/gui/kernel/qapplication_s60.cpp | 25 ++++++++++++--- src/gui/kernel/qwidget_s60.cpp | 18 ++++++++++- src/gui/kernel/symbian.pri | 2 ++ src/gui/kernel/window_owning_control.h | 57 ++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 src/gui/kernel/window_owning_control.h diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 765a1c1..2a71073 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -75,6 +75,8 @@ #include #endif +#include "window_owning_control.h" + QT_BEGIN_NAMESPACE #if defined(QT_DEBUG) @@ -322,6 +324,7 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) { if (!desktop) { +#ifdef QWIDGET_OWNS_WINDOW if (topLevel or !qwidget->parentWidget()) CreateWindowL(S60->windowGroup()); else @@ -333,18 +336,30 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) * 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. */ + #ifdef QWIDGET_IMMEDIATE_WINDOW_PARENT CreateWindowL(qwidget->parentWidget()->winId()); + #else + CreateWindowL(qwidget->parentWidget()->effectiveWinId()); + #endif // QWIDGET_IMMEDIATE_WINDOW_PARENT + + // Necessary in order to be able to track the activation status of + // the control's window + qwidget->d_func()->createTLExtra(); +#else + if (topLevel) + CreateWindowL(S60->windowGroup()); +#endif // QWIDGET_OWNS_WINDOW #ifdef DEBUG_QSYMBIANCONTROL qDebug() << "QSymbianControl::ConstructL [" << this << "] widget" << qwidget - << "control" << qwidget->winId(); + << "topLevel" << topLevel + << "parentWidget" << qwidget->parentWidget() + << "OwnsWindow" << OwnsWindow() + << "Window.ClientHandle" << reinterpret_cast(DrawableWindow()->ClientHandle()) + << "WindowGroupId" << DrawableWindow()->WindowGroupId(); #endif - // 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 210aff5..28ce90e 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -61,6 +61,8 @@ #include #endif +#include "window_owning_control.h" + QT_BEGIN_NAMESPACE extern bool qt_nograb(); @@ -612,6 +614,11 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); +#ifndef QWIDGET_OWNS_WINDOW + WId parentw = parentWidget->effectiveWinId(); + QT_TRAP_THROWING(control->SetContainerWindowL(*parentw)); +#endif + q->setAttribute(Qt::WA_WState_Created); int x, y, w, h; data.crect.getRect(&x, &y, &w, &h); @@ -646,8 +653,12 @@ void QWidgetPrivate::show_sys() return; } +#ifdef QWIDGET_OWNS_WINDOW if (q->internalWinId()) { - +#else + if (q->isWindow() && q->internalWinId()) { +#endif + WId id = q->internalWinId(); if (!extra->topextra->activated) { @@ -688,7 +699,12 @@ void QWidgetPrivate::hide_sys() Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); deactivateWidgetCleanup(); WId id = q->internalWinId(); + +#ifdef QWIDGET_OWNS_WINDOW if (id) { +#else + if (q->isWindow() && id) { +#endif #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::show_sys [" << this << "]" diff --git a/src/gui/kernel/symbian.pri b/src/gui/kernel/symbian.pri index d267a53..87d8492 100644 --- a/src/gui/kernel/symbian.pri +++ b/src/gui/kernel/symbian.pri @@ -1,3 +1,5 @@ symbian { + HEADERS += window_owning_control.h + contains(QT_CONFIG, s60): LIBS+= $$QMAKE_LIBS_S60 } diff --git a/src/gui/kernel/window_owning_control.h b/src/gui/kernel/window_owning_control.h new file mode 100644 index 0000000..af192f3 --- /dev/null +++ b/src/gui/kernel/window_owning_control.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WINDOW_OWNING_CONTROL_H +#define WINDOW_OWNING_CONTROL_H + +// If this is defined, then calling QWidget::winId causes a native window to +// be created for the associated control +#define QWIDGET_OWNS_WINDOW + +// If QWIDGET_OWNS_WINDOW is defined, defining this macro means that the +// parent window for the newly created window is the parent widget's winId. +// This in turn means that calling QWidget::winId causes native windows to +// be created for all ancestors of the target widget. +// If this macro is undefined, the parent window is the parent widget's +// effectiveWinId. +#define QWIDGET_IMMEDIATE_WINDOW_PARENT + +#endif // WINDOW_OWNING_CONTROL_H -- cgit v0.12 From 7823dc43b85c3d1dd2f3ba10d0e7efbd83888059 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 2 Sep 2009 18:48:36 +0100 Subject: Added a macro for setting video output region to null This is useful when debugging problems with the interaction between video rendering, Qt widget rendering and the underlying native control / window system. --- src/3rdparty/phonon/mmf/defs.h | 4 +++ src/3rdparty/phonon/mmf/videoplayer.cpp | 43 +++++---------------------------- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 60f363b..afb25dc 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -34,6 +34,10 @@ along with this library. If not, see . // rect, i.e. QWidget::winId()->Rect() //#define PHONON_MMF_HARD_CODE_VIDEO_RECT +// Hack to make the video invisible. This is used in order to debug +// problems caused by the window-owning control change. +//#define PHONON_MMF_HARD_CODE_VIDEO_RECT_TO_EMPTY + QT_BEGIN_NAMESPACE namespace Phonon diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index a73c6ec..e8b792f 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -412,41 +412,6 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() m_screenDevice = coeEnv->ScreenDevice(); m_window = control->DrawableWindow(); -/* - 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 _DEBUG QScopedPointer dumper(new ObjectDump::QDumper); dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs @@ -460,12 +425,16 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() // updateGeometry on the parent widget? m_windowRect = TRect(0, 100, 320, 250); m_clipRect = m_windowRect; -#else +#else m_windowRect = TRect( control->DrawableWindow()->AbsPosition(), control->DrawableWindow()->Size()); - //m_clipRect = control->Rect(); + m_clipRect = m_windowRect; +#endif + +#ifdef PHONON_MMF_HARD_CODE_VIDEO_RECT_TO_EMPTY + m_windowRect = TRect(0, 0, 0, 0); m_clipRect = m_windowRect; #endif -- cgit v0.12 From ea6b181df68a18044a06063ab33dc6eb35b2aba1 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 3 Sep 2009 11:16:45 +0100 Subject: Modified MediaPlayer to set names on its child QObject instances This is useful for debugging, as it helps to associate nodes in the object tree with the corresponding source code. --- demos/mediaplayer/mediaplayer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/demos/mediaplayer/mediaplayer.cpp b/demos/mediaplayer/mediaplayer.cpp index 5a69e4f..4bbe413 100644 --- a/demos/mediaplayer/mediaplayer.cpp +++ b/demos/mediaplayer/mediaplayer.cpp @@ -152,6 +152,9 @@ MediaPlayer::MediaPlayer(const QString &filePath) : m_AudioOutput(Phonon::VideoCategory), m_videoWidget(new MediaVideoWidget(this)) { + m_videoWindow.setObjectName("videoWindow"); + m_videoWidget->setObjectName("videoWidget"); + setWindowTitle(tr("Media Player")); setContextMenuPolicy(Qt::CustomContextMenu); m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); @@ -159,6 +162,7 @@ MediaPlayer::MediaPlayer(const QString &filePath) : QSize buttonSize(34, 28); QPushButton *openButton = new QPushButton(this); + openButton->setObjectName("openButton"); openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); QPalette bpal; @@ -169,20 +173,25 @@ MediaPlayer::MediaPlayer(const QString &filePath) : openButton->setPalette(bpal); rewindButton = new QPushButton(this); + rewindButton->setObjectName("rewindButton"); rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); forwardButton = new QPushButton(this); + forwardButton->setObjectName("forwardButton"); forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); forwardButton->setEnabled(false); playButton = new QPushButton(this); + playButton->setObjectName("playButton"); playIcon = style()->standardIcon(QStyle::SP_MediaPlay); pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); playButton->setIcon(playIcon); slider = new Phonon::SeekSlider(this); + slider->setObjectName("slider"); slider->setMediaObject(&m_MediaObject); volume = new Phonon::VolumeSlider(&m_AudioOutput); + volume->setObjectName("volume"); QVBoxLayout *vLayout = new QVBoxLayout(this); vLayout->setContentsMargins(8, 8, 8, 8); @@ -190,6 +199,7 @@ MediaPlayer::MediaPlayer(const QString &filePath) : QHBoxLayout *layout = new QHBoxLayout(); info = new QLabel(this); + info->setObjectName("info"); info->setMinimumHeight(70); info->setAcceptDrops(false); info->setMargin(2); @@ -227,8 +237,11 @@ MediaPlayer::MediaPlayer(const QString &filePath) : buttonPanelLayout->addLayout(layout); timeLabel = new QLabel(this); + timeLabel->setObjectName("timeLabel"); progressLabel = new QLabel(this); + progressLabel->setObjectName("progressLabel"); QWidget *sliderPanel = new QWidget(this); + sliderPanel->setObjectName("sliderPanel"); QHBoxLayout *sliderLayout = new QHBoxLayout(); sliderLayout->addWidget(slider); sliderLayout->addWidget(timeLabel); @@ -251,6 +264,7 @@ MediaPlayer::MediaPlayer(const QString &filePath) : // forwardButton->setStyle(flatButtonStyle); #endif QWidget *buttonPanelWidget = new QWidget(this); + buttonPanelWidget->setObjectName("buttonPanelWidget"); buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); buttonPanelWidget->setLayout(buttonPanelLayout); vLayout->addWidget(buttonPanelWidget); -- cgit v0.12 From c5f0fbb0128860f8b4407332875c69a9237de084 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 7 Sep 2009 15:09:57 +0100 Subject: Oops: removed .lib from libraries in mmf.pro so they are now dynamically linked --- src/plugins/phonon/mmf/mmf.pro | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 56cc37a..4496feb 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -9,7 +9,7 @@ PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf #CONFIG += phonon_mmf_audio_drm phonon_mmf_audio_drm { - LIBS += -lDrmAudioPlayUtility.lib + LIBS += -lDrmAudioPlayUtility # In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this # folder, as opposed to the public, where it is placed in @@ -18,7 +18,7 @@ phonon_mmf_audio_drm { DEFINES += QT_PHONON_MMF_AUDIO_DRM } else { - LIBS += -lmediaclientaudio.lib + LIBS += -lmediaclientaudio } HEADERS += \ @@ -65,11 +65,11 @@ SOURCES += \ } -LIBS += -lmediaclientvideo.lib # For CVideoPlayerUtility -LIBS += -lcone.lib # For CCoeEnv -LIBS += -lws32.lib # For RWindow +LIBS += -lmediaclientvideo # For CVideoPlayerUtility +LIBS += -lcone # For CCoeEnv +LIBS += -lws32 # For RWindow LIBS += -lefsrv # For file server -LIBS += -lapgrfx.lib -lapmime.lib # For recognizer +LIBS += -lapgrfx -lapmime # 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 0ad37ee268f4a314ee31e70fc8b4acfc9aa46970 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 7 Sep 2009 16:16:49 +0100 Subject: Refactored object tree dumping framework into a separate DLL --- src/3rdparty/phonon/mmf/objectdump.cpp | 527 --------------------- src/3rdparty/phonon/mmf/objectdump.h | 164 ------- src/3rdparty/phonon/mmf/objectdump/objectdump.cpp | 527 +++++++++++++++++++++ src/3rdparty/phonon/mmf/objectdump/objectdump.h | 166 +++++++ .../phonon/mmf/objectdump/objectdump_global.h | 30 ++ .../phonon/mmf/objectdump/objectdump_stub.cpp | 40 ++ .../phonon/mmf/objectdump/objectdump_symbian.cpp | 129 +++++ .../phonon/mmf/objectdump/objectdump_symbian.h | 56 +++ src/3rdparty/phonon/mmf/objectdump/objecttree.cpp | 102 ++++ src/3rdparty/phonon/mmf/objectdump/objecttree.h | 117 +++++ src/3rdparty/phonon/mmf/objectdump_symbian.cpp | 129 ----- src/3rdparty/phonon/mmf/objectdump_symbian.h | 56 --- src/3rdparty/phonon/mmf/objecttree.cpp | 102 ---- src/3rdparty/phonon/mmf/objecttree.h | 115 ----- src/3rdparty/phonon/mmf/videooutput.cpp | 2 +- src/3rdparty/phonon/mmf/videoplayer.cpp | 2 +- src/plugins/phonon/mmf/mmf.pro | 90 +--- src/plugins/phonon/mmf/objectdump/objectdump.pro | 28 ++ src/plugins/phonon/mmf/plugin/plugin.pro | 79 +++ 19 files changed, 1278 insertions(+), 1183 deletions(-) delete mode 100644 src/3rdparty/phonon/mmf/objectdump.cpp delete mode 100644 src/3rdparty/phonon/mmf/objectdump.h create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump.h create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_global.h create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h create mode 100644 src/3rdparty/phonon/mmf/objectdump/objecttree.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump/objecttree.h delete mode 100644 src/3rdparty/phonon/mmf/objectdump_symbian.cpp delete mode 100644 src/3rdparty/phonon/mmf/objectdump_symbian.h delete mode 100644 src/3rdparty/phonon/mmf/objecttree.cpp delete mode 100644 src/3rdparty/phonon/mmf/objecttree.h create mode 100644 src/plugins/phonon/mmf/objectdump/objectdump.pro create mode 100644 src/plugins/phonon/mmf/plugin/plugin.pro diff --git a/src/3rdparty/phonon/mmf/objectdump.cpp b/src/3rdparty/phonon/mmf/objectdump.cpp deleted file mode 100644 index 50c6bf8..0000000 --- a/src/3rdparty/phonon/mmf/objectdump.cpp +++ /dev/null @@ -1,527 +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 -#include - -#include "objectdump.h" -#include "objecttree.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ - -//----------------------------------------------------------------------------- -// QObjectAnnotator -//----------------------------------------------------------------------------- - -QAnnotator::~QAnnotator() -{ - -} - - -//----------------------------------------------------------------------------- -// Annotators -//----------------------------------------------------------------------------- - -QList QAnnotatorBasic::annotation(const QObject& object) -{ - QList result; - - QByteArray array; - QTextStream stream(&array); - - stream << '[' << &object << ']'; - stream << ' '; - stream << object.metaObject()->className(); - - if(object.objectName() != "") - stream << " \"" << object.objectName() << '"'; - - if(object.isWidgetType()) - stream << " isWidget"; - - stream.flush(); - result.append(array); - return result; -} - -QList QAnnotatorWidget::annotation(const QObject& object) -{ - QList result; - - const QWidget* widget = qobject_cast(&object); - if(widget) { - - QByteArray array; - QTextStream stream(&array); - - stream << "widget: "; - - if(widget->isVisible()) - stream << "visible "; - else - stream << "invisible "; - - stream << widget->x() << ',' << widget->y() << ' '; - stream << widget->size().width() << 'x'<< widget->size().height() << ' '; - - stream << "hint " << widget->sizeHint().width() << 'x' << widget->sizeHint().height(); - - stream.flush(); - result.append(array); - } - - return result; -} - - -//----------------------------------------------------------------------------- -// Base class for QDumperPrivate, QVisitorPrivate -//----------------------------------------------------------------------------- - -class QDumperBase -{ -public: - QDumperBase(); - ~QDumperBase(); - - void setPrefix(const QString& prefix); - void addAnnotator(QAnnotator* annotator); - -protected: - QByteArray m_prefix; - QList m_annotators; - -}; - -QDumperBase::QDumperBase() -{ - -} - -QDumperBase::~QDumperBase() -{ - QAnnotator* annotator; - foreach(annotator, m_annotators) - delete annotator; -} - -void QDumperBase::setPrefix(const QString& prefix) -{ - m_prefix = prefix.count() - ? (prefix + " ").toAscii() - : prefix.toAscii(); -} - -void QDumperBase::addAnnotator(QAnnotator* annotator) -{ - // Protect against an exception occurring during QList::append - QScopedPointer holder(annotator); - m_annotators.append(annotator); - holder.take(); -} - - -//----------------------------------------------------------------------------- -// QDumper -//----------------------------------------------------------------------------- - -class QDumperPrivate : public QDumperBase -{ -public: - QDumperPrivate(); - ~QDumperPrivate(); - - void dumpObject(const QObject& object); - -}; - - -QDumperPrivate::QDumperPrivate() -{ - -} - -QDumperPrivate::~QDumperPrivate() -{ - -} - -void QDumperPrivate::dumpObject(const QObject& object) -{ - QAnnotator* annotator; - foreach(annotator, m_annotators) { - - const QList annotations = annotator->annotation(object); - QByteArray annotation; - foreach(annotation, annotations) { - QByteArray buffer(m_prefix); - buffer.append(annotation); - qDebug() << buffer.constData(); - } - } -} - - -QDumper::QDumper() - : d_ptr(new QDumperPrivate) -{ - -} - -QDumper::~QDumper() -{ - -} - -void QDumper::setPrefix(const QString& prefix) -{ - d_func()->setPrefix(prefix); -} - -void QDumper::addAnnotator(QAnnotator* annotator) -{ - d_func()->addAnnotator(annotator); -} - -void QDumper::dumpObject(const QObject& object) -{ - d_func()->dumpObject(object); -} - - -//----------------------------------------------------------------------------- -// QVisitor -//----------------------------------------------------------------------------- - -class QVisitorPrivate : public QDumperBase -{ -public: - QVisitorPrivate(); - ~QVisitorPrivate(); - - void setIndent(unsigned indent); - - void visitNode(const QObject& object); - void visitComplete(); - -private: - class Node - { - public: - Node(); - ~Node(); - - QList m_annotation; - QList m_children; - - typedef QList::const_iterator child_iterator; - }; - -private: - Node* findNode(const QObject* object) const; - QByteArray branchBuffer(const QList& branches, bool isNodeLine, bool isLastChild) const; - void dumpRecursive(const Node& node, QList branches, bool isLastChild); - void dumpNode(const Node& node, const QList& branches, bool isLastChild); - -private: - unsigned m_indent; - - QScopedPointer m_root; - - // Hash table used to associate internal nodes with QObjects - typedef QHash Hash; - Hash m_hash; -}; - -static const unsigned DefaultIndent = 2; - -QVisitorPrivate::QVisitorPrivate() - : m_indent(DefaultIndent) -{ - -} - -QVisitorPrivate::~QVisitorPrivate() -{ - -} - -void QVisitorPrivate::setIndent(unsigned indent) -{ - m_indent = indent; -} - -// Builds up a mirror of the object tree, rooted in m_root, with each node -// storing annotations generated by -void QVisitorPrivate::visitNode(const QObject& object) -{ - QObject* const objectParent = object.parent(); - Node* const nodeParent = objectParent ? findNode(objectParent) : NULL; - - // Create a new node and store in scoped pointer for exception safety - Node* node = new Node; - QScopedPointer nodePtr(node); - - // Associate node with QObject - m_hash.insert(&object, node); - - // Insert node into internal tree - if(nodeParent) - { - nodeParent->m_children.append(nodePtr.take()); - } - else - { - Q_ASSERT(m_root.isNull()); - m_root.reset(nodePtr.take()); - } - - // Generate and store annotations - QAnnotator* annotator; - foreach(annotator, m_annotators) - node->m_annotation.append( annotator->annotation(object) ); -} - -void QVisitorPrivate::visitComplete() -{ - QList branches; - static const bool isLastChild = true; - dumpRecursive(*m_root, branches, isLastChild); - m_root.reset(NULL); -} - -QVisitorPrivate::Node* QVisitorPrivate::findNode(const QObject* object) const -{ - Hash::const_iterator i = m_hash.find(object); - return (m_hash.end() == i) ? NULL : *i; -} - -QByteArray QVisitorPrivate::branchBuffer - (const QList& branches, bool isNodeLine, bool isLastChild) const -{ - const int depth = branches.count(); - - const QByteArray indent(m_indent, ' '); - const QByteArray horiz(m_indent, '-'); - - QByteArray buffer; - QTextStream stream(&buffer); - - for (int i=0; i branches, bool isLastChild) -{ - dumpNode(node, branches, isLastChild); - - // Recurse down tree - const Node::child_iterator begin = node.m_children.begin(); - const Node::child_iterator end = node.m_children.end(); - for(Node::child_iterator i = begin; end != i; ++i) { - - isLastChild = (end == i + 1); - - if(begin == i) - branches.push_back(!isLastChild); - else - branches.back() = !isLastChild; - - static const bool isNodeLine = false; - const QByteArray buffer = branchBuffer(branches, isNodeLine, false); - qDebug() << buffer.constData(); - - dumpRecursive(**i, branches, isLastChild); - } -} - -void QVisitorPrivate::dumpNode - (const Node& node, const QList& branches, bool isLastChild) -{ - const QList::const_iterator - begin = node.m_annotation.begin(), end = node.m_annotation.end(); - - if(begin == end) { - // No annotations - just dump the object pointer - const bool isNodeLine = true; - QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); - qDebug() << NULL; // TODO - } - else { - // Dump annotations - for(QList::const_iterator i = begin; end != i; ++i) { - const bool isNodeLine = (begin == i); - QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); - buffer.append(*i); - qDebug() << buffer.constData(); - } - } -} - - -// QVisitorPrivate::Node - -QVisitorPrivate::Node::Node() -{ - -} - -QVisitorPrivate::Node::~Node() -{ - Node* child; - foreach(child, m_children) - delete child; -} - - -// QVisitor - -QVisitor::QVisitor() - : d_ptr(new QVisitorPrivate) -{ - -} - -QVisitor::~QVisitor() -{ - -} - -void QVisitor::setPrefix(const QString& prefix) -{ - d_func()->setPrefix(prefix); -} - -void QVisitor::setIndent(unsigned indent) -{ - d_func()->setIndent(indent); -} - -void QVisitor::addAnnotator(QAnnotator* annotator) -{ - d_func()->addAnnotator(annotator); -} - -void QVisitor::visitPrepare() -{ - // Do nothing -} - -void QVisitor::visitNode(const QObject& object) -{ - d_func()->visitNode(object); -} - -void QVisitor::visitComplete() -{ - d_func()->visitComplete(); -} - - -//----------------------------------------------------------------------------- -// Utility functions -//----------------------------------------------------------------------------- - -void addDefaultAnnotators_sys(QDumper& visitor); -void addDefaultAnnotators_sys(QVisitor& visitor); - -void addDefaultAnnotators(QDumper& dumper) -{ - dumper.addAnnotator(new QAnnotatorBasic); - dumper.addAnnotator(new QAnnotatorWidget); - - // Add platform-specific annotators - addDefaultAnnotators_sys(dumper); -} - -void addDefaultAnnotators(QVisitor& visitor) -{ - visitor.addAnnotator(new QAnnotatorBasic); - visitor.addAnnotator(new QAnnotatorWidget); - - // Add platform-specific annotators - addDefaultAnnotators_sys(visitor); -} - -void dumpTreeFromRoot(const QObject& root, QVisitor& visitor) -{ - // Set up iteration range - ObjectTree::DepthFirstConstIterator begin(root), end; - - // Invoke generic visitor algorithm - ObjectTree::visit(begin, end, visitor); -} - -void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor) -{ - // Walk up to root - const QObject* root = &leaf; - while(root->parent()) - { - root = root->parent(); - } - - dumpTreeFromRoot(*root, visitor); -} - -void dumpAncestors(const QObject& leaf, QVisitor& visitor) -{ - // Set up iteration range - ObjectTree::AncestorConstIterator begin(leaf), end; - - // Invoke generic visitor algorithm - ObjectTree::visit(begin, end, visitor); -} - - -} // namespace ObjectDump - -QT_END_NAMESPACE - - - diff --git a/src/3rdparty/phonon/mmf/objectdump.h b/src/3rdparty/phonon/mmf/objectdump.h deleted file mode 100644 index 4efc015..0000000 --- a/src/3rdparty/phonon/mmf/objectdump.h +++ /dev/null @@ -1,164 +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 OBJECTDUMP_H -#define OBJECTDUMP_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ - -/** - * Abstract base for annotator classes invoked by QVisitor. - */ -class QAnnotator : public QObject -{ - Q_OBJECT -public: - virtual ~QAnnotator(); - virtual QList annotation(const QObject& object) = 0; -}; - -/** - * Annotator which replicates QObject::dumpObjectTree functionality. - */ -class QAnnotatorBasic : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - -/** - * Annotator which returns widget information. - */ -class QAnnotatorWidget : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - - -class QDumperPrivate; - -/** - * Class used to dump information about individual QObjects. - */ -class QDumper : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDumper) - -public: - QDumper(); - ~QDumper(); - - /** - * Specify a prefix, to be printed on each line of output. - */ - void setPrefix(const QString& prefix); - - /** - * Takes ownership of annotator. - */ - void addAnnotator(QAnnotator* annotator); - - /** - * Invoke each annotator on the object and write to debug output. - */ - void dumpObject(const QObject& object); - -private: - QScopedPointer d_ptr; - -}; - - -class QVisitorPrivate; - -/** - * Visitor class which dumps information about nodes in the object tree. - */ -class QVisitor : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QVisitor) - -public: - QVisitor(); - ~QVisitor(); - - /** - * Specify a prefix, to be printed on each line of output. - */ - void setPrefix(const QString& prefix); - - /** - * Set number of spaces by which each level of the tree is indented. - */ - void setIndent(unsigned indent); - - /** - * Called by the visitor algorithm before starting the visit. - */ - void visitPrepare(); - - /** - * Called by the visitor algorithm as each node is visited. - */ - void visitNode(const QObject& object); - - /** - * Called by the visitor algorithm when the visit is complete. - */ - void visitComplete(); - - /** - * Takes ownership of annotator. - */ - void addAnnotator(QAnnotator* annotator); - -private: - QScopedPointer d_ptr; - -}; - - -//----------------------------------------------------------------------------- -// Utility functions -//----------------------------------------------------------------------------- - -void addDefaultAnnotators(QDumper& dumper); -void addDefaultAnnotators(QVisitor& visitor); - -void dumpTreeFromRoot(const QObject& root, QVisitor& visitor); -void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor); -void dumpAncestors(const QObject& leaf, QVisitor& visitor); - -} // namespace ObjectDump - -QT_END_NAMESPACE - -#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump.cpp b/src/3rdparty/phonon/mmf/objectdump/objectdump.cpp new file mode 100644 index 0000000..50c6bf8 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump.cpp @@ -0,0 +1,527 @@ +/* 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 +#include + +#include "objectdump.h" +#include "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +//----------------------------------------------------------------------------- +// QObjectAnnotator +//----------------------------------------------------------------------------- + +QAnnotator::~QAnnotator() +{ + +} + + +//----------------------------------------------------------------------------- +// Annotators +//----------------------------------------------------------------------------- + +QList QAnnotatorBasic::annotation(const QObject& object) +{ + QList result; + + QByteArray array; + QTextStream stream(&array); + + stream << '[' << &object << ']'; + stream << ' '; + stream << object.metaObject()->className(); + + if(object.objectName() != "") + stream << " \"" << object.objectName() << '"'; + + if(object.isWidgetType()) + stream << " isWidget"; + + stream.flush(); + result.append(array); + return result; +} + +QList QAnnotatorWidget::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + QByteArray array; + QTextStream stream(&array); + + stream << "widget: "; + + if(widget->isVisible()) + stream << "visible "; + else + stream << "invisible "; + + stream << widget->x() << ',' << widget->y() << ' '; + stream << widget->size().width() << 'x'<< widget->size().height() << ' '; + + stream << "hint " << widget->sizeHint().width() << 'x' << widget->sizeHint().height(); + + stream.flush(); + result.append(array); + } + + return result; +} + + +//----------------------------------------------------------------------------- +// Base class for QDumperPrivate, QVisitorPrivate +//----------------------------------------------------------------------------- + +class QDumperBase +{ +public: + QDumperBase(); + ~QDumperBase(); + + void setPrefix(const QString& prefix); + void addAnnotator(QAnnotator* annotator); + +protected: + QByteArray m_prefix; + QList m_annotators; + +}; + +QDumperBase::QDumperBase() +{ + +} + +QDumperBase::~QDumperBase() +{ + QAnnotator* annotator; + foreach(annotator, m_annotators) + delete annotator; +} + +void QDumperBase::setPrefix(const QString& prefix) +{ + m_prefix = prefix.count() + ? (prefix + " ").toAscii() + : prefix.toAscii(); +} + +void QDumperBase::addAnnotator(QAnnotator* annotator) +{ + // Protect against an exception occurring during QList::append + QScopedPointer holder(annotator); + m_annotators.append(annotator); + holder.take(); +} + + +//----------------------------------------------------------------------------- +// QDumper +//----------------------------------------------------------------------------- + +class QDumperPrivate : public QDumperBase +{ +public: + QDumperPrivate(); + ~QDumperPrivate(); + + void dumpObject(const QObject& object); + +}; + + +QDumperPrivate::QDumperPrivate() +{ + +} + +QDumperPrivate::~QDumperPrivate() +{ + +} + +void QDumperPrivate::dumpObject(const QObject& object) +{ + QAnnotator* annotator; + foreach(annotator, m_annotators) { + + const QList annotations = annotator->annotation(object); + QByteArray annotation; + foreach(annotation, annotations) { + QByteArray buffer(m_prefix); + buffer.append(annotation); + qDebug() << buffer.constData(); + } + } +} + + +QDumper::QDumper() + : d_ptr(new QDumperPrivate) +{ + +} + +QDumper::~QDumper() +{ + +} + +void QDumper::setPrefix(const QString& prefix) +{ + d_func()->setPrefix(prefix); +} + +void QDumper::addAnnotator(QAnnotator* annotator) +{ + d_func()->addAnnotator(annotator); +} + +void QDumper::dumpObject(const QObject& object) +{ + d_func()->dumpObject(object); +} + + +//----------------------------------------------------------------------------- +// QVisitor +//----------------------------------------------------------------------------- + +class QVisitorPrivate : public QDumperBase +{ +public: + QVisitorPrivate(); + ~QVisitorPrivate(); + + void setIndent(unsigned indent); + + void visitNode(const QObject& object); + void visitComplete(); + +private: + class Node + { + public: + Node(); + ~Node(); + + QList m_annotation; + QList m_children; + + typedef QList::const_iterator child_iterator; + }; + +private: + Node* findNode(const QObject* object) const; + QByteArray branchBuffer(const QList& branches, bool isNodeLine, bool isLastChild) const; + void dumpRecursive(const Node& node, QList branches, bool isLastChild); + void dumpNode(const Node& node, const QList& branches, bool isLastChild); + +private: + unsigned m_indent; + + QScopedPointer m_root; + + // Hash table used to associate internal nodes with QObjects + typedef QHash Hash; + Hash m_hash; +}; + +static const unsigned DefaultIndent = 2; + +QVisitorPrivate::QVisitorPrivate() + : m_indent(DefaultIndent) +{ + +} + +QVisitorPrivate::~QVisitorPrivate() +{ + +} + +void QVisitorPrivate::setIndent(unsigned indent) +{ + m_indent = indent; +} + +// Builds up a mirror of the object tree, rooted in m_root, with each node +// storing annotations generated by +void QVisitorPrivate::visitNode(const QObject& object) +{ + QObject* const objectParent = object.parent(); + Node* const nodeParent = objectParent ? findNode(objectParent) : NULL; + + // Create a new node and store in scoped pointer for exception safety + Node* node = new Node; + QScopedPointer nodePtr(node); + + // Associate node with QObject + m_hash.insert(&object, node); + + // Insert node into internal tree + if(nodeParent) + { + nodeParent->m_children.append(nodePtr.take()); + } + else + { + Q_ASSERT(m_root.isNull()); + m_root.reset(nodePtr.take()); + } + + // Generate and store annotations + QAnnotator* annotator; + foreach(annotator, m_annotators) + node->m_annotation.append( annotator->annotation(object) ); +} + +void QVisitorPrivate::visitComplete() +{ + QList branches; + static const bool isLastChild = true; + dumpRecursive(*m_root, branches, isLastChild); + m_root.reset(NULL); +} + +QVisitorPrivate::Node* QVisitorPrivate::findNode(const QObject* object) const +{ + Hash::const_iterator i = m_hash.find(object); + return (m_hash.end() == i) ? NULL : *i; +} + +QByteArray QVisitorPrivate::branchBuffer + (const QList& branches, bool isNodeLine, bool isLastChild) const +{ + const int depth = branches.count(); + + const QByteArray indent(m_indent, ' '); + const QByteArray horiz(m_indent, '-'); + + QByteArray buffer; + QTextStream stream(&buffer); + + for (int i=0; i branches, bool isLastChild) +{ + dumpNode(node, branches, isLastChild); + + // Recurse down tree + const Node::child_iterator begin = node.m_children.begin(); + const Node::child_iterator end = node.m_children.end(); + for(Node::child_iterator i = begin; end != i; ++i) { + + isLastChild = (end == i + 1); + + if(begin == i) + branches.push_back(!isLastChild); + else + branches.back() = !isLastChild; + + static const bool isNodeLine = false; + const QByteArray buffer = branchBuffer(branches, isNodeLine, false); + qDebug() << buffer.constData(); + + dumpRecursive(**i, branches, isLastChild); + } +} + +void QVisitorPrivate::dumpNode + (const Node& node, const QList& branches, bool isLastChild) +{ + const QList::const_iterator + begin = node.m_annotation.begin(), end = node.m_annotation.end(); + + if(begin == end) { + // No annotations - just dump the object pointer + const bool isNodeLine = true; + QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); + qDebug() << NULL; // TODO + } + else { + // Dump annotations + for(QList::const_iterator i = begin; end != i; ++i) { + const bool isNodeLine = (begin == i); + QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); + buffer.append(*i); + qDebug() << buffer.constData(); + } + } +} + + +// QVisitorPrivate::Node + +QVisitorPrivate::Node::Node() +{ + +} + +QVisitorPrivate::Node::~Node() +{ + Node* child; + foreach(child, m_children) + delete child; +} + + +// QVisitor + +QVisitor::QVisitor() + : d_ptr(new QVisitorPrivate) +{ + +} + +QVisitor::~QVisitor() +{ + +} + +void QVisitor::setPrefix(const QString& prefix) +{ + d_func()->setPrefix(prefix); +} + +void QVisitor::setIndent(unsigned indent) +{ + d_func()->setIndent(indent); +} + +void QVisitor::addAnnotator(QAnnotator* annotator) +{ + d_func()->addAnnotator(annotator); +} + +void QVisitor::visitPrepare() +{ + // Do nothing +} + +void QVisitor::visitNode(const QObject& object) +{ + d_func()->visitNode(object); +} + +void QVisitor::visitComplete() +{ + d_func()->visitComplete(); +} + + +//----------------------------------------------------------------------------- +// Utility functions +//----------------------------------------------------------------------------- + +void addDefaultAnnotators_sys(QDumper& visitor); +void addDefaultAnnotators_sys(QVisitor& visitor); + +void addDefaultAnnotators(QDumper& dumper) +{ + dumper.addAnnotator(new QAnnotatorBasic); + dumper.addAnnotator(new QAnnotatorWidget); + + // Add platform-specific annotators + addDefaultAnnotators_sys(dumper); +} + +void addDefaultAnnotators(QVisitor& visitor) +{ + visitor.addAnnotator(new QAnnotatorBasic); + visitor.addAnnotator(new QAnnotatorWidget); + + // Add platform-specific annotators + addDefaultAnnotators_sys(visitor); +} + +void dumpTreeFromRoot(const QObject& root, QVisitor& visitor) +{ + // Set up iteration range + ObjectTree::DepthFirstConstIterator begin(root), end; + + // Invoke generic visitor algorithm + ObjectTree::visit(begin, end, visitor); +} + +void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor) +{ + // Walk up to root + const QObject* root = &leaf; + while(root->parent()) + { + root = root->parent(); + } + + dumpTreeFromRoot(*root, visitor); +} + +void dumpAncestors(const QObject& leaf, QVisitor& visitor) +{ + // Set up iteration range + ObjectTree::AncestorConstIterator begin(leaf), end; + + // Invoke generic visitor algorithm + ObjectTree::visit(begin, end, visitor); +} + + +} // namespace ObjectDump + +QT_END_NAMESPACE + + + diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump.h b/src/3rdparty/phonon/mmf/objectdump/objectdump.h new file mode 100644 index 0000000..cbd9bea --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump.h @@ -0,0 +1,166 @@ +/* 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 OBJECTDUMP_H +#define OBJECTDUMP_H + +#include "objectdump_global.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +/** + * Abstract base for annotator classes invoked by QVisitor. + */ +class OBJECTDUMP_EXPORT QAnnotator : public QObject +{ + Q_OBJECT +public: + virtual ~QAnnotator(); + virtual QList annotation(const QObject& object) = 0; +}; + +/** + * Annotator which replicates QObject::dumpObjectTree functionality. + */ +class OBJECTDUMP_EXPORT QAnnotatorBasic : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +/** + * Annotator which returns widget information. + */ +class OBJECTDUMP_EXPORT QAnnotatorWidget : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + + +class QDumperPrivate; + +/** + * Class used to dump information about individual QObjects. + */ +class OBJECTDUMP_EXPORT QDumper : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDumper) + +public: + QDumper(); + ~QDumper(); + + /** + * Specify a prefix, to be printed on each line of output. + */ + void setPrefix(const QString& prefix); + + /** + * Takes ownership of annotator. + */ + void addAnnotator(QAnnotator* annotator); + + /** + * Invoke each annotator on the object and write to debug output. + */ + void dumpObject(const QObject& object); + +private: + QScopedPointer d_ptr; + +}; + + +class QVisitorPrivate; + +/** + * Visitor class which dumps information about nodes in the object tree. + */ +class OBJECTDUMP_EXPORT QVisitor : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QVisitor) + +public: + QVisitor(); + ~QVisitor(); + + /** + * Specify a prefix, to be printed on each line of output. + */ + void setPrefix(const QString& prefix); + + /** + * Set number of spaces by which each level of the tree is indented. + */ + void setIndent(unsigned indent); + + /** + * Called by the visitor algorithm before starting the visit. + */ + void visitPrepare(); + + /** + * Called by the visitor algorithm as each node is visited. + */ + void visitNode(const QObject& object); + + /** + * Called by the visitor algorithm when the visit is complete. + */ + void visitComplete(); + + /** + * Takes ownership of annotator. + */ + void addAnnotator(QAnnotator* annotator); + +private: + QScopedPointer d_ptr; + +}; + + +//----------------------------------------------------------------------------- +// Utility functions +//----------------------------------------------------------------------------- + +void OBJECTDUMP_EXPORT addDefaultAnnotators(QDumper& dumper); +void OBJECTDUMP_EXPORT addDefaultAnnotators(QVisitor& visitor); + +void OBJECTDUMP_EXPORT dumpTreeFromRoot(const QObject& root, QVisitor& visitor); +void OBJECTDUMP_EXPORT dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor); +void OBJECTDUMP_EXPORT dumpAncestors(const QObject& leaf, QVisitor& visitor); + +} // namespace ObjectDump + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_global.h b/src/3rdparty/phonon/mmf/objectdump/objectdump_global.h new file mode 100644 index 0000000..ff031c4 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump_global.h @@ -0,0 +1,30 @@ +/* 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 OBJECTDUMP_GLOBAL_H +#define OBJECTDUMP_GLOBAL_H + +#include + +#if defined(OBJECTDUMP_LIBRARY) +# define OBJECTDUMP_EXPORT Q_DECL_EXPORT +#else +# define OBJECTDUMP_EXPORT Q_DECL_IMPORT +#endif + +#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp b/src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp new file mode 100644 index 0000000..6207dac --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp @@ -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 . + +*/ + +#include "objectdump.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +void addDefaultAnnotators_sys(QDumper& /*dumper*/) +{ + +} + +void addDefaultAnnotators_sys(QVisitor& /*visitor*/) +{ + +} + +} // namespace ObjectDump + +QT_END_NAMESPACE + + diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp new file mode 100644 index 0000000..54ebc55 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp @@ -0,0 +1,129 @@ +/* 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 "objectdump_symbian.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ +namespace Symbian +{ + +QList QAnnotatorControl::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + const CCoeControl* control = widget->effectiveWinId(); + if(control) { + + QByteArray array; + QTextStream stream(&array); + + stream << "control: " << control << ' '; + stream << "parent " << control->Parent() << ' '; + + if(control->IsVisible()) + stream << "visible "; + else + stream << "invisible "; + + stream << control->Position().iX << ',' << control->Position().iY << ' '; + stream << control->Size().iWidth << 'x' << control->Size().iHeight; + + if(control->OwnsWindow()) + stream << " ownsWindow "; + + stream.flush(); + result.append(array); + } + } + + return result; +} + +QList QAnnotatorWindow::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + const CCoeControl* control = widget->effectiveWinId(); + if(control) { + + RDrawableWindow& window = *(control->DrawableWindow()); + + QByteArray array; + QTextStream stream(&array); + + stream << "window: "; + + // Client-side window handle + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "cli " << reinterpret_cast(window.ClientHandle()) << ' '; + + // Server-side address of CWsWindow object + // This is useful for correlation with the window tree dumped by the window + // server (see RWsSession::LogCommand). + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "srv " << reinterpret_cast(window.WsHandle()) << ' '; + + stream << "group " << window.WindowGroupId() << ' '; + + // Client-side handle to the parent window. + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "parent " << reinterpret_cast(window.Parent()) << ' '; + + stream << window.Position().iX << ',' << window.Position().iY << ' '; + stream << '(' << window.AbsPosition().iX << ',' << window.AbsPosition().iY << ") "; + stream << window.Size().iWidth << 'x' << window.Size().iHeight; + + stream.flush(); + result.append(array); + } + } + + return result; +} + +} // namespace Symbian + +void addDefaultAnnotators_sys(QDumper& dumper) +{ + dumper.addAnnotator(new Symbian::QAnnotatorControl); + dumper.addAnnotator(new Symbian::QAnnotatorWindow); +} + +void addDefaultAnnotators_sys(QVisitor& visitor) +{ + visitor.addAnnotator(new Symbian::QAnnotatorControl); + visitor.addAnnotator(new Symbian::QAnnotatorWindow); +} + +} // namespace ObjectDump + +QT_END_NAMESPACE + + diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h new file mode 100644 index 0000000..26ab308 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h @@ -0,0 +1,56 @@ +/* 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 OBJECTDUMP_SYMBIAN_H +#define OBJECTDUMP_SYMBIAN_H + +#include "objectdump.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ +namespace Symbian +{ + +/** + * Annotator which returns control information + */ +class QAnnotatorControl : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +/** + * Annotator which returns window information + */ +class QAnnotatorWindow : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +} // namespace Symbian +} // namespace ObjectDump + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objecttree.cpp b/src/3rdparty/phonon/mmf/objectdump/objecttree.cpp new file mode 100644 index 0000000..f9d1c93 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objecttree.cpp @@ -0,0 +1,102 @@ +/* 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 "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectTree +{ + +DepthFirstConstIterator::DepthFirstConstIterator() + : m_pointee(NULL) +{ + +} + +DepthFirstConstIterator::DepthFirstConstIterator + (const QObject& root) + : m_pointee(&root) +{ + +} + +DepthFirstConstIterator& + DepthFirstConstIterator::operator++() +{ + const QObjectList& children = m_pointee->children(); + + if (children.count() == 0) { + backtrack(); + } + else { + m_history.push(0); + m_pointee = children.first(); + } + + return *this; +} + +void DepthFirstConstIterator::backtrack() +{ + if (m_history.count()) { + const int index = m_history.top(); + m_history.pop(); + + const QObjectList& siblings = m_pointee->parent()->children(); + if (siblings.count() > index + 1) { + m_history.push(index + 1); + m_pointee = siblings[index + 1]; + } + else { + m_pointee = m_pointee->parent(); + backtrack(); + } + } + else { + // Reached end of search + m_pointee = NULL; + } +} + + + +AncestorConstIterator::AncestorConstIterator() +{ + +} + +AncestorConstIterator::AncestorConstIterator(const QObject& leaf) +{ + m_ancestors.push(&leaf); + QObject* ancestor = leaf.parent(); + while(ancestor) + { + m_ancestors.push(ancestor); + ancestor = ancestor->parent(); + } +} + +} // namespace ObjectTree + +QT_END_NAMESPACE + + + diff --git a/src/3rdparty/phonon/mmf/objectdump/objecttree.h b/src/3rdparty/phonon/mmf/objectdump/objecttree.h new file mode 100644 index 0000000..f2729fa --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objecttree.h @@ -0,0 +1,117 @@ +/* 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 OBJECTTREE_H +#define OBJECTTREE_H + +#include "objectdump_global.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace ObjectTree +{ + +/** + * Depth-first iterator for QObject tree + */ +class OBJECTDUMP_EXPORT DepthFirstConstIterator +{ +public: + DepthFirstConstIterator(); + DepthFirstConstIterator(const QObject& root); + + DepthFirstConstIterator& operator++(); + + inline bool operator==(const DepthFirstConstIterator& other) const + { return other.m_pointee == m_pointee; } + + inline bool operator!=(const DepthFirstConstIterator& other) const + { return other.m_pointee != m_pointee; } + + inline const QObject* operator->() const { return m_pointee; } + inline const QObject& operator*() const { return *m_pointee; } + +private: + void backtrack(); + +private: + const QObject* m_pointee; + QStack m_history; +}; + +/** + * Ancestor iterator for QObject tree + */ +class OBJECTDUMP_EXPORT AncestorConstIterator +{ +public: + AncestorConstIterator(); + AncestorConstIterator(const QObject& root); + + inline AncestorConstIterator& operator++() + { m_ancestors.pop(); return *this; } + + inline bool operator==(const AncestorConstIterator& other) const + { return other.m_ancestors == m_ancestors; } + + inline bool operator!=(const AncestorConstIterator& other) const + { return other.m_ancestors != m_ancestors; } + + inline const QObject* operator->() const { return m_ancestors.top(); } + inline const QObject& operator*() const { return *m_ancestors.top(); } + +private: + QStack m_ancestors; + +}; + +/** + * Generic algorithm for visiting nodes in an object tree. Nodes in the + * tree are visited in a const context, therefore they are not modified + * by this algorithm. + * + * Visitor must provide functions with the following signatures: + * + * Called before visit begins + * void visitPrepare() + * + * Called on each node visited + * void visitNode(const QObject& object) + * + * Called when visit is complete + * void visitComplete() + */ +template +void visit(Iterator begin, Iterator end, Visitor& visitor) +{ + visitor.visitPrepare(); + + for( ; begin != end; ++begin) + visitor.visitNode(*begin); + + visitor.visitComplete(); +} + +} // namespace ObjectTree + +QT_END_NAMESPACE + +#endif // OBJECTTREE_H diff --git a/src/3rdparty/phonon/mmf/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/objectdump_symbian.cpp deleted file mode 100644 index 54ebc55..0000000 --- a/src/3rdparty/phonon/mmf/objectdump_symbian.cpp +++ /dev/null @@ -1,129 +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 "objectdump_symbian.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ -namespace Symbian -{ - -QList QAnnotatorControl::annotation(const QObject& object) -{ - QList result; - - const QWidget* widget = qobject_cast(&object); - if(widget) { - - const CCoeControl* control = widget->effectiveWinId(); - if(control) { - - QByteArray array; - QTextStream stream(&array); - - stream << "control: " << control << ' '; - stream << "parent " << control->Parent() << ' '; - - if(control->IsVisible()) - stream << "visible "; - else - stream << "invisible "; - - stream << control->Position().iX << ',' << control->Position().iY << ' '; - stream << control->Size().iWidth << 'x' << control->Size().iHeight; - - if(control->OwnsWindow()) - stream << " ownsWindow "; - - stream.flush(); - result.append(array); - } - } - - return result; -} - -QList QAnnotatorWindow::annotation(const QObject& object) -{ - QList result; - - const QWidget* widget = qobject_cast(&object); - if(widget) { - - const CCoeControl* control = widget->effectiveWinId(); - if(control) { - - RDrawableWindow& window = *(control->DrawableWindow()); - - QByteArray array; - QTextStream stream(&array); - - stream << "window: "; - - // Client-side window handle - // Cast to a void pointer so that log output is in hexadecimal format. - stream << "cli " << reinterpret_cast(window.ClientHandle()) << ' '; - - // Server-side address of CWsWindow object - // This is useful for correlation with the window tree dumped by the window - // server (see RWsSession::LogCommand). - // Cast to a void pointer so that log output is in hexadecimal format. - stream << "srv " << reinterpret_cast(window.WsHandle()) << ' '; - - stream << "group " << window.WindowGroupId() << ' '; - - // Client-side handle to the parent window. - // Cast to a void pointer so that log output is in hexadecimal format. - stream << "parent " << reinterpret_cast(window.Parent()) << ' '; - - stream << window.Position().iX << ',' << window.Position().iY << ' '; - stream << '(' << window.AbsPosition().iX << ',' << window.AbsPosition().iY << ") "; - stream << window.Size().iWidth << 'x' << window.Size().iHeight; - - stream.flush(); - result.append(array); - } - } - - return result; -} - -} // namespace Symbian - -void addDefaultAnnotators_sys(QDumper& dumper) -{ - dumper.addAnnotator(new Symbian::QAnnotatorControl); - dumper.addAnnotator(new Symbian::QAnnotatorWindow); -} - -void addDefaultAnnotators_sys(QVisitor& visitor) -{ - visitor.addAnnotator(new Symbian::QAnnotatorControl); - visitor.addAnnotator(new Symbian::QAnnotatorWindow); -} - -} // namespace ObjectDump - -QT_END_NAMESPACE - - diff --git a/src/3rdparty/phonon/mmf/objectdump_symbian.h b/src/3rdparty/phonon/mmf/objectdump_symbian.h deleted file mode 100644 index 26ab308..0000000 --- a/src/3rdparty/phonon/mmf/objectdump_symbian.h +++ /dev/null @@ -1,56 +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 OBJECTDUMP_SYMBIAN_H -#define OBJECTDUMP_SYMBIAN_H - -#include "objectdump.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ -namespace Symbian -{ - -/** - * Annotator which returns control information - */ -class QAnnotatorControl : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - -/** - * Annotator which returns window information - */ -class QAnnotatorWindow : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - -} // namespace Symbian -} // namespace ObjectDump - -QT_END_NAMESPACE - -#endif diff --git a/src/3rdparty/phonon/mmf/objecttree.cpp b/src/3rdparty/phonon/mmf/objecttree.cpp deleted file mode 100644 index f9d1c93..0000000 --- a/src/3rdparty/phonon/mmf/objecttree.cpp +++ /dev/null @@ -1,102 +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 "objecttree.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectTree -{ - -DepthFirstConstIterator::DepthFirstConstIterator() - : m_pointee(NULL) -{ - -} - -DepthFirstConstIterator::DepthFirstConstIterator - (const QObject& root) - : m_pointee(&root) -{ - -} - -DepthFirstConstIterator& - DepthFirstConstIterator::operator++() -{ - const QObjectList& children = m_pointee->children(); - - if (children.count() == 0) { - backtrack(); - } - else { - m_history.push(0); - m_pointee = children.first(); - } - - return *this; -} - -void DepthFirstConstIterator::backtrack() -{ - if (m_history.count()) { - const int index = m_history.top(); - m_history.pop(); - - const QObjectList& siblings = m_pointee->parent()->children(); - if (siblings.count() > index + 1) { - m_history.push(index + 1); - m_pointee = siblings[index + 1]; - } - else { - m_pointee = m_pointee->parent(); - backtrack(); - } - } - else { - // Reached end of search - m_pointee = NULL; - } -} - - - -AncestorConstIterator::AncestorConstIterator() -{ - -} - -AncestorConstIterator::AncestorConstIterator(const QObject& leaf) -{ - m_ancestors.push(&leaf); - QObject* ancestor = leaf.parent(); - while(ancestor) - { - m_ancestors.push(ancestor); - ancestor = ancestor->parent(); - } -} - -} // namespace ObjectTree - -QT_END_NAMESPACE - - - diff --git a/src/3rdparty/phonon/mmf/objecttree.h b/src/3rdparty/phonon/mmf/objecttree.h deleted file mode 100644 index 0c2031d..0000000 --- a/src/3rdparty/phonon/mmf/objecttree.h +++ /dev/null @@ -1,115 +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 OBJECTTREE_H -#define OBJECTTREE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -namespace ObjectTree -{ - -/** - * Depth-first iterator for QObject tree - */ -class DepthFirstConstIterator -{ -public: - DepthFirstConstIterator(); - DepthFirstConstIterator(const QObject& root); - - DepthFirstConstIterator& operator++(); - - inline bool operator==(const DepthFirstConstIterator& other) const - { return other.m_pointee == m_pointee; } - - inline bool operator!=(const DepthFirstConstIterator& other) const - { return other.m_pointee != m_pointee; } - - inline const QObject* operator->() const { return m_pointee; } - inline const QObject& operator*() const { return *m_pointee; } - -private: - void backtrack(); - -private: - const QObject* m_pointee; - QStack m_history; -}; - -/** - * Ancestor iterator for QObject tree - */ -class AncestorConstIterator -{ -public: - AncestorConstIterator(); - AncestorConstIterator(const QObject& root); - - inline AncestorConstIterator& operator++() - { m_ancestors.pop(); return *this; } - - inline bool operator==(const AncestorConstIterator& other) const - { return other.m_ancestors == m_ancestors; } - - inline bool operator!=(const AncestorConstIterator& other) const - { return other.m_ancestors != m_ancestors; } - - inline const QObject* operator->() const { return m_ancestors.top(); } - inline const QObject& operator*() const { return *m_ancestors.top(); } - -private: - QStack m_ancestors; - -}; - -/** - * Generic algorithm for visiting nodes in an object tree. Nodes in the - * tree are visited in a const context, therefore they are not modified - * by this algorithm. - * - * Visitor must provide functions with the following signatures: - * - * Called before visit begins - * void visitPrepare() - * - * Called on each node visited - * void visitNode(const QObject& object) - * - * Called when visit is complete - * void visitComplete() - */ -template -void visit(Iterator begin, Iterator end, Visitor& visitor) -{ - visitor.visitPrepare(); - - for( ; begin != end; ++begin) - visitor.visitNode(*begin); - - visitor.visitComplete(); -} - -} // namespace ObjectTree - -QT_END_NAMESPACE - -#endif // OBJECTTREE_H diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 2544a97..3f14f19 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -21,7 +21,7 @@ along with this library. If not, see . #include "videooutputobserver.h" #ifdef _DEBUG -#include "objectdump.h" +#include "objectdump/objectdump.h" #endif #include diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index e8b792f..b4f3d35 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -27,7 +27,7 @@ along with this library. If not, see . #include "utils.h" #ifdef _DEBUG -#include "objectdump.h" +#include "objectdump/objectdump.h" #endif QT_BEGIN_NAMESPACE diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 4496feb..dc18d20 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -1,89 +1,3 @@ -# MMF Phonon backend - -QT += phonon -TARGET = phonon_mmf -PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf - -# 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 - - # 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 -} - -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/defs.h \ - $$PHONON_MMF_DIR/dummyplayer.h \ - $$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 - -SOURCES += \ - $$PHONON_MMF_DIR/abstractplayer.cpp \ - $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ - $$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/videooutput.cpp \ - $$PHONON_MMF_DIR/videoplayer.cpp \ - $$PHONON_MMF_DIR/videowidget.cpp - -# This is not mmfphonon-specific, and should be factored out into a separate -# library (QtCore?) at a later date -debug { -HEADERS += \ - $$PHONON_MMF_DIR/objectdump.h \ - $$PHONON_MMF_DIR/objectdump_symbian.h \ - $$PHONON_MMF_DIR/objecttree.h - -SOURCES += \ - $$PHONON_MMF_DIR/objectdump.cpp \ - $$PHONON_MMF_DIR/objectdump_symbian.cpp \ - $$PHONON_MMF_DIR/objecttree.cpp - -} - -LIBS += -lmediaclientvideo # For CVideoPlayerUtility -LIBS += -lcone # For CCoeEnv -LIBS += -lws32 # For RWindow -LIBS += -lefsrv # For file server -LIBS += -lapgrfx -lapmime # For recognizer - -# 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 - -include(../../qpluginbase.pri) - -# 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. -symbian:TARGET.UID3=0x2001E627 +TEMPLATE = subdirs +SUBDIRS = objectdump plugin diff --git a/src/plugins/phonon/mmf/objectdump/objectdump.pro b/src/plugins/phonon/mmf/objectdump/objectdump.pro new file mode 100644 index 0000000..b9e2017 --- /dev/null +++ b/src/plugins/phonon/mmf/objectdump/objectdump.pro @@ -0,0 +1,28 @@ +TEMPLATE = lib +TARGET = objectdump +OBJECTDUMP_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf/objectdump + +CONFIG += dll + +DEFINES += OBJECTDUMP_LIBRARY + +HEADERS += \ + $$OBJECTDUMP_DIR/objectdump_global.h \ + $$OBJECTDUMP_DIR/objectdump.h \ + $$OBJECTDUMP_DIR/objecttree.h + +SOURCES += \ + $$OBJECTDUMP_DIR/objectdump.cpp \ + $$OBJECTDUMP_DIR/objecttree.cpp + +symbian { + HEADERS += $$OBJECTDUMP_DIR/objectdump_symbian.h + SOURCES += $$OBJECTDUMP_DIR/objectdump_symbian.cpp + + LIBS += -lcone + LIBS += -lws32 + + TARGET.CAPABILITY = all -tcb +} else { + SOURCES += $$OBJECTDUMP_DIR/objectdump_stub.cpp +} diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro new file mode 100644 index 0000000..418d354 --- /dev/null +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -0,0 +1,79 @@ +# MMF Phonon backend + +QT += phonon +TARGET = phonon_mmf +PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf + +# 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 + + # 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 +} + +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/defs.h \ + $$PHONON_MMF_DIR/dummyplayer.h \ + $$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 + +SOURCES += \ + $$PHONON_MMF_DIR/abstractplayer.cpp \ + $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ + $$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/videooutput.cpp \ + $$PHONON_MMF_DIR/videoplayer.cpp \ + $$PHONON_MMF_DIR/videowidget.cpp + +debug { + INCLUDEPATH += $$PHONON_MMF_DIR/objectdump + LIBS += -lobjectdump +} + +LIBS += -lmediaclientvideo # For CVideoPlayerUtility +LIBS += -lcone # For CCoeEnv +LIBS += -lws32 # For RWindow +LIBS += -lefsrv # For file server +LIBS += -lapgrfx -lapmime # For recognizer + +# 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 + +include(../../../qpluginbase.pri) + +# 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. +symbian:TARGET.UID3=0x2001E627 + -- cgit v0.12 From c4d341ecf26d63cc7410756f8f7d1926c277f02f Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 7 Sep 2009 17:30:53 +0100 Subject: Modified file-loading code to use QDir::toNativeSeparators --- src/3rdparty/phonon/mmf/mediaobject.cpp | 5 ++++- src/3rdparty/phonon/mmf/utils.cpp | 15 --------------- src/3rdparty/phonon/mmf/utils.h | 9 --------- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index bf55781..a2a7e4d 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -23,6 +23,8 @@ along with this library. If not, see . #include "utils.h" #include "videoplayer.h" +#include + QT_BEGIN_NAMESPACE using namespace Phonon; @@ -101,7 +103,8 @@ MMF::MediaType MMF::MediaObject::fileMediaType MediaType result = MediaTypeUnknown; if (openRecognizer()) { - QHBufC fileNameSymbian = Utils::symbianFilename(fileName); + + const QHBufC fileNameSymbian(QDir::toNativeSeparators(fileName)); m_file.Close(); TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly); diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index df9ceae..cebc32e 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -31,21 +31,6 @@ 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; -} - static const TInt KMimePrefixLength = 6; // either "audio/" or "video/" _LIT(KMimePrefixAudio, "audio/"); diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index c0487a7..5a26018 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -47,15 +47,6 @@ namespace Utils 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. */ -- cgit v0.12 From 0963768ba79b6304c27c9ea293c71824e77a64ef Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 3 Sep 2009 16:42:47 +0200 Subject: Make itemviews use gradient selection on Vista by default We postponed this in 4.3 when the vista style was introduced since a lot of microsoft apps still used the legacy style and microsoft did not enable it by default. It has been reported as bugs a few times and it seems increasingly odd that we are not using the more modern look and feel when we can. Instead of only enabling it for QTreeView, we now only disable it for QTableView as the look still cannot be used to span vertical cells. Task-number: QTBUG-3746 Reviewed-by: prasanth --- src/gui/styles/qwindowsvistastyle.cpp | 22 ++++++++-------------- src/gui/styles/qwindowsvistastyle_p.h | 1 + 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index b062a3f..6cb8b40 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -731,14 +731,11 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt { const QStyleOptionViewItemV4 *vopt; const QAbstractItemView *view = qobject_cast(widget); - bool newStyle = false; + bool newStyle = true; + + if (qobject_cast(widget)) + newStyle = false; - if (const QListView *listview = qobject_cast(widget)) { - if (listview->viewMode() == QListView::IconMode) - newStyle = true; - } else if (qobject_cast(widget)) { - newStyle = true; - } if (newStyle && view && (vopt = qstyleoption_cast(option))) { bool selected = vopt->state & QStyle::State_Selected; bool hover = vopt->state & QStyle::State_MouseOver; @@ -1496,14 +1493,11 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption { const QStyleOptionViewItemV4 *vopt; const QAbstractItemView *view = qobject_cast(widget); - bool newStyle = false; + bool newStyle = true; + + if (qobject_cast(widget)) + newStyle = false; - if (const QListView *listview = qobject_cast(widget)) { - if (listview->viewMode() == QListView::IconMode) - newStyle = true; - } else if (qobject_cast(widget)) { - newStyle = true; - } if (newStyle && view && (vopt = qstyleoption_cast(option))) { /* // We cannot currently get the correct selection color for "explorer style" views diff --git a/src/gui/styles/qwindowsvistastyle_p.h b/src/gui/styles/qwindowsvistastyle_p.h index d4170aa..e9bbb77 100644 --- a/src/gui/styles/qwindowsvistastyle_p.h +++ b/src/gui/styles/qwindowsvistastyle_p.h @@ -84,6 +84,7 @@ #include #include #include +#include #include #include -- cgit v0.12 From 4cc9fcac3ef66987b95a5589f10f3a0d82a778f4 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 4 Sep 2009 17:16:18 +0200 Subject: Fix duplicate key events from extended media keys on Windows We handle WM_APPCOMMAND to generate keyEvents separate from normal key events. However when we already have virtual key mappings for the same keys the events got delivered twice. Hence we have now removed WM_APPCOMMAND handling for all such keys. Task-number: QTBUG-4124 Reviewed-by: prasanth --- src/gui/kernel/qapplication_win.cpp | 61 ------------------------------------- 1 file changed, 61 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 6ecd535..eb9e276 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1752,79 +1752,18 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam case APPCOMMAND_BASS_UP: key = Qt::Key_BassUp; break; - case APPCOMMAND_BROWSER_BACKWARD: - key = Qt::Key_Back; - break; - case APPCOMMAND_BROWSER_FAVORITES: - key = Qt::Key_Favorites; - break; - case APPCOMMAND_BROWSER_FORWARD: - key = Qt::Key_Forward; - break; - case APPCOMMAND_BROWSER_HOME: - key = Qt::Key_HomePage; - break; - case APPCOMMAND_BROWSER_REFRESH: - key = Qt::Key_Refresh; - break; - case APPCOMMAND_BROWSER_SEARCH: - key = Qt::Key_Search; - break; - case APPCOMMAND_BROWSER_STOP: - key = Qt::Key_Stop; - break; - case APPCOMMAND_LAUNCH_APP1: - key = Qt::Key_Launch0; - break; - case APPCOMMAND_LAUNCH_APP2: - key = Qt::Key_Launch1; - break; - case APPCOMMAND_LAUNCH_MAIL: - key = Qt::Key_LaunchMail; - break; - case APPCOMMAND_LAUNCH_MEDIA_SELECT: - key = Qt::Key_LaunchMedia; - break; - case APPCOMMAND_MEDIA_NEXTTRACK: - key = Qt::Key_MediaNext; - break; - case APPCOMMAND_MEDIA_PLAY_PAUSE: - key = Qt::Key_MediaPlay; - break; - case APPCOMMAND_MEDIA_PREVIOUSTRACK: - key = Qt::Key_MediaPrevious; - break; - case APPCOMMAND_MEDIA_STOP: - key = Qt::Key_MediaStop; - break; case APPCOMMAND_TREBLE_DOWN: key = Qt::Key_TrebleDown; break; case APPCOMMAND_TREBLE_UP: key = Qt::Key_TrebleUp; break; - case APPCOMMAND_VOLUME_DOWN: - key = Qt::Key_VolumeDown; - break; - case APPCOMMAND_VOLUME_MUTE: - key = Qt::Key_VolumeMute; - break; - case APPCOMMAND_VOLUME_UP: - key = Qt::Key_VolumeUp; - break; - // Commands new in Windows XP case APPCOMMAND_HELP: key = Qt::Key_Help; break; case APPCOMMAND_FIND: key = Qt::Key_Search; break; - case APPCOMMAND_PRINT: - key = Qt::Key_Print; - break; - case APPCOMMAND_MEDIA_PLAY: - key = Qt::Key_MediaPlay; - break; default: break; } -- cgit v0.12 From c5c58c2368f71c5d0067c9389c8ad04c41b66db5 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 9 Sep 2009 15:09:34 +0200 Subject: Fix regression in Command link button font size Since vista style polish sets the font on polish, the check for WA_SetFont will succeed, hence we never set the actual font. I replaced the check with a full resolve. However since the resolve would clear the resolve_mask, from the widget font it has to be restored manually so that QPainter:setFont can resolve it later. Task-number: QTBUG-4646 Reviewed-by: trond --- src/gui/text/qfont.h | 1 + src/gui/widgets/qcommandlinkbutton.cpp | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index ef91983..d73e1c4 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -309,6 +309,7 @@ private: friend class QPicturePaintEngine; friend class QPainterReplayer; friend class QPaintBufferEngine; + friend class QCommandLinkButtonPrivate; #ifndef QT_NO_DATASTREAM friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QFont &); diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp index e64f687..9adf280 100644 --- a/src/gui/widgets/qcommandlinkbutton.cpp +++ b/src/gui/widgets/qcommandlinkbutton.cpp @@ -140,23 +140,34 @@ QFont QCommandLinkButtonPrivate::titleFont() const Q_Q(const QCommandLinkButton); QFont font = q->font(); if (usingVistaStyle()) { - if (!q->testAttribute(Qt::WA_SetFont)) - font.setPointSizeF(12.0); + font.setPointSizeF(12.0); } else { font.setBold(true); - if (!q->testAttribute(Qt::WA_SetFont)) - font.setPointSizeF(9.0); + font.setPointSizeF(9.0); } - return font; + + // Note the font will be resolved against + // QPainters font, so we need to restore the mask + int resolve_mask = font.resolve_mask; + QFont modifiedFont = q->font().resolve(font); + modifiedFont.detach(); + modifiedFont.resolve_mask = resolve_mask; + return modifiedFont; } QFont QCommandLinkButtonPrivate::descriptionFont() const { Q_Q(const QCommandLinkButton); QFont font = q->font(); - if (!q->testAttribute(Qt::WA_SetFont)) - font.setPointSizeF(9.0); - return font; + font.setPointSizeF(9.0); + + // Note the font will be resolved against + // QPainters font, so we need to restore the mask + int resolve_mask = font.resolve_mask; + QFont modifiedFont = q->font().resolve(font); + modifiedFont.detach(); + modifiedFont.resolve_mask = resolve_mask; + return modifiedFont; } QRect QCommandLinkButtonPrivate::titleRect() const -- cgit v0.12 From 7d2d15bbc9d598daf94800b576aff19a68119ed1 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 26 Aug 2009 16:36:32 +0200 Subject: Work on extending the framework for accomodating effects. This extends the framework for being able to handle audio effects, largely affecting how the audio chain is set up, connected and disconnected, and therefore the Backend has been refactored slightly, and the class MediaNode introduced, see its documentation. In addition two effects has been written: BassBoost and AudioEqualizer. --- src/3rdparty/phonon/mmf/TODO.txt | 3 + src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 105 ++++++++++++++++ src/3rdparty/phonon/mmf/abstractaudioeffect.h | 108 ++++++++++++++++ src/3rdparty/phonon/mmf/abstractplayer.h | 4 +- src/3rdparty/phonon/mmf/audioequalizer.cpp | 86 +++++++++++++ src/3rdparty/phonon/mmf/audioequalizer.h | 63 ++++++++++ src/3rdparty/phonon/mmf/audiooutput.cpp | 2 +- src/3rdparty/phonon/mmf/audiooutput.h | 5 +- src/3rdparty/phonon/mmf/audioplayer.cpp | 6 + src/3rdparty/phonon/mmf/audioplayer.h | 6 +- src/3rdparty/phonon/mmf/backend.cpp | 75 +++++++----- src/3rdparty/phonon/mmf/backend.h | 2 +- src/3rdparty/phonon/mmf/bassboost.cpp | 45 +++++++ src/3rdparty/phonon/mmf/bassboost.h | 59 +++++++++ src/3rdparty/phonon/mmf/effectfactory.cpp | 156 ++++++++++++++++++++++++ src/3rdparty/phonon/mmf/effectfactory.h | 76 ++++++++++++ src/3rdparty/phonon/mmf/mediaobject.cpp | 46 ++++++- src/3rdparty/phonon/mmf/mediaobject.h | 19 ++- src/3rdparty/phonon/mmf/mmf_medianode.cpp | 63 ++++++++++ src/3rdparty/phonon/mmf/mmf_medianode.h | 79 ++++++++++++ src/3rdparty/phonon/mmf/videowidget.cpp | 2 +- src/3rdparty/phonon/mmf/videowidget.h | 10 +- src/plugins/phonon/mmf/mmf.pro | 5 +- src/plugins/phonon/mmf/plugin/plugin.pro | 35 ++++-- 24 files changed, 993 insertions(+), 67 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/abstractaudioeffect.cpp create mode 100644 src/3rdparty/phonon/mmf/abstractaudioeffect.h create mode 100644 src/3rdparty/phonon/mmf/audioequalizer.cpp create mode 100644 src/3rdparty/phonon/mmf/audioequalizer.h create mode 100644 src/3rdparty/phonon/mmf/bassboost.cpp create mode 100644 src/3rdparty/phonon/mmf/bassboost.h create mode 100644 src/3rdparty/phonon/mmf/effectfactory.cpp create mode 100644 src/3rdparty/phonon/mmf/effectfactory.h create mode 100644 src/3rdparty/phonon/mmf/mmf_medianode.cpp create mode 100644 src/3rdparty/phonon/mmf/mmf_medianode.h diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 846f0bb..1d2cb44 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -37,4 +37,7 @@ 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). +* Before merging, ensure the UID3 is properly allocated, see the .pro file. + +* Metadata is not implemented. diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp new file mode 100644 index 0000000..4c876e1 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -0,0 +1,105 @@ +/* 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 "mediaobject.h" + +#include "abstractaudioeffect.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +AbstractAudioEffect::AbstractAudioEffect(QObject *parent, + const QList ¶ms) : MediaNode::MediaNode(parent) + , m_params(params) + , m_isApplied(false) +{ +} + +bool AbstractAudioEffect::disconnectMediaNode(MediaNode *target) +{ + MediaNode::disconnectMediaNode(target); + m_effect.reset(); + return true; +} + +QList AbstractAudioEffect::parameters() const +{ + return m_params; +} + +QVariant AbstractAudioEffect::parameterValue(const EffectParameter &queriedParam) const +{ + const QVariant &val = m_values.value(queriedParam.id()); + + if (val.isNull()) + return queriedParam.defaultValue(); + else + return val; +} + +void AbstractAudioEffect::setParameterValue(const EffectParameter ¶m, + const QVariant &newValue) +{ + m_values.insert(param.id(), newValue); + parameterChanged(param.id(), newValue); +} + +bool AbstractAudioEffect::activateBackwardsInChain(MediaNode *target) +{ + // TODO we need to walk forward too. + MediaNode *current = target; + + while (current) { + MMF::MediaObject *const mo = qobject_cast(current); + if(!mo) + continue; + + AudioPlayer *const ap = qobject_cast(mo->abstractPlayer()); + + if (ap) { + activateOn(ap->player()); + // There might be stuff before the mediaobject, but + // that's undefined for us. + return true; + } + else + current = current->source(); + } + + return false; +} + +bool AbstractAudioEffect::connectMediaNode(MediaNode *target) +{ + /** + * We first call this function, so source() and target() + * is properly set up. + */ + MediaNode::connectMediaNode(target); + + if (!m_isApplied && activateBackwardsInChain(target)) + m_isApplied = true; + + return true; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h new file mode 100644 index 0000000..4c2eba3 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -0,0 +1,108 @@ +/* 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_ABSTRACTEFFECT_H +#define PHONON_MMF_ABSTRACTEFFECT_H + +#include "mmf_medianode.h" + +#include + +#include +#include +#include "audioplayer.h" + +class CAudioEffect; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ + +/** + * @short Base class for all effects for MMF. + * + * Adhering to Phonon with MMF is cumbersome because of a number of reasons: + * + * - MMF has no concept of effect chaining. Simply, an effect is a applied + * to PlayerUtility, that's it. This means that the order of effects is + * undefined. + * - We apply an effect to a PlayerUtility, and MediaObject has that one. + * However, effects might be created before MediaObject, but nevertheless + * needs to work. We solve this by that we are aware of the whole connection + * chain, and whenever a connection happens, we walk the chain, find effects + * that aren't applied, and apply it if we have a media object. + * - There are plenty of corner cases which we don't handle and where behavior + * are undefined. For instance, graphs with more than one MediaObject. + */ +class AbstractAudioEffect : public MediaNode + , public EffectInterface +{ + Q_OBJECT + Q_INTERFACES(Phonon::EffectInterface) +public: + AbstractAudioEffect(QObject *parent, + const QList ¶ms); + + virtual QList parameters() const; + virtual QVariant parameterValue(const EffectParameter ¶m) const; + virtual void setParameterValue(const EffectParameter &, + const QVariant &newValue); + + virtual bool connectMediaNode(MediaNode *target); + virtual bool disconnectMediaNode(MediaNode *target); + + enum Type + { + EffectAudioEqualizer = 1, + EffectBassBoost, + EffectDistanceAttenuation, + EffectEnvironmentalReverb, + EffectListenerOrientation, + EffectLoudness, + //EffectRoomLevel, + EffectSourceOrientation, + EffectStereoWidening + }; + +protected: + virtual void activateOn(CPlayerType *player) = 0; + virtual void parameterChanged(const int id, + const QVariant &value) = 0; + + QScopedPointer m_effect; +private: + /** + * From @p target, we walk the chain backwards and try to find the media + * object, and apply ourselves to that one. + */ + bool activateBackwardsInChain(MediaNode *target); + + const QList m_params; + bool m_isApplied; + QHash m_values; +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index da0fe51..0f846ca 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -48,8 +48,8 @@ class VideoOutput; * - Audio, in which case the implementation is AudioPlayer * - Video, in which case the implementation is VideoPlayer */ -class AbstractPlayer : public QObject - , public VolumeObserver +class AbstractPlayer : public QObject + , public VolumeObserver { // Required although this class has no signals or slots // Without this, qobject_cast will fail diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp new file mode 100644 index 0000000..28a8741 --- /dev/null +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -0,0 +1,86 @@ +/* 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 "audioequalizer.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +AudioEqualizer::AudioEqualizer(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, createParams()) +{ +} + +void AudioEqualizer::parameterChanged(const int pid, + const QVariant &value) +{ + // There is no way to return an error from this function, so we just + // have to trap and ignore exceptions. + TRAP_IGNORE(eq()->SetBandLevelL(pid, value.toInt())); +} + +void AudioEqualizer::activateOn(CPlayerType *player) +{ + m_effect.reset(CAudioEqualizer::NewL(*player)); +} + +CAudioEqualizer *AudioEqualizer::eq() const +{ + return static_cast(m_effect.data()); +} + +QList AudioEqualizer::createParams() +{ + QList retval; + + // We temporarily create an AudioPlayer, and run the effect on it, so + // we can extract the readonly data we need. + AudioPlayer dummyPlayer; + activateOn(dummyPlayer.player()); + + TInt32 dbMin; + TInt32 dbMax; + eq()->DbLevelLimits(dbMin, dbMax); + + const int bandCount = eq()->NumberOfBands(); + + for (int i = 0; i < bandCount; ++i) { + const qint32 hz = eq()->CenterFrequency(i); + + const qint32 defVol = eq()->BandLevel(i); + + retval.append(EffectParameter(i, + tr("Frequency band, %1 Hz").arg(hz), + EffectParameter::LogarithmicHint, + QVariant(qint32(defVol)), + QVariant(qint32(dbMin)), + QVariant(qint32(dbMax)), + QVariantList(), + QString())); + } + + m_effect.reset(); + + return retval; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h new file mode 100644 index 0000000..5ef2af9 --- /dev/null +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -0,0 +1,63 @@ +/* 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_AUDIOEQUALIZER_H +#define PHONON_MMF_AUDIOEQUALIZER_H + +#include "abstractaudioeffect.h" + +class CAudioEqualizer; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short A classic equalizer. + * + * The equalizer has a number of bands, and each band has a frequency, and a + * volume. With Phonon's API, this is modeled such that each band is one + * Phonon::EffectParameter, where Phonon::EffectParameter::id() is the band + * number, and the setting is the volume level. + */ +class AudioEqualizer : public AbstractAudioEffect +{ + Q_OBJECT +public: + AudioEqualizer(QObject *parent); + +protected: + virtual void parameterChanged(const int id, + const QVariant &value); + + virtual void activateOn(CPlayerType *player); + +private: + inline CAudioEqualizer *eq() const; + QList createParams(); + QScopedPointer m_bassBoost; +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 909e568..d2e7d76 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -33,7 +33,7 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : QObject(parent) +MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : MediaNode(parent) , m_volume(InitialVolume) , m_observer(NULL) { diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 001190f..0d3cca7 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -19,6 +19,7 @@ along with this library. If not, see . #ifndef PHONON_MMF_AUDIOOUTPUT_H #define PHONON_MMF_AUDIOOUTPUT_H +#include "mmf_medianode.h" #include QT_BEGIN_NAMESPACE @@ -46,8 +47,8 @@ class VolumeObserver; * * @author Frans Englich */ -class AudioOutput : public QObject - , public AudioOutputInterface +class AudioOutput : public MediaNode + , public AudioOutputInterface { Q_OBJECT Q_INTERFACES(Phonon::AudioOutputInterface) diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 1229625..127b921 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -220,6 +220,12 @@ void MMF::AudioPlayer::MapcPlayComplete(TInt aError) TRACE_EXIT_0(); } +CPlayerType *MMF::AudioPlayer::player() const +{ + return m_player; +} + + #ifdef QT_PHONON_MMF_AUDIO_DRM void MMF::AudioPlayer::MaloLoadingStarted() { diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 424985c..3245159 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -44,9 +44,9 @@ namespace MMF * @short Wrapper over MMF audio client utility */ class AudioPlayer : public AbstractMediaPlayer - , public MPlayerObserverType // typedef + , public MPlayerObserverType // typedef #ifdef QT_PHONON_MMF_AUDIO_DRM - , public MAudioLoadingObserver + , public MAudioLoadingObserver #endif { Q_OBJECT @@ -86,6 +86,7 @@ public: virtual void MapcPlayComplete(TInt aError); #endif + CPlayerType *player() const; Q_SIGNALS: void totalTimeChanged(qint64 length); void finished(); @@ -99,7 +100,6 @@ private: * CMdaAudioPlayerUtility and CDrmPlayerUtility */ CPlayerType* m_player; - }; } } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 71e51d9..d05b543 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -23,8 +23,11 @@ along with this library. If not, see . #include // for CDataTypeArray #include // for TDataType -#include "backend.h" +#include "abstractaudioeffect.h" #include "audiooutput.h" +#include "audioplayer.h" +#include "backend.h" +#include "effectfactory.h" #include "mediaobject.h" #include "utils.h" #include "videowidget.h" @@ -48,7 +51,7 @@ Backend::Backend(QObject *parent) : QObject(parent) TRACE_EXIT_0(); } -QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &) +QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &args) { TRACE_CONTEXT(Backend::createObject, EBackend); TRACE_ENTRY("class %d", c); @@ -61,15 +64,20 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const break; case MediaObjectClass: - result = new MediaObject(parent); + result = new MediaObject(parent); break; case VolumeFaderEffectClass: case VisualizationClass: case VideoDataOutputClass: case EffectClass: - break; + { + Q_ASSERT(args.count() == 1); + Q_ASSERT(args.first().type() == QVariant::Int); + const AbstractAudioEffect::Type effect = AbstractAudioEffect::Type(args.first().toInt()); + return EffectFactory::createAudioEffect(effect, parent); + } case VideoWidgetClass: result = new VideoWidget(qobject_cast(parent)); break; @@ -81,14 +89,32 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const TRACE_RETURN("0x%08x", result); } -QList Backend::objectDescriptionIndexes(ObjectDescriptionType) const +QList Backend::objectDescriptionIndexes(ObjectDescriptionType type) const { - return QList(); + TRACE_CONTEXT(Backend::objectDescriptionIndexes, EAudioApi); + TRACE_ENTRY_0(); + QList retval; + + switch(type) + { + case EffectType: + retval.append(EffectFactory::effectIndexes()); + default: + ; + } + + TRACE_EXIT_0(); + return retval; } -QHash Backend::objectDescriptionProperties(ObjectDescriptionType, int) const +QHash Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const { - return QHash(); + TRACE_CONTEXT(Backend::connectNodes, EBackend); + + if (type == EffectType) + return EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type(index)); + else + return QHash(); } bool Backend::startConnectionChange(QSet) @@ -100,40 +126,25 @@ bool Backend::connectNodes(QObject *source, QObject *target) { TRACE_CONTEXT(Backend::connectNodes, EBackend); TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); + Q_ASSERT(qobject_cast(source)); + Q_ASSERT(qobject_cast(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->setVolumeObserver(mediaObject); - result = true; - } + MediaNode *const mediaSource = static_cast(source); + MediaNode *const mediaTarget = static_cast(target); - if (mediaObject and videoWidget) { - TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); - mediaObject->setVideoOutput(&videoWidget->videoOutput()); - result = true; - } + mediaSource->connectMediaNode(mediaTarget); - TRACE_RETURN("%d", result); + return false; } bool Backend::disconnectNodes(QObject *source, QObject *target) { TRACE_CONTEXT(Backend::disconnectNodes, EBackend); TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); + Q_ASSERT(qobject_cast(source)); + Q_ASSERT(qobject_cast(target)); - MediaObject *const mediaObject = qobject_cast(source); - AudioOutput *const audioOutput = qobject_cast(target); - VideoWidget *const videoWidget = qobject_cast(target); - - bool result = true; - - // TODO: disconnection + const bool result = static_cast(source)->disconnectMediaNode(static_cast(target)); TRACE_RETURN("%d", result); } diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index 7598fa7..1886ae6 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -29,7 +29,7 @@ namespace Phonon namespace MMF { class Backend : public QObject - , public BackendInterface + , public BackendInterface { Q_OBJECT Q_INTERFACES(Phonon::BackendInterface) diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp new file mode 100644 index 0000000..ca9d5cc --- /dev/null +++ b/src/3rdparty/phonon/mmf/bassboost.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 + +#include "bassboost.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +BassBoost::BassBoost(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, + QList()) +{ +} + +void BassBoost::parameterChanged(const int, + const QVariant &) +{ + // We should never be called, because we have no parameters. +} + +void BassBoost::activateOn(CPlayerType *player) +{ + m_effect.reset(CBassBoost::NewL(*player, true)); +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h new file mode 100644 index 0000000..bf3c6c4 --- /dev/null +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -0,0 +1,59 @@ +/* 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_BASSBOOST_H +#define PHONON_MMF_BASSBOOST_H + +#include "abstractaudioeffect.h" + +class CBassBoost; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short An "bass boost" effect. + * + * The documentation does not say what "bass boost" is, neither has it anykind + * of setting. It's an on or off thing. + */ +class BassBoost : public AbstractAudioEffect +{ + Q_OBJECT +public: + BassBoost(QObject *parent); + +protected: + virtual void parameterChanged(const int id, + const QVariant &value); + + virtual void activateOn(CPlayerType *player); + +private: + QScopedPointer m_bassBoost; +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp new file mode 100644 index 0000000..41f48d2 --- /dev/null +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -0,0 +1,156 @@ +/* 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "audioequalizer.h" +#include "bassboost.h" + +#include "effectfactory.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +QHash EffectFactory::constructEffectDescription(const QString &name, + const QString &description) +{ + QHash retval; + + retval.insert("name", name); + retval.insert("description", description); + retval.insert("available", true); + + return retval; +} + + +QHash EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type type) +{ + switch (type) + { + case AbstractAudioEffect::EffectAudioEqualizer: + return constructEffectDescription(QObject::tr("audio equalizer"), "Audio equalizer."); + case AbstractAudioEffect::EffectBassBoost: + return constructEffectDescription(QObject::tr("Bass boost"), "Bass boost."); + case AbstractAudioEffect::EffectDistanceAttenuation: + return constructEffectDescription(QObject::tr("Distance Attenuation"), "Distance Attenuation."); + case AbstractAudioEffect::EffectEnvironmentalReverb: + return constructEffectDescription(QObject::tr("Environmental Reverb"), "Environmental Reverb."); + case AbstractAudioEffect::EffectListenerOrientation: + return constructEffectDescription(QObject::tr("Environmental Reverb"), "Environmental Reverb."); + case AbstractAudioEffect::EffectLoudness: + return constructEffectDescription(QObject::tr("Loudness"), "Loudness."); + //case EffectRoomLevel: + case AbstractAudioEffect::EffectSourceOrientation: + return constructEffectDescription(QObject::tr("Source Orientation"), "Source Orientation."); + case AbstractAudioEffect::EffectStereoWidening: + return constructEffectDescription(QObject::tr("Stereo Widening"), "Stereo Widening."); + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect type."); + return QHash(); +} + +AbstractAudioEffect *EffectFactory::createAudioEffect(AbstractAudioEffect::Type type, + QObject *parent) +{ + Q_ASSERT(parent); + + switch (type) + { + case AbstractAudioEffect::EffectBassBoost: + return new BassBoost(parent); + case AbstractAudioEffect::EffectAudioEqualizer: + return new AudioEqualizer(parent); + case AbstractAudioEffect::EffectDistanceAttenuation: + case AbstractAudioEffect::EffectEnvironmentalReverb: + case AbstractAudioEffect::EffectListenerOrientation: + case AbstractAudioEffect::EffectLoudness: + //AbstractAudioEffect::EffectRoomLevel, + case AbstractAudioEffect::EffectSourceOrientation: + case AbstractAudioEffect::EffectStereoWidening: + ; + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect."); + return 0; +} + +template +bool isEffectSupported() +{ + AudioPlayer audioPlayer; + + QScopedPointer eff; + TRAPD(errorCode, eff.reset(TEffect::NewL(*audioPlayer.player()))); + + return errorCode != KErrNone; +} + +QList EffectFactory::effectIndexes() +{ + QList retval; + + if (isEffectSupported()) + retval.append(AbstractAudioEffect::EffectAudioEqualizer); + + if (isEffectSupported()) + retval.append(AbstractAudioEffect::EffectBassBoost); + + if (isEffectSupported()) + retval.append(AbstractAudioEffect::EffectDistanceAttenuation); + + if (isEffectSupported()) + retval.append(AbstractAudioEffect::EffectEnvironmentalReverb); + + if (isEffectSupported()) + retval.append(AbstractAudioEffect::EffectLoudness); + + if (isEffectSupported()) + retval.append(AbstractAudioEffect::EffectListenerOrientation); + + if (isEffectSupported()) + retval.append(AbstractAudioEffect::EffectSourceOrientation); + + /* + if (isEffectSupported()) + retval.append(EffectRoomLevel); + */ + + if (isEffectSupported()) + retval.append(AbstractAudioEffect::EffectStereoWidening); + + return retval; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/effectfactory.h b/src/3rdparty/phonon/mmf/effectfactory.h new file mode 100644 index 0000000..d5dde27 --- /dev/null +++ b/src/3rdparty/phonon/mmf/effectfactory.h @@ -0,0 +1,76 @@ +/* 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_EFFECTFACTORY_H +#define PHONON_MMF_EFFECTFACTORY_H + +#include "abstractaudioeffect.h" + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ + +/** + * @short Contains utility functions related to effects. + */ +class EffectFactory +{ +public: + /** + * @short Creates an audio effect of type @p type. + */ + static AbstractAudioEffect *createAudioEffect(AbstractAudioEffect::Type type, + QObject *parent); + + /** + * @short Return the properties for effect @p type. + * + * This handles the effects for + * BackendInterface::objectDescriptionProperties(). + */ + static QHash audioEffectDescriptions(AbstractAudioEffect::Type type); + + /** + * @short Returns the indexes for the supported effects. + * + * This handles the effects for + * BackendInterface::objectDescriptionIndexes(). + */ + static QList effectIndexes(); + +private: + static inline QHash constructEffectDescription(const QString &name, + const QString &description); + + /** + * This class is not supposed to be instantiated, so disable + * the default constructor. + */ + inline EffectFactory(); + Q_DISABLE_COPY(EffectFactory); +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index a2a7e4d..4c7dc6d 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -16,12 +16,16 @@ along with this library. If not, see . */ +#include "audiooutput.h" #include "audioplayer.h" #include "defs.h" #include "dummyplayer.h" -#include "mediaobject.h" +#include "utils.h" #include "utils.h" #include "videoplayer.h" +#include "videowidget.h" + +#include "mediaobject.h" #include @@ -34,8 +38,8 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::MediaObject::MediaObject(QObject *parent) : QObject(parent) - , m_recognizerOpened(false) +MMF::MediaObject::MediaObject(QObject *parent) : MMF::MediaNode::MediaNode(parent) + , m_recognizerOpened(false) { m_player.reset(new DummyPlayer()); @@ -366,5 +370,41 @@ void MMF::MediaObject::setVideoOutput(VideoOutput* videoOutput) } +AbstractPlayer *MediaObject::abstractPlayer() const +{ + return m_player.data(); +} + +bool MediaObject::connectMediaNode(MediaNode *target) +{ + TRACE_CONTEXT(Backend::connect, EBackend); + + MediaNode::connectMediaNode(target); + + bool result = false; + + { + AudioOutput *const audioOutput = qobject_cast(target); + + if (audioOutput) { + TRACE("this 0x%08x -> audioOutput 0x%08x", this, audioOutput); + audioOutput->setVolumeObserver(this); + return true; + } + } + + { + VideoWidget *const videoWidget = qobject_cast(target); + + if (videoWidget) { + TRACE("this 0x%08x -> videoWidget 0x%08x", this, videoWidget); + this->setVideoOutput(&videoWidget->videoOutput()); + return true; + } + } + + return false; +} + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index c53b908..1f19068 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 "abstractplayer.h" +#include "mmf_medianode.h" #include "defs.h" #include "volumeobserver.h" @@ -42,9 +44,9 @@ class VideoOutput; /** * @short Facade class which wraps MMF client utility instance */ -class MediaObject : public QObject - , public MediaObjectInterface - , public VolumeObserver +class MediaObject : public MediaNode + , public MediaObjectInterface + , public VolumeObserver { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface) @@ -78,7 +80,14 @@ public: // VolumeObserver void volumeChanged(qreal volume); - void setVideoOutput(VideoOutput* videoOutput); + // MediaNode + virtual bool connectMediaNode(MediaNode *target); + + /** + * This class owns the AbstractPlayer, and will delete it upon + * destruction. + */ + AbstractPlayer *abstractPlayer() const; Q_SIGNALS: void totalTimeChanged(qint64 length); @@ -109,6 +118,8 @@ private: static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); private: + void setVideoOutput(VideoOutput* videoOutput); + // Audio / video media type recognition bool m_recognizerOpened; RApaLsSession m_recognizer; diff --git a/src/3rdparty/phonon/mmf/mmf_medianode.cpp b/src/3rdparty/phonon/mmf/mmf_medianode.cpp new file mode 100644 index 0000000..a210c49 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmf_medianode.cpp @@ -0,0 +1,63 @@ +/* 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 "mmf_medianode.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +MMF::MediaNode::MediaNode(QObject *parent) : QObject::QObject(parent) + , m_source(0) + , m_target(0) +{ +} + +bool MMF::MediaNode::connectMediaNode(MediaNode *target) +{ + m_target = target; + m_target->setSource(this); + return true; +} + +bool MMF::MediaNode::disconnectMediaNode(MediaNode *target) +{ + Q_UNUSED(target); + m_target = 0; + return false; +} + +void MMF::MediaNode::setSource(MediaNode *source) +{ + m_source = source; +} + +MMF::MediaNode *MMF::MediaNode::source() const +{ + return m_source; +} + +MMF::MediaNode *MMF::MediaNode::target() const +{ + return m_target; +} + + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/mmf_medianode.h b/src/3rdparty/phonon/mmf/mmf_medianode.h new file mode 100644 index 0000000..17917aa --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmf_medianode.h @@ -0,0 +1,79 @@ +/* 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_MEDIANODE_H +#define PHONON_MMF_MEDIANODE_H + +#include +#include +#include "audioplayer.h" + +QT_BEGIN_NAMESPACE + +/** + * @file mmf_medianode.h mmf_medianode.cpp + * + * This file starts with mmf_ in order to avoid clash with Phonon's + * medianode.h. The GStreamer backend has a file named medianode.h, but it + * isn't compiled with ABLD build system, which have problems with separating + * user and system include paths. + */ + +namespace Phonon +{ +namespace MMF +{ +/** + * @short Base class for all nodes in the MMF backend. + * + * MediaNode is the base class for all nodes in the chain for MMF. Currently + * they are: + * + * - MediaObject: a source of media + * - AbstractEffect: supplying audio effects + * - AudioOutput: pretty much a dummy interface, but is also MediaNode in order + * to simplify connection/disconnection. + * + * MediaNode provides spectatability into the chain, and also allows the + * connection code to be written in a polymorphic manner, instead of putting it + * all in the Backend class. + */ +class MediaNode : public QObject +{ + Q_OBJECT +public: + MediaNode(QObject *parent); + + virtual bool connectMediaNode(MediaNode *target); + virtual bool disconnectMediaNode(MediaNode *target); + void setSource(MediaNode *source); + + MediaNode *source() const; + MediaNode *target() const; + +private: + MediaNode *m_source; + MediaNode *m_target; +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index be3c752..67e245e 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -44,7 +44,7 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : QObject(parent) + : MediaNode(parent) , m_widget(new VideoOutput(parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index e2e1f33..89551b7 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -19,9 +19,11 @@ along with this library. If not, see . #ifndef PHONON_MMF_VIDEOWIDGET_H #define PHONON_MMF_VIDEOWIDGET_H +#include "mmf_medianode.h" + #include -#include -#include +#include +#include QT_BEGIN_NAMESPACE @@ -31,8 +33,8 @@ namespace MMF { class VideoOutput; -class VideoWidget : public QObject - , public Phonon::VideoWidgetInterface +class VideoWidget : public MediaNode + , public Phonon::VideoWidgetInterface { Q_OBJECT Q_INTERFACES(Phonon::VideoWidgetInterface) diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index dc18d20..4e764dc 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -1,3 +1,2 @@ -TEMPLATE = subdirs -SUBDIRS = objectdump plugin - +TEMPLATE = subdirs +SUBDIRS = objectdump plugin diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index 418d354..f3a6a9c 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -22,28 +22,38 @@ phonon_mmf_audio_drm { } HEADERS += \ - $$PHONON_MMF_DIR/abstractplayer.h \ + $$PHONON_MMF_DIR/abstractaudioeffect.h \ $$PHONON_MMF_DIR/abstractmediaplayer.h \ + $$PHONON_MMF_DIR/abstractplayer.h \ $$PHONON_MMF_DIR/audiooutput.h \ + $$PHONON_MMF_DIR/audioequalizer.h \ $$PHONON_MMF_DIR/audioplayer.h \ $$PHONON_MMF_DIR/backend.h \ + $$PHONON_MMF_DIR/bassboost.h \ $$PHONON_MMF_DIR/defs.h \ $$PHONON_MMF_DIR/dummyplayer.h \ + $$PHONON_MMF_DIR/effectfactory.h \ + $$PHONON_MMF_DIR/mmf_medianode.h \ $$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 + $$PHONON_MMF_DIR/volumeobserver.h SOURCES += \ + $$PHONON_MMF_DIR/abstractaudioeffect.cpp \ + $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ $$PHONON_MMF_DIR/abstractplayer.cpp \ - $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ $$PHONON_MMF_DIR/audiooutput.cpp \ + $$PHONON_MMF_DIR/audioequalizer.cpp \ $$PHONON_MMF_DIR/audioplayer.cpp \ $$PHONON_MMF_DIR/backend.cpp \ + $$PHONON_MMF_DIR/bassboost.cpp \ $$PHONON_MMF_DIR/dummyplayer.cpp \ + $$PHONON_MMF_DIR/effectfactory.cpp \ + $$PHONON_MMF_DIR/mmf_medianode.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/utils.cpp \ $$PHONON_MMF_DIR/videooutput.cpp \ @@ -51,15 +61,18 @@ SOURCES += \ $$PHONON_MMF_DIR/videowidget.cpp debug { - INCLUDEPATH += $$PHONON_MMF_DIR/objectdump - LIBS += -lobjectdump + INCLUDEPATH += $$PHONON_MMF_DIR/objectdump + LIBS += -lobjectdump } - -LIBS += -lmediaclientvideo # For CVideoPlayerUtility -LIBS += -lcone # For CCoeEnv -LIBS += -lws32 # For RWindow -LIBS += -lefsrv # For file server -LIBS += -lapgrfx -lapmime # For recognizer + +LIBS += -lmediaclientvideo # For CVideoPlayerUtility +LIBS += -lcone # For CCoeEnv +LIBS += -lws32 # For RWindow +LIBS += -lefsrv # For file server +LIBS += -lapgrfx -lapmime # For recognizer + +# These are for effects. +LIBS += -lAudioEqualizerEffect.lib -lBassBoostEffect.lib -lDistanceAttenuationEffect.lib -lDopplerBase.lib -lEffectBase.lib -lEnvironmentalReverbEffect.lib -lListenerDopplerEffect.lib -lListenerLocationEffect.lib -lListenerOrientationEffect.lib -lLocationBase.lib -lLoudnessEffect.lib -lOrientationBase.lib -lRoomLevelEffect.lib -lSourceDopplerEffect.lib -lSourceLocationEffect.lib -lSourceOrientationEffect.lib -lStereoWideningEffect.lib # 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 c4fb0864e229ff33e4b454c74116573a9ea79054 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 7 Sep 2009 01:22:32 +0200 Subject: Make the MediaObject propagation generic for all kinds of nodes. Previously the MediaObject propagation was only done for effects, but now it's for all kinds of nodes. This is needed for AudioOutput. --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 50 +++++----------------- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 14 +++---- src/3rdparty/phonon/mmf/audioequalizer.cpp | 3 +- src/3rdparty/phonon/mmf/audioequalizer.h | 2 +- src/3rdparty/phonon/mmf/audiooutput.cpp | 6 +++ src/3rdparty/phonon/mmf/audiooutput.h | 8 ++-- src/3rdparty/phonon/mmf/backend.cpp | 4 +- src/3rdparty/phonon/mmf/bassboost.cpp | 3 +- src/3rdparty/phonon/mmf/bassboost.h | 2 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 32 ++------------ src/3rdparty/phonon/mmf/mediaobject.h | 8 ++-- src/3rdparty/phonon/mmf/mmf_medianode.cpp | 56 ++++++++++++++++++++++++- src/3rdparty/phonon/mmf/mmf_medianode.h | 27 ++++++++++-- src/3rdparty/phonon/mmf/videowidget.cpp | 7 ++++ src/3rdparty/phonon/mmf/videowidget.h | 3 ++ src/3rdparty/phonon/phonon/path.cpp | 8 ++-- 16 files changed, 133 insertions(+), 100 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index 4c876e1..665b9e4 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -29,7 +29,6 @@ using namespace Phonon::MMF; AbstractAudioEffect::AbstractAudioEffect(QObject *parent, const QList ¶ms) : MediaNode::MediaNode(parent) , m_params(params) - , m_isApplied(false) { } @@ -55,50 +54,21 @@ QVariant AbstractAudioEffect::parameterValue(const EffectParameter &queriedParam return val; } -void AbstractAudioEffect::setParameterValue(const EffectParameter ¶m, - const QVariant &newValue) +bool AbstractAudioEffect::activateOnMediaObject(MediaObject *mo) { - m_values.insert(param.id(), newValue); - parameterChanged(param.id(), newValue); -} + AudioPlayer *const ap = qobject_cast(mo->abstractPlayer()); -bool AbstractAudioEffect::activateBackwardsInChain(MediaNode *target) -{ - // TODO we need to walk forward too. - MediaNode *current = target; - - while (current) { - MMF::MediaObject *const mo = qobject_cast(current); - if(!mo) - continue; - - AudioPlayer *const ap = qobject_cast(mo->abstractPlayer()); - - if (ap) { - activateOn(ap->player()); - // There might be stuff before the mediaobject, but - // that's undefined for us. - return true; - } - else - current = current->source(); - } - - return false; + if (ap) + return activateOn(ap->player()); + else + return true; } -bool AbstractAudioEffect::connectMediaNode(MediaNode *target) +void AbstractAudioEffect::setParameterValue(const EffectParameter ¶m, + const QVariant &newValue) { - /** - * We first call this function, so source() and target() - * is properly set up. - */ - MediaNode::connectMediaNode(target); - - if (!m_isApplied && activateBackwardsInChain(target)) - m_isApplied = true; - - return true; + m_values.insert(param.id(), newValue); + parameterChanged(param.id(), newValue); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 4c2eba3..cf2fb3c 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -66,7 +66,6 @@ public: virtual void setParameterValue(const EffectParameter &, const QVariant &newValue); - virtual bool connectMediaNode(MediaNode *target); virtual bool disconnectMediaNode(MediaNode *target); enum Type @@ -83,20 +82,19 @@ public: }; protected: - virtual void activateOn(CPlayerType *player) = 0; + virtual bool activateOn(CPlayerType *player) = 0; virtual void parameterChanged(const int id, const QVariant &value) = 0; - QScopedPointer m_effect; -private: /** - * From @p target, we walk the chain backwards and try to find the media - * object, and apply ourselves to that one. + * Part of the implementation of AbstractAudioEffect. Forwards the call to + * activateOn(), essentially. */ - bool activateBackwardsInChain(MediaNode *target); + virtual bool activateOnMediaObject(MediaObject *mo); + QScopedPointer m_effect; +private: const QList m_params; - bool m_isApplied; QHash m_values; }; } diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 28a8741..013412d 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -37,9 +37,10 @@ void AudioEqualizer::parameterChanged(const int pid, TRAP_IGNORE(eq()->SetBandLevelL(pid, value.toInt())); } -void AudioEqualizer::activateOn(CPlayerType *player) +bool AudioEqualizer::activateOn(CPlayerType *player) { m_effect.reset(CAudioEqualizer::NewL(*player)); + return true; } CAudioEqualizer *AudioEqualizer::eq() const diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index 5ef2af9..d072bf1 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -47,7 +47,7 @@ protected: virtual void parameterChanged(const int id, const QVariant &value); - virtual void activateOn(CPlayerType *player); + virtual bool activateOn(CPlayerType *player); private: inline CAudioEqualizer *eq() const; diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index d2e7d76..20130ad 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -20,6 +20,7 @@ along with this library. If not, see . #include "audiooutput.h" #include "defs.h" +#include "mediaobject.h" #include "utils.h" #include "volumeobserver.h" @@ -91,5 +92,10 @@ void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer) } } +bool MMF::AudioOutput::activateOnMediaObject(MediaObject *mo) +{ + setVolumeObserver(mo); + return true; +} QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 0d3cca7..0a962a9 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -70,16 +70,16 @@ public: */ virtual bool setOutputDevice(const Phonon::AudioOutputDevice &); - /** - * Called by backend when nodes are connected. - */ - void setVolumeObserver(VolumeObserver* observer); +protected: + virtual bool activateOnMediaObject(MediaObject *mo); Q_SIGNALS: void volumeChanged(qreal volume); void audioDeviceFailed(); private: + void setVolumeObserver(VolumeObserver* observer); + qreal m_volume; // Not owned diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index d05b543..fe1b1a7 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -132,9 +132,7 @@ bool Backend::connectNodes(QObject *source, QObject *target) MediaNode *const mediaSource = static_cast(source); MediaNode *const mediaTarget = static_cast(target); - mediaSource->connectMediaNode(mediaTarget); - - return false; + return mediaSource->connectMediaNode(mediaTarget); } bool Backend::disconnectNodes(QObject *source, QObject *target) diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index ca9d5cc..f3db9d9 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -36,9 +36,10 @@ void BassBoost::parameterChanged(const int, // We should never be called, because we have no parameters. } -void BassBoost::activateOn(CPlayerType *player) +bool BassBoost::activateOn(CPlayerType *player) { m_effect.reset(CBassBoost::NewL(*player, true)); + return true; } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index bf3c6c4..68ea272 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -45,7 +45,7 @@ protected: virtual void parameterChanged(const int id, const QVariant &value); - virtual void activateOn(CPlayerType *player); + virtual bool activateOn(CPlayerType *player); private: QScopedPointer m_bassBoost; diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 4c7dc6d..f09b488 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -359,7 +359,6 @@ void MMF::MediaObject::volumeChanged(qreal volume) m_player->volumeChanged(volume); } - //----------------------------------------------------------------------------- // Video output //----------------------------------------------------------------------------- @@ -375,35 +374,10 @@ AbstractPlayer *MediaObject::abstractPlayer() const return m_player.data(); } -bool MediaObject::connectMediaNode(MediaNode *target) +bool MediaObject::activateOnMediaObject(MediaObject *) { - TRACE_CONTEXT(Backend::connect, EBackend); - - MediaNode::connectMediaNode(target); - - bool result = false; - - { - AudioOutput *const audioOutput = qobject_cast(target); - - if (audioOutput) { - TRACE("this 0x%08x -> audioOutput 0x%08x", this, audioOutput); - audioOutput->setVolumeObserver(this); - return true; - } - } - - { - VideoWidget *const videoWidget = qobject_cast(target); - - if (videoWidget) { - TRACE("this 0x%08x -> videoWidget 0x%08x", this, videoWidget); - this->setVideoOutput(&videoWidget->videoOutput()); - return true; - } - } - - return false; + // Guess what, we do nothing. + return true; } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 1f19068..409918d 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -80,15 +80,16 @@ public: // VolumeObserver void volumeChanged(qreal volume); - // MediaNode - virtual bool connectMediaNode(MediaNode *target); - /** * This class owns the AbstractPlayer, and will delete it upon * destruction. */ AbstractPlayer *abstractPlayer() const; + void setVideoOutput(VideoOutput* videoOutput); + + virtual bool activateOnMediaObject(MediaObject *); + Q_SIGNALS: void totalTimeChanged(qint64 length); void hasVideoChanged(bool hasVideo); @@ -118,7 +119,6 @@ private: static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); private: - void setVideoOutput(VideoOutput* videoOutput); // Audio / video media type recognition bool m_recognizerOpened; diff --git a/src/3rdparty/phonon/mmf/mmf_medianode.cpp b/src/3rdparty/phonon/mmf/mmf_medianode.cpp index a210c49..54c51a0 100644 --- a/src/3rdparty/phonon/mmf/mmf_medianode.cpp +++ b/src/3rdparty/phonon/mmf/mmf_medianode.cpp @@ -16,6 +16,8 @@ along with this library. If not, see . */ +#include "mediaobject.h" + #include "mmf_medianode.h" QT_BEGIN_NAMESPACE @@ -26,6 +28,7 @@ using namespace Phonon::MMF; MMF::MediaNode::MediaNode(QObject *parent) : QObject::QObject(parent) , m_source(0) , m_target(0) + , m_isApplied(false) { } @@ -33,13 +36,15 @@ bool MMF::MediaNode::connectMediaNode(MediaNode *target) { m_target = target; m_target->setSource(this); - return true; + + return applyNodesOnMediaObject(target); } bool MMF::MediaNode::disconnectMediaNode(MediaNode *target) { Q_UNUSED(target); m_target = 0; + m_isApplied = false; return false; } @@ -58,6 +63,55 @@ MMF::MediaNode *MMF::MediaNode::target() const return m_target; } +bool MediaNode::applyNodesOnMediaObject(MediaNode *) +{ + // Algorithmically, this can be expressed in a more efficient way by + // exercising available assumptions, but it complicates code for input + // data(length of the graph) which typically is very small. + + // First, we go to the very beginning of the graph. + MediaNode *current = this; + do { + MediaNode *const candidate = current->source(); + if (candidate) + current = candidate; + else + break; + } + while (current); + + // Now we do two things, while walking to the other end: + // 1. Find the MediaObject, if present + // 2. Collect a list of all unapplied MediaNodes + + QList unapplied; + MMF::MediaObject *mo = 0; + + do { + if (!current->m_isApplied) + unapplied.append(current); + + if (!mo) + mo = qobject_cast(current); + + current = current->target(); + } + while (current); + + // Now, lets activate all the objects, if we found the MediaObject. + + if (mo) { + for (int i = 0; i < unapplied.count(); ++i) { + MediaNode *const at = unapplied.at(i); + + // We don't want to apply MediaObject on itself. + if (at != mo) + at->activateOnMediaObject(mo); + } + } + + return true; +} QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/mmf_medianode.h b/src/3rdparty/phonon/mmf/mmf_medianode.h index 17917aa..4616ff1 100644 --- a/src/3rdparty/phonon/mmf/mmf_medianode.h +++ b/src/3rdparty/phonon/mmf/mmf_medianode.h @@ -38,6 +38,8 @@ namespace Phonon { namespace MMF { +class MediaObject; + /** * @short Base class for all nodes in the MMF backend. * @@ -51,7 +53,8 @@ namespace MMF * * MediaNode provides spectatability into the chain, and also allows the * connection code to be written in a polymorphic manner, instead of putting it - * all in the Backend class. + * all in the Backend class. Due to that MMF has no concept of chaining, the + * order of the nodes in the graph has no meaning. */ class MediaNode : public QObject { @@ -66,9 +69,27 @@ public: MediaNode *source() const; MediaNode *target() const; +protected: + /** + * When connectMediaNode() is called and a MediaObject is part of + * the its graph, this function will be called for each MediaNode in the + * graph for which it hasn't been called yet. + * + * The caller guarantees that @p mo is always non-null. + */ + virtual bool activateOnMediaObject(MediaObject *mo) = 0; + private: - MediaNode *m_source; - MediaNode *m_target; + /** + * Finds a MediaObject anywhere in the graph @p target is apart of, and + * calls activateOnMediaObject() for all MediaNodes in the graph for which + * it hasn't been applied to already. + */ + bool applyNodesOnMediaObject(MediaNode *target); + + MediaNode * m_source; + MediaNode * m_target; + bool m_isApplied; }; } } diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index 67e245e..ac93929 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -16,8 +16,10 @@ along with this library. If not, see . */ +#include "mediaobject.h" #include "utils.h" #include "videooutput.h" + #include "videowidget.h" QT_BEGIN_NAMESPACE @@ -161,6 +163,11 @@ VideoOutput& MMF::VideoWidget::videoOutput() return *static_cast(widget()); } +bool MMF::VideoWidget::activateOnMediaObject(MediaObject *mo) +{ + mo->setVideoOutput(&videoOutput()); + return true; +} QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 89551b7..970f749 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -60,6 +60,9 @@ public: VideoOutput& videoOutput(); +protected: + virtual bool activateOnMediaObject(MediaObject *mo); + private: QScopedPointer m_widget; diff --git a/src/3rdparty/phonon/phonon/path.cpp b/src/3rdparty/phonon/phonon/path.cpp index aec8d05..ef3530c 100644 --- a/src/3rdparty/phonon/phonon/path.cpp +++ b/src/3rdparty/phonon/phonon/path.cpp @@ -310,8 +310,8 @@ bool PathPrivate::executeTransaction( const QList &disconnections, if (!transaction) return false; - QList::const_iterator it = disconnections.begin(); - for(;it != disconnections.end();++it) { + QList::const_iterator it = disconnections.constBegin(); + for(;it != disconnections.constEnd();++it) { const QObjectPair &pair = *it; if (!backend->disconnectNodes(pair.first, pair.second)) { @@ -327,8 +327,8 @@ bool PathPrivate::executeTransaction( const QList &disconnections, } } - for(it = connections.begin(); it != connections.end();++it) { - const QObjectPair &pair = *it; + for(it = connections.constBegin(); it != connections.constEnd(); ++it) { + const QObjectPair pair = *it; if (!backend->connectNodes(pair.first, pair.second)) { //Error: a connection failed QList::const_iterator it2 = connections.begin(); -- cgit v0.12 From 4bdd75bd721610b992b01c9ebc659da2a8730480 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 8 Sep 2009 23:22:54 +0200 Subject: Improve signal connections between MediaObject and AbstractPlayer. MediaObject deals with an AbstractPlayer, so make sure we have the signals declared in that base class, instead of individually in each sub-class. --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 3 ++- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 6 ------ src/3rdparty/phonon/mmf/abstractplayer.h | 8 ++++++++ src/3rdparty/phonon/mmf/audioplayer.h | 3 --- src/3rdparty/phonon/mmf/videoplayer.h | 4 ---- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 1e032f3..bdf188d 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -443,7 +443,8 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds void MMF::AbstractMediaPlayer::tick() { - emit tick(currentTime()); + // For the MWC compiler, we need to qualify the base class. + emit MMF::AbstractPlayer::tick(currentTime()); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index f11b559..e69f325 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -68,7 +68,6 @@ protected: // AbstractPlayer virtual void doSetTickInterval(qint32 interval); -protected: virtual void doPlay() = 0; virtual void doPause() = 0; virtual void doStop() = 0; @@ -121,11 +120,6 @@ protected: 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 diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 0f846ca..72d0a3b 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -88,6 +88,14 @@ public: void setVideoOutput(VideoOutput* videoOutput); +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void finished(); + void tick(qint64 time); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + + protected: virtual void videoOutputChanged(); diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 3245159..f16de1d 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -87,9 +87,6 @@ public: #endif CPlayerType *player() const; -Q_SIGNALS: - void totalTimeChanged(qint64 length); - void finished(); private: void construct(); diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index 887a26b..5761ce7 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -73,10 +73,6 @@ public: // VideoOutputObserver virtual void videoOutputRegionChanged(); -Q_SIGNALS: - void totalTimeChanged(qint64 length); - void finished(); - private: void construct(); VideoOutput& videoOutput(); -- cgit v0.12 From 264a6a562f7870a9fd1af065aef4e979808bd1d2 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 9 Sep 2009 14:55:35 +0100 Subject: Added epoc32/include/osextensions include path, necessary to compile in S60 5.0 environment --- src/plugins/phonon/mmf/plugin/plugin.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index f3a6a9c..c343831 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -21,6 +21,8 @@ phonon_mmf_audio_drm { LIBS += -lmediaclientaudio } +INCLUDEPATH += /epoc32/include/osextensions + HEADERS += \ $$PHONON_MMF_DIR/abstractaudioeffect.h \ $$PHONON_MMF_DIR/abstractmediaplayer.h \ -- cgit v0.12 From 087249f6f1bdceeb50d9100fe0acd5fb2938d9f4 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 10 Sep 2009 00:37:51 +0200 Subject: Simplify inclusion of osextensions. --- src/plugins/phonon/mmf/plugin/plugin.pro | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index c343831..35d14ce 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -11,16 +11,14 @@ PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf phonon_mmf_audio_drm { LIBS += -lDrmAudioPlayUtility - # 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 } +# In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this folder, as +# opposed to the public, where it is placed in epoc32/include. In some cases +# it's needed for other headers as well. INCLUDEPATH += /epoc32/include/osextensions HEADERS += \ -- cgit v0.12 From f6495ee7a1427e377559e25616a35ba11f34e9c1 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 10 Sep 2009 12:57:07 +0100 Subject: Fixed problems with compiling for ARMV5 - Forward declaration of QScopedPointer containee type was causing an error - Audio effect libraries were declared in the .pro file as e.g. -lBassBoostEffect.lib, causing toolchain to try to link statically - Added several missing MMF:: namespace qualifiers --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 1 - src/3rdparty/phonon/mmf/abstractaudioeffect.h | 4 ++-- src/3rdparty/phonon/mmf/audioequalizer.cpp | 2 -- src/3rdparty/phonon/mmf/audioequalizer.h | 3 +-- src/3rdparty/phonon/mmf/bassboost.cpp | 2 -- src/3rdparty/phonon/mmf/bassboost.h | 3 +-- src/3rdparty/phonon/mmf/effectfactory.h | 2 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 4 ++-- src/3rdparty/phonon/mmf/mmf_medianode.cpp | 4 ++-- src/plugins/phonon/mmf/plugin/plugin.pro | 2 +- 10 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index 665b9e4..b3155a6 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -16,7 +16,6 @@ along with this library. If not, see . */ -#include #include "mediaobject.h" #include "abstractaudioeffect.h" diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index cf2fb3c..9957e25 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -23,12 +23,12 @@ along with this library. If not, see . #include +#include + #include #include #include "audioplayer.h" -class CAudioEffect; - QT_BEGIN_NAMESPACE namespace Phonon diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 013412d..78c6ff7 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -16,8 +16,6 @@ along with this library. If not, see . */ -#include - #include "audioequalizer.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index d072bf1..6415411 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -19,10 +19,9 @@ along with this library. If not, see . #ifndef PHONON_MMF_AUDIOEQUALIZER_H #define PHONON_MMF_AUDIOEQUALIZER_H +#include #include "abstractaudioeffect.h" -class CAudioEqualizer; - QT_BEGIN_NAMESPACE namespace Phonon diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index f3db9d9..fc88d03 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -16,8 +16,6 @@ along with this library. If not, see . */ -#include - #include "bassboost.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index 68ea272..c16393a 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -19,10 +19,9 @@ along with this library. If not, see . #ifndef PHONON_MMF_BASSBOOST_H #define PHONON_MMF_BASSBOOST_H +#include #include "abstractaudioeffect.h" -class CBassBoost; - QT_BEGIN_NAMESPACE namespace Phonon diff --git a/src/3rdparty/phonon/mmf/effectfactory.h b/src/3rdparty/phonon/mmf/effectfactory.h index d5dde27..e83ad15 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.h +++ b/src/3rdparty/phonon/mmf/effectfactory.h @@ -65,7 +65,7 @@ private: * the default constructor. */ inline EffectFactory(); - Q_DISABLE_COPY(EffectFactory); + Q_DISABLE_COPY(EffectFactory) }; } } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index f09b488..cf968f3 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -369,12 +369,12 @@ void MMF::MediaObject::setVideoOutput(VideoOutput* videoOutput) } -AbstractPlayer *MediaObject::abstractPlayer() const +AbstractPlayer *MMF::MediaObject::abstractPlayer() const { return m_player.data(); } -bool MediaObject::activateOnMediaObject(MediaObject *) +bool MMF::MediaObject::activateOnMediaObject(MediaObject *) { // Guess what, we do nothing. return true; diff --git a/src/3rdparty/phonon/mmf/mmf_medianode.cpp b/src/3rdparty/phonon/mmf/mmf_medianode.cpp index 54c51a0..a9eee58 100644 --- a/src/3rdparty/phonon/mmf/mmf_medianode.cpp +++ b/src/3rdparty/phonon/mmf/mmf_medianode.cpp @@ -63,14 +63,14 @@ MMF::MediaNode *MMF::MediaNode::target() const return m_target; } -bool MediaNode::applyNodesOnMediaObject(MediaNode *) +bool MMF::MediaNode::applyNodesOnMediaObject(MediaNode *) { // Algorithmically, this can be expressed in a more efficient way by // exercising available assumptions, but it complicates code for input // data(length of the graph) which typically is very small. // First, we go to the very beginning of the graph. - MediaNode *current = this; + MMF::MediaNode *current = this; do { MediaNode *const candidate = current->source(); if (candidate) diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index c343831..e24252c 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -74,7 +74,7 @@ LIBS += -lefsrv # For file server LIBS += -lapgrfx -lapmime # For recognizer # These are for effects. -LIBS += -lAudioEqualizerEffect.lib -lBassBoostEffect.lib -lDistanceAttenuationEffect.lib -lDopplerBase.lib -lEffectBase.lib -lEnvironmentalReverbEffect.lib -lListenerDopplerEffect.lib -lListenerLocationEffect.lib -lListenerOrientationEffect.lib -lLocationBase.lib -lLoudnessEffect.lib -lOrientationBase.lib -lRoomLevelEffect.lib -lSourceDopplerEffect.lib -lSourceLocationEffect.lib -lSourceOrientationEffect.lib -lStereoWideningEffect.lib +LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lRoomLevelEffect -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect # 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 2b1a5032018a9636a391b78ef5681e59ca6404bc Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 10 Sep 2009 02:23:00 +0200 Subject: QScopedPointer makes code simpler. --- src/3rdparty/phonon/mmf/videoplayer.cpp | 6 ++---- src/3rdparty/phonon/mmf/videoplayer.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index b4f3d35..4f9834a 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -86,14 +86,14 @@ void MMF::VideoPlayer::construct() // and respond to future showEvents from the videoOutput widget. TRAPD(err, - m_player = CVideoPlayerUtility::NewL + m_player.reset(CVideoPlayerUtility::NewL ( *this, priority, preference, *m_wsSession, *m_screenDevice, *m_window, m_windowRect, m_clipRect - ) + )) ); if (KErrNone != err) { @@ -108,8 +108,6 @@ MMF::VideoPlayer::~VideoPlayer() TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); TRACE_ENTRY_0(); - delete m_player; - TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index 5761ce7..4fba68b 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -86,7 +86,7 @@ private: void updateMmfOutput(); private: - CVideoPlayerUtility* m_player; + QScopedPointer m_player; QScopedPointer m_dummyVideoOutput; // Not owned -- cgit v0.12 From 0e0d716684f90e1ba5f34dc7ad961bc323b711ed Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 10 Sep 2009 04:01:34 +0200 Subject: Remove an unimplementable TODO. MvpuoOpenComplete's TInt aError doesn't map to Phonon::ErrorType. --- src/3rdparty/phonon/mmf/videoplayer.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 4f9834a..c18af9c 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -217,12 +217,10 @@ void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); - if (KErrNone == aError) { + if (KErrNone == aError) m_player->Prepare(); - } else { - // TODO: set different error states according to value of aError? + else setError(NormalError); - } TRACE_EXIT_0(); } -- cgit v0.12 From d5c4411081a6c6d58ed3ccbd134c423f08b8ece5 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 10 Sep 2009 04:15:16 +0200 Subject: Fix whitespace. --- src/3rdparty/phonon/mmf/videoplayer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index 4fba68b..2878d6a 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -38,9 +38,9 @@ namespace MMF * How to * play a video file using CVideoPlayerUtility */ -class VideoPlayer : public AbstractMediaPlayer - , public MVideoPlayerUtilityObserver - , public VideoOutputObserver +class VideoPlayer : public AbstractMediaPlayer + , public MVideoPlayerUtilityObserver + , public VideoOutputObserver { Q_OBJECT -- cgit v0.12 From 331af4d007cc57f6bbb5e2afa5574b670eda0f6d Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 10 Sep 2009 04:19:19 +0200 Subject: Invoke on appropriate states in seek(). --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 28 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index bdf188d..2f2146b 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -173,15 +173,29 @@ 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(); + switch (m_state) { + // Fallthrough all these + case GroundState: + case StoppedState: + case PausedState: + case PlayingState: + case LoadingState: + { + const bool tickTimerWasRunning = m_tickTimer->isActive(); + stopTickTimer(); - doSeek(ms); + doSeek(ms); - if (tickTimerWasRunning) { - startTickTimer(); + if (tickTimerWasRunning) { + startTickTimer(); + } + break; + } + case BufferingState: + // Fallthrough + case ErrorState: + // Do nothing + break; } TRACE_EXIT_0(); -- cgit v0.12 From 17ed3f3c55b0510d8a53de1331bf1fb33c58e4ce Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 10 Sep 2009 05:27:03 +0200 Subject: Remove an unimplementable TODO. MvpuoPrepareComplete()'s TInt aError doesn't map to Phonon::ErrorType. --- src/3rdparty/phonon/mmf/videoplayer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index c18af9c..0d98256 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -248,7 +248,6 @@ void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) emit totalTimeChanged(totalTime()); changeState(StoppedState); } else { - // TODO: set different error states according to value of aError? setError(NormalError); } -- cgit v0.12 From 1ac3f2b02f3d17a699aee077f614f52c1b7d8363 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 14 Sep 2009 12:58:05 +0200 Subject: Reserve & use UIDs. --- src/plugins/phonon/mmf/objectdump/objectdump.pro | 5 ++++- src/plugins/phonon/mmf/plugin/plugin.pro | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/phonon/mmf/objectdump/objectdump.pro b/src/plugins/phonon/mmf/objectdump/objectdump.pro index b9e2017..4b1245e 100644 --- a/src/plugins/phonon/mmf/objectdump/objectdump.pro +++ b/src/plugins/phonon/mmf/objectdump/objectdump.pro @@ -17,12 +17,15 @@ SOURCES += \ symbian { HEADERS += $$OBJECTDUMP_DIR/objectdump_symbian.h - SOURCES += $$OBJECTDUMP_DIR/objectdump_symbian.cpp + SOURCES += $$OBJECTDUMP_DIR/objectdump_symbian.cpp LIBS += -lcone LIBS += -lws32 TARGET.CAPABILITY = all -tcb + } else { SOURCES += $$OBJECTDUMP_DIR/objectdump_stub.cpp } + +TARGET.UID3=0x2001E62A diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index 100ccb9..c7aad69 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -86,7 +86,5 @@ include(../../../qpluginbase.pri) # 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. -symbian:TARGET.UID3=0x2001E627 +TARGET.UID3=0x2001E629 -- cgit v0.12 From d37930e3387b7c7812445234640973134383be25 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 14 Sep 2009 13:13:28 +0200 Subject: Fix bug, it's phonon-backend, not phonon_backend. --- src/s60installs/qt_libs.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/qt_libs.pro index cd4219a..d04dd99 100644 --- a/src/s60installs/qt_libs.pro +++ b/src/s60installs/qt_libs.pro @@ -67,8 +67,8 @@ 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 + contains(QT_CONFIG, phonon-backend) { + phonon_backend_plugins.sources += phonon_mmf.dll objectdump.dll phonon_backend_plugins.path = $$QT_PLUGINS_BASE_DIR/phonon_backend DEPLOYMENT += phonon_backend_plugins } -- cgit v0.12 From b6b365696ebdbb3dad1a58c5506cacc948057cb5 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 14 Sep 2009 14:51:31 +0200 Subject: Rename objectdump to mmfphonondebug in order to avoid conflicts. --- .../phonon/mmf/mmfphonondebug/objectdump.cpp | 527 +++++++++++++++++++++ .../phonon/mmf/mmfphonondebug/objectdump.h | 166 +++++++ .../phonon/mmf/mmfphonondebug/objectdump_global.h | 30 ++ .../phonon/mmf/mmfphonondebug/objectdump_stub.cpp | 40 ++ .../mmf/mmfphonondebug/objectdump_symbian.cpp | 129 +++++ .../phonon/mmf/mmfphonondebug/objectdump_symbian.h | 56 +++ .../phonon/mmf/mmfphonondebug/objecttree.cpp | 102 ++++ .../phonon/mmf/mmfphonondebug/objecttree.h | 117 +++++ src/3rdparty/phonon/mmf/objectdump/objectdump.cpp | 527 --------------------- src/3rdparty/phonon/mmf/objectdump/objectdump.h | 166 ------- .../phonon/mmf/objectdump/objectdump_global.h | 30 -- .../phonon/mmf/objectdump/objectdump_stub.cpp | 40 -- .../phonon/mmf/objectdump/objectdump_symbian.cpp | 129 ----- .../phonon/mmf/objectdump/objectdump_symbian.h | 56 --- src/3rdparty/phonon/mmf/objectdump/objecttree.cpp | 102 ---- src/3rdparty/phonon/mmf/objectdump/objecttree.h | 117 ----- src/3rdparty/phonon/mmf/videooutput.cpp | 2 +- src/plugins/phonon/mmf/mmf.pro | 2 +- .../phonon/mmf/mmfphonondebug/mmfphonondebug.pro | 31 ++ src/plugins/phonon/mmf/objectdump/objectdump.pro | 31 -- src/s60installs/qt_libs.pro | 3 +- 21 files changed, 1202 insertions(+), 1201 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp create mode 100644 src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.h create mode 100644 src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_global.h create mode 100644 src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_stub.cpp create mode 100644 src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp create mode 100644 src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.h create mode 100644 src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.cpp create mode 100644 src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.h delete mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump.cpp delete mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump.h delete mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_global.h delete mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp delete mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp delete mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h delete mode 100644 src/3rdparty/phonon/mmf/objectdump/objecttree.cpp delete mode 100644 src/3rdparty/phonon/mmf/objectdump/objecttree.h create mode 100644 src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro delete mode 100644 src/plugins/phonon/mmf/objectdump/objectdump.pro diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp new file mode 100644 index 0000000..50c6bf8 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp @@ -0,0 +1,527 @@ +/* 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 +#include + +#include "objectdump.h" +#include "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +//----------------------------------------------------------------------------- +// QObjectAnnotator +//----------------------------------------------------------------------------- + +QAnnotator::~QAnnotator() +{ + +} + + +//----------------------------------------------------------------------------- +// Annotators +//----------------------------------------------------------------------------- + +QList QAnnotatorBasic::annotation(const QObject& object) +{ + QList result; + + QByteArray array; + QTextStream stream(&array); + + stream << '[' << &object << ']'; + stream << ' '; + stream << object.metaObject()->className(); + + if(object.objectName() != "") + stream << " \"" << object.objectName() << '"'; + + if(object.isWidgetType()) + stream << " isWidget"; + + stream.flush(); + result.append(array); + return result; +} + +QList QAnnotatorWidget::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + QByteArray array; + QTextStream stream(&array); + + stream << "widget: "; + + if(widget->isVisible()) + stream << "visible "; + else + stream << "invisible "; + + stream << widget->x() << ',' << widget->y() << ' '; + stream << widget->size().width() << 'x'<< widget->size().height() << ' '; + + stream << "hint " << widget->sizeHint().width() << 'x' << widget->sizeHint().height(); + + stream.flush(); + result.append(array); + } + + return result; +} + + +//----------------------------------------------------------------------------- +// Base class for QDumperPrivate, QVisitorPrivate +//----------------------------------------------------------------------------- + +class QDumperBase +{ +public: + QDumperBase(); + ~QDumperBase(); + + void setPrefix(const QString& prefix); + void addAnnotator(QAnnotator* annotator); + +protected: + QByteArray m_prefix; + QList m_annotators; + +}; + +QDumperBase::QDumperBase() +{ + +} + +QDumperBase::~QDumperBase() +{ + QAnnotator* annotator; + foreach(annotator, m_annotators) + delete annotator; +} + +void QDumperBase::setPrefix(const QString& prefix) +{ + m_prefix = prefix.count() + ? (prefix + " ").toAscii() + : prefix.toAscii(); +} + +void QDumperBase::addAnnotator(QAnnotator* annotator) +{ + // Protect against an exception occurring during QList::append + QScopedPointer holder(annotator); + m_annotators.append(annotator); + holder.take(); +} + + +//----------------------------------------------------------------------------- +// QDumper +//----------------------------------------------------------------------------- + +class QDumperPrivate : public QDumperBase +{ +public: + QDumperPrivate(); + ~QDumperPrivate(); + + void dumpObject(const QObject& object); + +}; + + +QDumperPrivate::QDumperPrivate() +{ + +} + +QDumperPrivate::~QDumperPrivate() +{ + +} + +void QDumperPrivate::dumpObject(const QObject& object) +{ + QAnnotator* annotator; + foreach(annotator, m_annotators) { + + const QList annotations = annotator->annotation(object); + QByteArray annotation; + foreach(annotation, annotations) { + QByteArray buffer(m_prefix); + buffer.append(annotation); + qDebug() << buffer.constData(); + } + } +} + + +QDumper::QDumper() + : d_ptr(new QDumperPrivate) +{ + +} + +QDumper::~QDumper() +{ + +} + +void QDumper::setPrefix(const QString& prefix) +{ + d_func()->setPrefix(prefix); +} + +void QDumper::addAnnotator(QAnnotator* annotator) +{ + d_func()->addAnnotator(annotator); +} + +void QDumper::dumpObject(const QObject& object) +{ + d_func()->dumpObject(object); +} + + +//----------------------------------------------------------------------------- +// QVisitor +//----------------------------------------------------------------------------- + +class QVisitorPrivate : public QDumperBase +{ +public: + QVisitorPrivate(); + ~QVisitorPrivate(); + + void setIndent(unsigned indent); + + void visitNode(const QObject& object); + void visitComplete(); + +private: + class Node + { + public: + Node(); + ~Node(); + + QList m_annotation; + QList m_children; + + typedef QList::const_iterator child_iterator; + }; + +private: + Node* findNode(const QObject* object) const; + QByteArray branchBuffer(const QList& branches, bool isNodeLine, bool isLastChild) const; + void dumpRecursive(const Node& node, QList branches, bool isLastChild); + void dumpNode(const Node& node, const QList& branches, bool isLastChild); + +private: + unsigned m_indent; + + QScopedPointer m_root; + + // Hash table used to associate internal nodes with QObjects + typedef QHash Hash; + Hash m_hash; +}; + +static const unsigned DefaultIndent = 2; + +QVisitorPrivate::QVisitorPrivate() + : m_indent(DefaultIndent) +{ + +} + +QVisitorPrivate::~QVisitorPrivate() +{ + +} + +void QVisitorPrivate::setIndent(unsigned indent) +{ + m_indent = indent; +} + +// Builds up a mirror of the object tree, rooted in m_root, with each node +// storing annotations generated by +void QVisitorPrivate::visitNode(const QObject& object) +{ + QObject* const objectParent = object.parent(); + Node* const nodeParent = objectParent ? findNode(objectParent) : NULL; + + // Create a new node and store in scoped pointer for exception safety + Node* node = new Node; + QScopedPointer nodePtr(node); + + // Associate node with QObject + m_hash.insert(&object, node); + + // Insert node into internal tree + if(nodeParent) + { + nodeParent->m_children.append(nodePtr.take()); + } + else + { + Q_ASSERT(m_root.isNull()); + m_root.reset(nodePtr.take()); + } + + // Generate and store annotations + QAnnotator* annotator; + foreach(annotator, m_annotators) + node->m_annotation.append( annotator->annotation(object) ); +} + +void QVisitorPrivate::visitComplete() +{ + QList branches; + static const bool isLastChild = true; + dumpRecursive(*m_root, branches, isLastChild); + m_root.reset(NULL); +} + +QVisitorPrivate::Node* QVisitorPrivate::findNode(const QObject* object) const +{ + Hash::const_iterator i = m_hash.find(object); + return (m_hash.end() == i) ? NULL : *i; +} + +QByteArray QVisitorPrivate::branchBuffer + (const QList& branches, bool isNodeLine, bool isLastChild) const +{ + const int depth = branches.count(); + + const QByteArray indent(m_indent, ' '); + const QByteArray horiz(m_indent, '-'); + + QByteArray buffer; + QTextStream stream(&buffer); + + for (int i=0; i branches, bool isLastChild) +{ + dumpNode(node, branches, isLastChild); + + // Recurse down tree + const Node::child_iterator begin = node.m_children.begin(); + const Node::child_iterator end = node.m_children.end(); + for(Node::child_iterator i = begin; end != i; ++i) { + + isLastChild = (end == i + 1); + + if(begin == i) + branches.push_back(!isLastChild); + else + branches.back() = !isLastChild; + + static const bool isNodeLine = false; + const QByteArray buffer = branchBuffer(branches, isNodeLine, false); + qDebug() << buffer.constData(); + + dumpRecursive(**i, branches, isLastChild); + } +} + +void QVisitorPrivate::dumpNode + (const Node& node, const QList& branches, bool isLastChild) +{ + const QList::const_iterator + begin = node.m_annotation.begin(), end = node.m_annotation.end(); + + if(begin == end) { + // No annotations - just dump the object pointer + const bool isNodeLine = true; + QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); + qDebug() << NULL; // TODO + } + else { + // Dump annotations + for(QList::const_iterator i = begin; end != i; ++i) { + const bool isNodeLine = (begin == i); + QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); + buffer.append(*i); + qDebug() << buffer.constData(); + } + } +} + + +// QVisitorPrivate::Node + +QVisitorPrivate::Node::Node() +{ + +} + +QVisitorPrivate::Node::~Node() +{ + Node* child; + foreach(child, m_children) + delete child; +} + + +// QVisitor + +QVisitor::QVisitor() + : d_ptr(new QVisitorPrivate) +{ + +} + +QVisitor::~QVisitor() +{ + +} + +void QVisitor::setPrefix(const QString& prefix) +{ + d_func()->setPrefix(prefix); +} + +void QVisitor::setIndent(unsigned indent) +{ + d_func()->setIndent(indent); +} + +void QVisitor::addAnnotator(QAnnotator* annotator) +{ + d_func()->addAnnotator(annotator); +} + +void QVisitor::visitPrepare() +{ + // Do nothing +} + +void QVisitor::visitNode(const QObject& object) +{ + d_func()->visitNode(object); +} + +void QVisitor::visitComplete() +{ + d_func()->visitComplete(); +} + + +//----------------------------------------------------------------------------- +// Utility functions +//----------------------------------------------------------------------------- + +void addDefaultAnnotators_sys(QDumper& visitor); +void addDefaultAnnotators_sys(QVisitor& visitor); + +void addDefaultAnnotators(QDumper& dumper) +{ + dumper.addAnnotator(new QAnnotatorBasic); + dumper.addAnnotator(new QAnnotatorWidget); + + // Add platform-specific annotators + addDefaultAnnotators_sys(dumper); +} + +void addDefaultAnnotators(QVisitor& visitor) +{ + visitor.addAnnotator(new QAnnotatorBasic); + visitor.addAnnotator(new QAnnotatorWidget); + + // Add platform-specific annotators + addDefaultAnnotators_sys(visitor); +} + +void dumpTreeFromRoot(const QObject& root, QVisitor& visitor) +{ + // Set up iteration range + ObjectTree::DepthFirstConstIterator begin(root), end; + + // Invoke generic visitor algorithm + ObjectTree::visit(begin, end, visitor); +} + +void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor) +{ + // Walk up to root + const QObject* root = &leaf; + while(root->parent()) + { + root = root->parent(); + } + + dumpTreeFromRoot(*root, visitor); +} + +void dumpAncestors(const QObject& leaf, QVisitor& visitor) +{ + // Set up iteration range + ObjectTree::AncestorConstIterator begin(leaf), end; + + // Invoke generic visitor algorithm + ObjectTree::visit(begin, end, visitor); +} + + +} // namespace ObjectDump + +QT_END_NAMESPACE + + + diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.h b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.h new file mode 100644 index 0000000..cbd9bea --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.h @@ -0,0 +1,166 @@ +/* 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 OBJECTDUMP_H +#define OBJECTDUMP_H + +#include "objectdump_global.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +/** + * Abstract base for annotator classes invoked by QVisitor. + */ +class OBJECTDUMP_EXPORT QAnnotator : public QObject +{ + Q_OBJECT +public: + virtual ~QAnnotator(); + virtual QList annotation(const QObject& object) = 0; +}; + +/** + * Annotator which replicates QObject::dumpObjectTree functionality. + */ +class OBJECTDUMP_EXPORT QAnnotatorBasic : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +/** + * Annotator which returns widget information. + */ +class OBJECTDUMP_EXPORT QAnnotatorWidget : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + + +class QDumperPrivate; + +/** + * Class used to dump information about individual QObjects. + */ +class OBJECTDUMP_EXPORT QDumper : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDumper) + +public: + QDumper(); + ~QDumper(); + + /** + * Specify a prefix, to be printed on each line of output. + */ + void setPrefix(const QString& prefix); + + /** + * Takes ownership of annotator. + */ + void addAnnotator(QAnnotator* annotator); + + /** + * Invoke each annotator on the object and write to debug output. + */ + void dumpObject(const QObject& object); + +private: + QScopedPointer d_ptr; + +}; + + +class QVisitorPrivate; + +/** + * Visitor class which dumps information about nodes in the object tree. + */ +class OBJECTDUMP_EXPORT QVisitor : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QVisitor) + +public: + QVisitor(); + ~QVisitor(); + + /** + * Specify a prefix, to be printed on each line of output. + */ + void setPrefix(const QString& prefix); + + /** + * Set number of spaces by which each level of the tree is indented. + */ + void setIndent(unsigned indent); + + /** + * Called by the visitor algorithm before starting the visit. + */ + void visitPrepare(); + + /** + * Called by the visitor algorithm as each node is visited. + */ + void visitNode(const QObject& object); + + /** + * Called by the visitor algorithm when the visit is complete. + */ + void visitComplete(); + + /** + * Takes ownership of annotator. + */ + void addAnnotator(QAnnotator* annotator); + +private: + QScopedPointer d_ptr; + +}; + + +//----------------------------------------------------------------------------- +// Utility functions +//----------------------------------------------------------------------------- + +void OBJECTDUMP_EXPORT addDefaultAnnotators(QDumper& dumper); +void OBJECTDUMP_EXPORT addDefaultAnnotators(QVisitor& visitor); + +void OBJECTDUMP_EXPORT dumpTreeFromRoot(const QObject& root, QVisitor& visitor); +void OBJECTDUMP_EXPORT dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor); +void OBJECTDUMP_EXPORT dumpAncestors(const QObject& leaf, QVisitor& visitor); + +} // namespace ObjectDump + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_global.h b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_global.h new file mode 100644 index 0000000..ff031c4 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_global.h @@ -0,0 +1,30 @@ +/* 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 OBJECTDUMP_GLOBAL_H +#define OBJECTDUMP_GLOBAL_H + +#include + +#if defined(OBJECTDUMP_LIBRARY) +# define OBJECTDUMP_EXPORT Q_DECL_EXPORT +#else +# define OBJECTDUMP_EXPORT Q_DECL_IMPORT +#endif + +#endif diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_stub.cpp b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_stub.cpp new file mode 100644 index 0000000..6207dac --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_stub.cpp @@ -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 . + +*/ + +#include "objectdump.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +void addDefaultAnnotators_sys(QDumper& /*dumper*/) +{ + +} + +void addDefaultAnnotators_sys(QVisitor& /*visitor*/) +{ + +} + +} // namespace ObjectDump + +QT_END_NAMESPACE + + diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp new file mode 100644 index 0000000..54ebc55 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp @@ -0,0 +1,129 @@ +/* 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 "objectdump_symbian.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ +namespace Symbian +{ + +QList QAnnotatorControl::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + const CCoeControl* control = widget->effectiveWinId(); + if(control) { + + QByteArray array; + QTextStream stream(&array); + + stream << "control: " << control << ' '; + stream << "parent " << control->Parent() << ' '; + + if(control->IsVisible()) + stream << "visible "; + else + stream << "invisible "; + + stream << control->Position().iX << ',' << control->Position().iY << ' '; + stream << control->Size().iWidth << 'x' << control->Size().iHeight; + + if(control->OwnsWindow()) + stream << " ownsWindow "; + + stream.flush(); + result.append(array); + } + } + + return result; +} + +QList QAnnotatorWindow::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + const CCoeControl* control = widget->effectiveWinId(); + if(control) { + + RDrawableWindow& window = *(control->DrawableWindow()); + + QByteArray array; + QTextStream stream(&array); + + stream << "window: "; + + // Client-side window handle + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "cli " << reinterpret_cast(window.ClientHandle()) << ' '; + + // Server-side address of CWsWindow object + // This is useful for correlation with the window tree dumped by the window + // server (see RWsSession::LogCommand). + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "srv " << reinterpret_cast(window.WsHandle()) << ' '; + + stream << "group " << window.WindowGroupId() << ' '; + + // Client-side handle to the parent window. + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "parent " << reinterpret_cast(window.Parent()) << ' '; + + stream << window.Position().iX << ',' << window.Position().iY << ' '; + stream << '(' << window.AbsPosition().iX << ',' << window.AbsPosition().iY << ") "; + stream << window.Size().iWidth << 'x' << window.Size().iHeight; + + stream.flush(); + result.append(array); + } + } + + return result; +} + +} // namespace Symbian + +void addDefaultAnnotators_sys(QDumper& dumper) +{ + dumper.addAnnotator(new Symbian::QAnnotatorControl); + dumper.addAnnotator(new Symbian::QAnnotatorWindow); +} + +void addDefaultAnnotators_sys(QVisitor& visitor) +{ + visitor.addAnnotator(new Symbian::QAnnotatorControl); + visitor.addAnnotator(new Symbian::QAnnotatorWindow); +} + +} // namespace ObjectDump + +QT_END_NAMESPACE + + diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.h b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.h new file mode 100644 index 0000000..26ab308 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.h @@ -0,0 +1,56 @@ +/* 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 OBJECTDUMP_SYMBIAN_H +#define OBJECTDUMP_SYMBIAN_H + +#include "objectdump.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ +namespace Symbian +{ + +/** + * Annotator which returns control information + */ +class QAnnotatorControl : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +/** + * Annotator which returns window information + */ +class QAnnotatorWindow : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +} // namespace Symbian +} // namespace ObjectDump + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.cpp b/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.cpp new file mode 100644 index 0000000..f9d1c93 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.cpp @@ -0,0 +1,102 @@ +/* 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 "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectTree +{ + +DepthFirstConstIterator::DepthFirstConstIterator() + : m_pointee(NULL) +{ + +} + +DepthFirstConstIterator::DepthFirstConstIterator + (const QObject& root) + : m_pointee(&root) +{ + +} + +DepthFirstConstIterator& + DepthFirstConstIterator::operator++() +{ + const QObjectList& children = m_pointee->children(); + + if (children.count() == 0) { + backtrack(); + } + else { + m_history.push(0); + m_pointee = children.first(); + } + + return *this; +} + +void DepthFirstConstIterator::backtrack() +{ + if (m_history.count()) { + const int index = m_history.top(); + m_history.pop(); + + const QObjectList& siblings = m_pointee->parent()->children(); + if (siblings.count() > index + 1) { + m_history.push(index + 1); + m_pointee = siblings[index + 1]; + } + else { + m_pointee = m_pointee->parent(); + backtrack(); + } + } + else { + // Reached end of search + m_pointee = NULL; + } +} + + + +AncestorConstIterator::AncestorConstIterator() +{ + +} + +AncestorConstIterator::AncestorConstIterator(const QObject& leaf) +{ + m_ancestors.push(&leaf); + QObject* ancestor = leaf.parent(); + while(ancestor) + { + m_ancestors.push(ancestor); + ancestor = ancestor->parent(); + } +} + +} // namespace ObjectTree + +QT_END_NAMESPACE + + + diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.h b/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.h new file mode 100644 index 0000000..f2729fa --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.h @@ -0,0 +1,117 @@ +/* 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 OBJECTTREE_H +#define OBJECTTREE_H + +#include "objectdump_global.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace ObjectTree +{ + +/** + * Depth-first iterator for QObject tree + */ +class OBJECTDUMP_EXPORT DepthFirstConstIterator +{ +public: + DepthFirstConstIterator(); + DepthFirstConstIterator(const QObject& root); + + DepthFirstConstIterator& operator++(); + + inline bool operator==(const DepthFirstConstIterator& other) const + { return other.m_pointee == m_pointee; } + + inline bool operator!=(const DepthFirstConstIterator& other) const + { return other.m_pointee != m_pointee; } + + inline const QObject* operator->() const { return m_pointee; } + inline const QObject& operator*() const { return *m_pointee; } + +private: + void backtrack(); + +private: + const QObject* m_pointee; + QStack m_history; +}; + +/** + * Ancestor iterator for QObject tree + */ +class OBJECTDUMP_EXPORT AncestorConstIterator +{ +public: + AncestorConstIterator(); + AncestorConstIterator(const QObject& root); + + inline AncestorConstIterator& operator++() + { m_ancestors.pop(); return *this; } + + inline bool operator==(const AncestorConstIterator& other) const + { return other.m_ancestors == m_ancestors; } + + inline bool operator!=(const AncestorConstIterator& other) const + { return other.m_ancestors != m_ancestors; } + + inline const QObject* operator->() const { return m_ancestors.top(); } + inline const QObject& operator*() const { return *m_ancestors.top(); } + +private: + QStack m_ancestors; + +}; + +/** + * Generic algorithm for visiting nodes in an object tree. Nodes in the + * tree are visited in a const context, therefore they are not modified + * by this algorithm. + * + * Visitor must provide functions with the following signatures: + * + * Called before visit begins + * void visitPrepare() + * + * Called on each node visited + * void visitNode(const QObject& object) + * + * Called when visit is complete + * void visitComplete() + */ +template +void visit(Iterator begin, Iterator end, Visitor& visitor) +{ + visitor.visitPrepare(); + + for( ; begin != end; ++begin) + visitor.visitNode(*begin); + + visitor.visitComplete(); +} + +} // namespace ObjectTree + +QT_END_NAMESPACE + +#endif // OBJECTTREE_H diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump.cpp b/src/3rdparty/phonon/mmf/objectdump/objectdump.cpp deleted file mode 100644 index 50c6bf8..0000000 --- a/src/3rdparty/phonon/mmf/objectdump/objectdump.cpp +++ /dev/null @@ -1,527 +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 -#include - -#include "objectdump.h" -#include "objecttree.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ - -//----------------------------------------------------------------------------- -// QObjectAnnotator -//----------------------------------------------------------------------------- - -QAnnotator::~QAnnotator() -{ - -} - - -//----------------------------------------------------------------------------- -// Annotators -//----------------------------------------------------------------------------- - -QList QAnnotatorBasic::annotation(const QObject& object) -{ - QList result; - - QByteArray array; - QTextStream stream(&array); - - stream << '[' << &object << ']'; - stream << ' '; - stream << object.metaObject()->className(); - - if(object.objectName() != "") - stream << " \"" << object.objectName() << '"'; - - if(object.isWidgetType()) - stream << " isWidget"; - - stream.flush(); - result.append(array); - return result; -} - -QList QAnnotatorWidget::annotation(const QObject& object) -{ - QList result; - - const QWidget* widget = qobject_cast(&object); - if(widget) { - - QByteArray array; - QTextStream stream(&array); - - stream << "widget: "; - - if(widget->isVisible()) - stream << "visible "; - else - stream << "invisible "; - - stream << widget->x() << ',' << widget->y() << ' '; - stream << widget->size().width() << 'x'<< widget->size().height() << ' '; - - stream << "hint " << widget->sizeHint().width() << 'x' << widget->sizeHint().height(); - - stream.flush(); - result.append(array); - } - - return result; -} - - -//----------------------------------------------------------------------------- -// Base class for QDumperPrivate, QVisitorPrivate -//----------------------------------------------------------------------------- - -class QDumperBase -{ -public: - QDumperBase(); - ~QDumperBase(); - - void setPrefix(const QString& prefix); - void addAnnotator(QAnnotator* annotator); - -protected: - QByteArray m_prefix; - QList m_annotators; - -}; - -QDumperBase::QDumperBase() -{ - -} - -QDumperBase::~QDumperBase() -{ - QAnnotator* annotator; - foreach(annotator, m_annotators) - delete annotator; -} - -void QDumperBase::setPrefix(const QString& prefix) -{ - m_prefix = prefix.count() - ? (prefix + " ").toAscii() - : prefix.toAscii(); -} - -void QDumperBase::addAnnotator(QAnnotator* annotator) -{ - // Protect against an exception occurring during QList::append - QScopedPointer holder(annotator); - m_annotators.append(annotator); - holder.take(); -} - - -//----------------------------------------------------------------------------- -// QDumper -//----------------------------------------------------------------------------- - -class QDumperPrivate : public QDumperBase -{ -public: - QDumperPrivate(); - ~QDumperPrivate(); - - void dumpObject(const QObject& object); - -}; - - -QDumperPrivate::QDumperPrivate() -{ - -} - -QDumperPrivate::~QDumperPrivate() -{ - -} - -void QDumperPrivate::dumpObject(const QObject& object) -{ - QAnnotator* annotator; - foreach(annotator, m_annotators) { - - const QList annotations = annotator->annotation(object); - QByteArray annotation; - foreach(annotation, annotations) { - QByteArray buffer(m_prefix); - buffer.append(annotation); - qDebug() << buffer.constData(); - } - } -} - - -QDumper::QDumper() - : d_ptr(new QDumperPrivate) -{ - -} - -QDumper::~QDumper() -{ - -} - -void QDumper::setPrefix(const QString& prefix) -{ - d_func()->setPrefix(prefix); -} - -void QDumper::addAnnotator(QAnnotator* annotator) -{ - d_func()->addAnnotator(annotator); -} - -void QDumper::dumpObject(const QObject& object) -{ - d_func()->dumpObject(object); -} - - -//----------------------------------------------------------------------------- -// QVisitor -//----------------------------------------------------------------------------- - -class QVisitorPrivate : public QDumperBase -{ -public: - QVisitorPrivate(); - ~QVisitorPrivate(); - - void setIndent(unsigned indent); - - void visitNode(const QObject& object); - void visitComplete(); - -private: - class Node - { - public: - Node(); - ~Node(); - - QList m_annotation; - QList m_children; - - typedef QList::const_iterator child_iterator; - }; - -private: - Node* findNode(const QObject* object) const; - QByteArray branchBuffer(const QList& branches, bool isNodeLine, bool isLastChild) const; - void dumpRecursive(const Node& node, QList branches, bool isLastChild); - void dumpNode(const Node& node, const QList& branches, bool isLastChild); - -private: - unsigned m_indent; - - QScopedPointer m_root; - - // Hash table used to associate internal nodes with QObjects - typedef QHash Hash; - Hash m_hash; -}; - -static const unsigned DefaultIndent = 2; - -QVisitorPrivate::QVisitorPrivate() - : m_indent(DefaultIndent) -{ - -} - -QVisitorPrivate::~QVisitorPrivate() -{ - -} - -void QVisitorPrivate::setIndent(unsigned indent) -{ - m_indent = indent; -} - -// Builds up a mirror of the object tree, rooted in m_root, with each node -// storing annotations generated by -void QVisitorPrivate::visitNode(const QObject& object) -{ - QObject* const objectParent = object.parent(); - Node* const nodeParent = objectParent ? findNode(objectParent) : NULL; - - // Create a new node and store in scoped pointer for exception safety - Node* node = new Node; - QScopedPointer nodePtr(node); - - // Associate node with QObject - m_hash.insert(&object, node); - - // Insert node into internal tree - if(nodeParent) - { - nodeParent->m_children.append(nodePtr.take()); - } - else - { - Q_ASSERT(m_root.isNull()); - m_root.reset(nodePtr.take()); - } - - // Generate and store annotations - QAnnotator* annotator; - foreach(annotator, m_annotators) - node->m_annotation.append( annotator->annotation(object) ); -} - -void QVisitorPrivate::visitComplete() -{ - QList branches; - static const bool isLastChild = true; - dumpRecursive(*m_root, branches, isLastChild); - m_root.reset(NULL); -} - -QVisitorPrivate::Node* QVisitorPrivate::findNode(const QObject* object) const -{ - Hash::const_iterator i = m_hash.find(object); - return (m_hash.end() == i) ? NULL : *i; -} - -QByteArray QVisitorPrivate::branchBuffer - (const QList& branches, bool isNodeLine, bool isLastChild) const -{ - const int depth = branches.count(); - - const QByteArray indent(m_indent, ' '); - const QByteArray horiz(m_indent, '-'); - - QByteArray buffer; - QTextStream stream(&buffer); - - for (int i=0; i branches, bool isLastChild) -{ - dumpNode(node, branches, isLastChild); - - // Recurse down tree - const Node::child_iterator begin = node.m_children.begin(); - const Node::child_iterator end = node.m_children.end(); - for(Node::child_iterator i = begin; end != i; ++i) { - - isLastChild = (end == i + 1); - - if(begin == i) - branches.push_back(!isLastChild); - else - branches.back() = !isLastChild; - - static const bool isNodeLine = false; - const QByteArray buffer = branchBuffer(branches, isNodeLine, false); - qDebug() << buffer.constData(); - - dumpRecursive(**i, branches, isLastChild); - } -} - -void QVisitorPrivate::dumpNode - (const Node& node, const QList& branches, bool isLastChild) -{ - const QList::const_iterator - begin = node.m_annotation.begin(), end = node.m_annotation.end(); - - if(begin == end) { - // No annotations - just dump the object pointer - const bool isNodeLine = true; - QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); - qDebug() << NULL; // TODO - } - else { - // Dump annotations - for(QList::const_iterator i = begin; end != i; ++i) { - const bool isNodeLine = (begin == i); - QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); - buffer.append(*i); - qDebug() << buffer.constData(); - } - } -} - - -// QVisitorPrivate::Node - -QVisitorPrivate::Node::Node() -{ - -} - -QVisitorPrivate::Node::~Node() -{ - Node* child; - foreach(child, m_children) - delete child; -} - - -// QVisitor - -QVisitor::QVisitor() - : d_ptr(new QVisitorPrivate) -{ - -} - -QVisitor::~QVisitor() -{ - -} - -void QVisitor::setPrefix(const QString& prefix) -{ - d_func()->setPrefix(prefix); -} - -void QVisitor::setIndent(unsigned indent) -{ - d_func()->setIndent(indent); -} - -void QVisitor::addAnnotator(QAnnotator* annotator) -{ - d_func()->addAnnotator(annotator); -} - -void QVisitor::visitPrepare() -{ - // Do nothing -} - -void QVisitor::visitNode(const QObject& object) -{ - d_func()->visitNode(object); -} - -void QVisitor::visitComplete() -{ - d_func()->visitComplete(); -} - - -//----------------------------------------------------------------------------- -// Utility functions -//----------------------------------------------------------------------------- - -void addDefaultAnnotators_sys(QDumper& visitor); -void addDefaultAnnotators_sys(QVisitor& visitor); - -void addDefaultAnnotators(QDumper& dumper) -{ - dumper.addAnnotator(new QAnnotatorBasic); - dumper.addAnnotator(new QAnnotatorWidget); - - // Add platform-specific annotators - addDefaultAnnotators_sys(dumper); -} - -void addDefaultAnnotators(QVisitor& visitor) -{ - visitor.addAnnotator(new QAnnotatorBasic); - visitor.addAnnotator(new QAnnotatorWidget); - - // Add platform-specific annotators - addDefaultAnnotators_sys(visitor); -} - -void dumpTreeFromRoot(const QObject& root, QVisitor& visitor) -{ - // Set up iteration range - ObjectTree::DepthFirstConstIterator begin(root), end; - - // Invoke generic visitor algorithm - ObjectTree::visit(begin, end, visitor); -} - -void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor) -{ - // Walk up to root - const QObject* root = &leaf; - while(root->parent()) - { - root = root->parent(); - } - - dumpTreeFromRoot(*root, visitor); -} - -void dumpAncestors(const QObject& leaf, QVisitor& visitor) -{ - // Set up iteration range - ObjectTree::AncestorConstIterator begin(leaf), end; - - // Invoke generic visitor algorithm - ObjectTree::visit(begin, end, visitor); -} - - -} // namespace ObjectDump - -QT_END_NAMESPACE - - - diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump.h b/src/3rdparty/phonon/mmf/objectdump/objectdump.h deleted file mode 100644 index cbd9bea..0000000 --- a/src/3rdparty/phonon/mmf/objectdump/objectdump.h +++ /dev/null @@ -1,166 +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 OBJECTDUMP_H -#define OBJECTDUMP_H - -#include "objectdump_global.h" - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ - -/** - * Abstract base for annotator classes invoked by QVisitor. - */ -class OBJECTDUMP_EXPORT QAnnotator : public QObject -{ - Q_OBJECT -public: - virtual ~QAnnotator(); - virtual QList annotation(const QObject& object) = 0; -}; - -/** - * Annotator which replicates QObject::dumpObjectTree functionality. - */ -class OBJECTDUMP_EXPORT QAnnotatorBasic : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - -/** - * Annotator which returns widget information. - */ -class OBJECTDUMP_EXPORT QAnnotatorWidget : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - - -class QDumperPrivate; - -/** - * Class used to dump information about individual QObjects. - */ -class OBJECTDUMP_EXPORT QDumper : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDumper) - -public: - QDumper(); - ~QDumper(); - - /** - * Specify a prefix, to be printed on each line of output. - */ - void setPrefix(const QString& prefix); - - /** - * Takes ownership of annotator. - */ - void addAnnotator(QAnnotator* annotator); - - /** - * Invoke each annotator on the object and write to debug output. - */ - void dumpObject(const QObject& object); - -private: - QScopedPointer d_ptr; - -}; - - -class QVisitorPrivate; - -/** - * Visitor class which dumps information about nodes in the object tree. - */ -class OBJECTDUMP_EXPORT QVisitor : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QVisitor) - -public: - QVisitor(); - ~QVisitor(); - - /** - * Specify a prefix, to be printed on each line of output. - */ - void setPrefix(const QString& prefix); - - /** - * Set number of spaces by which each level of the tree is indented. - */ - void setIndent(unsigned indent); - - /** - * Called by the visitor algorithm before starting the visit. - */ - void visitPrepare(); - - /** - * Called by the visitor algorithm as each node is visited. - */ - void visitNode(const QObject& object); - - /** - * Called by the visitor algorithm when the visit is complete. - */ - void visitComplete(); - - /** - * Takes ownership of annotator. - */ - void addAnnotator(QAnnotator* annotator); - -private: - QScopedPointer d_ptr; - -}; - - -//----------------------------------------------------------------------------- -// Utility functions -//----------------------------------------------------------------------------- - -void OBJECTDUMP_EXPORT addDefaultAnnotators(QDumper& dumper); -void OBJECTDUMP_EXPORT addDefaultAnnotators(QVisitor& visitor); - -void OBJECTDUMP_EXPORT dumpTreeFromRoot(const QObject& root, QVisitor& visitor); -void OBJECTDUMP_EXPORT dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor); -void OBJECTDUMP_EXPORT dumpAncestors(const QObject& leaf, QVisitor& visitor); - -} // namespace ObjectDump - -QT_END_NAMESPACE - -#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_global.h b/src/3rdparty/phonon/mmf/objectdump/objectdump_global.h deleted file mode 100644 index ff031c4..0000000 --- a/src/3rdparty/phonon/mmf/objectdump/objectdump_global.h +++ /dev/null @@ -1,30 +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 OBJECTDUMP_GLOBAL_H -#define OBJECTDUMP_GLOBAL_H - -#include - -#if defined(OBJECTDUMP_LIBRARY) -# define OBJECTDUMP_EXPORT Q_DECL_EXPORT -#else -# define OBJECTDUMP_EXPORT Q_DECL_IMPORT -#endif - -#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp b/src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp deleted file mode 100644 index 6207dac..0000000 --- a/src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp +++ /dev/null @@ -1,40 +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 "objectdump.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ - -void addDefaultAnnotators_sys(QDumper& /*dumper*/) -{ - -} - -void addDefaultAnnotators_sys(QVisitor& /*visitor*/) -{ - -} - -} // namespace ObjectDump - -QT_END_NAMESPACE - - diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp deleted file mode 100644 index 54ebc55..0000000 --- a/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp +++ /dev/null @@ -1,129 +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 "objectdump_symbian.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ -namespace Symbian -{ - -QList QAnnotatorControl::annotation(const QObject& object) -{ - QList result; - - const QWidget* widget = qobject_cast(&object); - if(widget) { - - const CCoeControl* control = widget->effectiveWinId(); - if(control) { - - QByteArray array; - QTextStream stream(&array); - - stream << "control: " << control << ' '; - stream << "parent " << control->Parent() << ' '; - - if(control->IsVisible()) - stream << "visible "; - else - stream << "invisible "; - - stream << control->Position().iX << ',' << control->Position().iY << ' '; - stream << control->Size().iWidth << 'x' << control->Size().iHeight; - - if(control->OwnsWindow()) - stream << " ownsWindow "; - - stream.flush(); - result.append(array); - } - } - - return result; -} - -QList QAnnotatorWindow::annotation(const QObject& object) -{ - QList result; - - const QWidget* widget = qobject_cast(&object); - if(widget) { - - const CCoeControl* control = widget->effectiveWinId(); - if(control) { - - RDrawableWindow& window = *(control->DrawableWindow()); - - QByteArray array; - QTextStream stream(&array); - - stream << "window: "; - - // Client-side window handle - // Cast to a void pointer so that log output is in hexadecimal format. - stream << "cli " << reinterpret_cast(window.ClientHandle()) << ' '; - - // Server-side address of CWsWindow object - // This is useful for correlation with the window tree dumped by the window - // server (see RWsSession::LogCommand). - // Cast to a void pointer so that log output is in hexadecimal format. - stream << "srv " << reinterpret_cast(window.WsHandle()) << ' '; - - stream << "group " << window.WindowGroupId() << ' '; - - // Client-side handle to the parent window. - // Cast to a void pointer so that log output is in hexadecimal format. - stream << "parent " << reinterpret_cast(window.Parent()) << ' '; - - stream << window.Position().iX << ',' << window.Position().iY << ' '; - stream << '(' << window.AbsPosition().iX << ',' << window.AbsPosition().iY << ") "; - stream << window.Size().iWidth << 'x' << window.Size().iHeight; - - stream.flush(); - result.append(array); - } - } - - return result; -} - -} // namespace Symbian - -void addDefaultAnnotators_sys(QDumper& dumper) -{ - dumper.addAnnotator(new Symbian::QAnnotatorControl); - dumper.addAnnotator(new Symbian::QAnnotatorWindow); -} - -void addDefaultAnnotators_sys(QVisitor& visitor) -{ - visitor.addAnnotator(new Symbian::QAnnotatorControl); - visitor.addAnnotator(new Symbian::QAnnotatorWindow); -} - -} // namespace ObjectDump - -QT_END_NAMESPACE - - diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h deleted file mode 100644 index 26ab308..0000000 --- a/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h +++ /dev/null @@ -1,56 +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 OBJECTDUMP_SYMBIAN_H -#define OBJECTDUMP_SYMBIAN_H - -#include "objectdump.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ -namespace Symbian -{ - -/** - * Annotator which returns control information - */ -class QAnnotatorControl : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - -/** - * Annotator which returns window information - */ -class QAnnotatorWindow : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - -} // namespace Symbian -} // namespace ObjectDump - -QT_END_NAMESPACE - -#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objecttree.cpp b/src/3rdparty/phonon/mmf/objectdump/objecttree.cpp deleted file mode 100644 index f9d1c93..0000000 --- a/src/3rdparty/phonon/mmf/objectdump/objecttree.cpp +++ /dev/null @@ -1,102 +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 "objecttree.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectTree -{ - -DepthFirstConstIterator::DepthFirstConstIterator() - : m_pointee(NULL) -{ - -} - -DepthFirstConstIterator::DepthFirstConstIterator - (const QObject& root) - : m_pointee(&root) -{ - -} - -DepthFirstConstIterator& - DepthFirstConstIterator::operator++() -{ - const QObjectList& children = m_pointee->children(); - - if (children.count() == 0) { - backtrack(); - } - else { - m_history.push(0); - m_pointee = children.first(); - } - - return *this; -} - -void DepthFirstConstIterator::backtrack() -{ - if (m_history.count()) { - const int index = m_history.top(); - m_history.pop(); - - const QObjectList& siblings = m_pointee->parent()->children(); - if (siblings.count() > index + 1) { - m_history.push(index + 1); - m_pointee = siblings[index + 1]; - } - else { - m_pointee = m_pointee->parent(); - backtrack(); - } - } - else { - // Reached end of search - m_pointee = NULL; - } -} - - - -AncestorConstIterator::AncestorConstIterator() -{ - -} - -AncestorConstIterator::AncestorConstIterator(const QObject& leaf) -{ - m_ancestors.push(&leaf); - QObject* ancestor = leaf.parent(); - while(ancestor) - { - m_ancestors.push(ancestor); - ancestor = ancestor->parent(); - } -} - -} // namespace ObjectTree - -QT_END_NAMESPACE - - - diff --git a/src/3rdparty/phonon/mmf/objectdump/objecttree.h b/src/3rdparty/phonon/mmf/objectdump/objecttree.h deleted file mode 100644 index f2729fa..0000000 --- a/src/3rdparty/phonon/mmf/objectdump/objecttree.h +++ /dev/null @@ -1,117 +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 OBJECTTREE_H -#define OBJECTTREE_H - -#include "objectdump_global.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -namespace ObjectTree -{ - -/** - * Depth-first iterator for QObject tree - */ -class OBJECTDUMP_EXPORT DepthFirstConstIterator -{ -public: - DepthFirstConstIterator(); - DepthFirstConstIterator(const QObject& root); - - DepthFirstConstIterator& operator++(); - - inline bool operator==(const DepthFirstConstIterator& other) const - { return other.m_pointee == m_pointee; } - - inline bool operator!=(const DepthFirstConstIterator& other) const - { return other.m_pointee != m_pointee; } - - inline const QObject* operator->() const { return m_pointee; } - inline const QObject& operator*() const { return *m_pointee; } - -private: - void backtrack(); - -private: - const QObject* m_pointee; - QStack m_history; -}; - -/** - * Ancestor iterator for QObject tree - */ -class OBJECTDUMP_EXPORT AncestorConstIterator -{ -public: - AncestorConstIterator(); - AncestorConstIterator(const QObject& root); - - inline AncestorConstIterator& operator++() - { m_ancestors.pop(); return *this; } - - inline bool operator==(const AncestorConstIterator& other) const - { return other.m_ancestors == m_ancestors; } - - inline bool operator!=(const AncestorConstIterator& other) const - { return other.m_ancestors != m_ancestors; } - - inline const QObject* operator->() const { return m_ancestors.top(); } - inline const QObject& operator*() const { return *m_ancestors.top(); } - -private: - QStack m_ancestors; - -}; - -/** - * Generic algorithm for visiting nodes in an object tree. Nodes in the - * tree are visited in a const context, therefore they are not modified - * by this algorithm. - * - * Visitor must provide functions with the following signatures: - * - * Called before visit begins - * void visitPrepare() - * - * Called on each node visited - * void visitNode(const QObject& object) - * - * Called when visit is complete - * void visitComplete() - */ -template -void visit(Iterator begin, Iterator end, Visitor& visitor) -{ - visitor.visitPrepare(); - - for( ; begin != end; ++begin) - visitor.visitNode(*begin); - - visitor.visitComplete(); -} - -} // namespace ObjectTree - -QT_END_NAMESPACE - -#endif // OBJECTTREE_H diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 3f14f19..8ff9a33 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -21,7 +21,7 @@ along with this library. If not, see . #include "videooutputobserver.h" #ifdef _DEBUG -#include "objectdump/objectdump.h" +#include "mmfphonondebug/objectdump.h" #endif #include diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 4e764dc..da73fdc 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = objectdump plugin +SUBDIRS = mmfphonondebug plugin diff --git a/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro b/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro new file mode 100644 index 0000000..6cce2e6 --- /dev/null +++ b/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro @@ -0,0 +1,31 @@ +TEMPLATE = lib +TARGET = mmfphonondebug +OBJECTDUMP_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf/mmfphonondebug + +CONFIG += dll + +DEFINES += OBJECTDUMP_LIBRARY + +HEADERS += \ + $$OBJECTDUMP_DIR/objectdump_global.h \ + $$OBJECTDUMP_DIR/objectdump.h \ + $$OBJECTDUMP_DIR/objecttree.h + +SOURCES += \ + $$OBJECTDUMP_DIR/objectdump.cpp \ + $$OBJECTDUMP_DIR/objecttree.cpp + +symbian { + HEADERS += $$OBJECTDUMP_DIR/objectdump_symbian.h + SOURCES += $$OBJECTDUMP_DIR/objectdump_symbian.cpp + + LIBS += -lcone + LIBS += -lws32 + + TARGET.CAPABILITY = all -tcb + +} else { + SOURCES += $$OBJECTDUMP_DIR/objectdump_stub.cpp +} + +TARGET.UID3=0x2001E62A diff --git a/src/plugins/phonon/mmf/objectdump/objectdump.pro b/src/plugins/phonon/mmf/objectdump/objectdump.pro deleted file mode 100644 index 4b1245e..0000000 --- a/src/plugins/phonon/mmf/objectdump/objectdump.pro +++ /dev/null @@ -1,31 +0,0 @@ -TEMPLATE = lib -TARGET = objectdump -OBJECTDUMP_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf/objectdump - -CONFIG += dll - -DEFINES += OBJECTDUMP_LIBRARY - -HEADERS += \ - $$OBJECTDUMP_DIR/objectdump_global.h \ - $$OBJECTDUMP_DIR/objectdump.h \ - $$OBJECTDUMP_DIR/objecttree.h - -SOURCES += \ - $$OBJECTDUMP_DIR/objectdump.cpp \ - $$OBJECTDUMP_DIR/objecttree.cpp - -symbian { - HEADERS += $$OBJECTDUMP_DIR/objectdump_symbian.h - SOURCES += $$OBJECTDUMP_DIR/objectdump_symbian.cpp - - LIBS += -lcone - LIBS += -lws32 - - TARGET.CAPABILITY = all -tcb - -} else { - SOURCES += $$OBJECTDUMP_DIR/objectdump_stub.cpp -} - -TARGET.UID3=0x2001E62A diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/qt_libs.pro index d04dd99..51354ee 100644 --- a/src/s60installs/qt_libs.pro +++ b/src/s60installs/qt_libs.pro @@ -68,7 +68,8 @@ symbian: { codecs_plugins.path = $$QT_PLUGINS_BASE_DIR/codecs contains(QT_CONFIG, phonon-backend) { - phonon_backend_plugins.sources += phonon_mmf.dll objectdump.dll + phonon_backend_plugins.sources += phonon_mmf.dll + phonon_backend_plugins.path = $$QT_PLUGINS_BASE_DIR/phonon_backend DEPLOYMENT += phonon_backend_plugins } -- cgit v0.12 From bca1ca80159dc5d8161b5e4bc84584b793414ff6 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 15 Sep 2009 11:57:15 +0100 Subject: Fixes to include paths, required due to objectdump renaming --- src/3rdparty/phonon/mmf/videooutput.cpp | 2 +- src/3rdparty/phonon/mmf/videoplayer.cpp | 2 +- src/plugins/phonon/mmf/plugin/plugin.pro | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 8ff9a33..2544a97 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -21,7 +21,7 @@ along with this library. If not, see . #include "videooutputobserver.h" #ifdef _DEBUG -#include "mmfphonondebug/objectdump.h" +#include "objectdump.h" #endif #include diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 0d98256..827c2a1 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -27,7 +27,7 @@ along with this library. If not, see . #include "utils.h" #ifdef _DEBUG -#include "objectdump/objectdump.h" +#include "objectdump.h" #endif QT_BEGIN_NAMESPACE diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index c7aad69..b1f3bfb 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -61,8 +61,8 @@ SOURCES += \ $$PHONON_MMF_DIR/videowidget.cpp debug { - INCLUDEPATH += $$PHONON_MMF_DIR/objectdump - LIBS += -lobjectdump + INCLUDEPATH += $$PHONON_MMF_DIR/mmfphonondebug + LIBS += -lmmfphonondebug } LIBS += -lmediaclientvideo # For CVideoPlayerUtility -- cgit v0.12 From 61161589376a3bb2dffaf898ca50449774b48565 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 15 Sep 2009 16:43:57 +0200 Subject: Make mmfphonondebug static, and do some build fixes. --- src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_global.h | 4 ++-- src/plugins/phonon/mmf/mmf.pro | 2 ++ src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro | 4 ++-- src/plugins/phonon/mmf/plugin/plugin.pro | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_global.h b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_global.h index ff031c4..b8987e0 100644 --- a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_global.h +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_global.h @@ -22,9 +22,9 @@ along with this library. If not, see . #include #if defined(OBJECTDUMP_LIBRARY) -# define OBJECTDUMP_EXPORT Q_DECL_EXPORT +# define OBJECTDUMP_EXPORT #else -# define OBJECTDUMP_EXPORT Q_DECL_IMPORT +# define OBJECTDUMP_EXPORT #endif #endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index da73fdc..ff27ea1 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -1,2 +1,4 @@ TEMPLATE = subdirs SUBDIRS = mmfphonondebug plugin + +plugin.depends = mmfphonondebug diff --git a/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro b/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro index 6cce2e6..2cfec15 100644 --- a/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro +++ b/src/plugins/phonon/mmf/mmfphonondebug/mmfphonondebug.pro @@ -1,8 +1,8 @@ TEMPLATE = lib -TARGET = mmfphonondebug +TARGET = phonon_mmf_debug OBJECTDUMP_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf/mmfphonondebug -CONFIG += dll +CONFIG += staticlib DEFINES += OBJECTDUMP_LIBRARY diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index b1f3bfb..c7bb327d 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -62,7 +62,7 @@ SOURCES += \ debug { INCLUDEPATH += $$PHONON_MMF_DIR/mmfphonondebug - LIBS += -lmmfphonondebug + LIBS += -lphonon_mmf_debug.lib } LIBS += -lmediaclientvideo # For CVideoPlayerUtility -- cgit v0.12 From 6700a53676265787ab46106602234448e0174e55 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 16 Sep 2009 18:08:58 +0100 Subject: Added a utility function for reading color of individual pixels from the screen --- src/3rdparty/phonon/mmf/utils.cpp | 75 ++++++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/utils.h | 9 ++++ src/plugins/phonon/mmf/plugin/plugin.pro | 1 + 3 files changed, 85 insertions(+) diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index cebc32e..3d674fd 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -50,5 +50,80 @@ MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) } +#ifdef _DEBUG + +#include +#include +#include +#include + +struct TScreenInfo +{ + int width; + int height; + int bpp; + const char* address; + int initialOffset; + int lineOffset; + TDisplayMode displayMode; +}; + +void getScreenInfoL(TScreenInfo& info) +{ + info.displayMode = CEikonEnv::Static()->ScreenDevice()->DisplayMode(); + + // Then we must set these as the input parameter + info.width = info.displayMode; + info.height = info.displayMode; + info.initialOffset = info.displayMode; + info.lineOffset = info.displayMode; + info.bpp = info.displayMode; + + User::LeaveIfError( HAL::Get(HALData::EDisplayXPixels, info.width) ); + User::LeaveIfError( HAL::Get(HALData::EDisplayYPixels, info.width) ); + + int address; + User::LeaveIfError( HAL::Get(HALData::EDisplayMemoryAddress, address) ); + info.address = reinterpret_cast(address); + + User::LeaveIfError( HAL::Get(HALData::EDisplayOffsetToFirstPixel, info.initialOffset) ); + + User::LeaveIfError( HAL::Get(HALData::EDisplayOffsetBetweenLines, info.lineOffset) ); + + User::LeaveIfError( HAL::Get(HALData::EDisplayBitsPerPixel, info.bpp) ); +} + + +QColor MMF::Utils::getScreenPixel(const QPoint& pos) +{ + TScreenInfo info; + TRAPD(err, getScreenInfoL(info)); + QColor pixel; + if(err == KErrNone and pos.x() < info.width and pos.y() < info.height) + { + const int bytesPerPixel = info.bpp / 8; + Q_ASSERT(bytesPerPixel >= 3); + + const int stride = (info.width * bytesPerPixel) + info.lineOffset; + + const char* ptr = + info.address + + info.initialOffset + + pos.y() * stride + + pos.x() * bytesPerPixel; + + // BGRA + pixel.setBlue(*ptr++); + pixel.setGreen(*ptr++); + pixel.setRed(*ptr++); + + if(bytesPerPixel == 4) + pixel.setAlpha(*ptr++); + } + return pixel; +} + +#endif // _DEBUG + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index 5a26018..7db7831 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 + #include "defs.h" QT_BEGIN_NAMESPACE @@ -51,6 +53,13 @@ void panic(PanicCode code); * type. If it is neither, the function returns MediaTypeUnknown. */ MediaType mimeTypeToMediaType(const TDesC& mimeType); + +#ifdef _DEBUG +/** + * Retrieve color of specified pixel from the screen. + */ +QColor getScreenPixel(const QPoint& pos); +#endif } /** diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index c7bb327d..d620453 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -63,6 +63,7 @@ SOURCES += \ debug { INCLUDEPATH += $$PHONON_MMF_DIR/mmfphonondebug LIBS += -lphonon_mmf_debug.lib + LIBS += -lhal } LIBS += -lmediaclientvideo # For CVideoPlayerUtility -- cgit v0.12 From 970db998dc6586388ca66b8969433d55a675c0a6 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 16 Sep 2009 18:21:26 +0100 Subject: Added a utility function which samples a number of pixels from the screen, and writes their colors to the debug log --- src/3rdparty/phonon/mmf/utils.cpp | 13 +++++++++++++ src/3rdparty/phonon/mmf/utils.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index 3d674fd..107a36d 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -123,6 +123,19 @@ QColor MMF::Utils::getScreenPixel(const QPoint& pos) return pixel; } +// Debugging: for debugging video visibility +void MMF::Utils::dumpScreenPixelSample() +{ + for(int i=0; i<20; ++i) { + const QPoint pos(i*10, i*10); + const QColor pixel = Utils::getScreenPixel(pos); + RDebug::Printf( + "Phonon::MMF::Utils::dumpScreenPixelSample %d %d = %d %d %d %d", + pos.x(), pos.y(), pixel.red(), pixel.green(), pixel.blue(), pixel.alpha() + ); + } +} + #endif // _DEBUG QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h index 7db7831..38964d0 100644 --- a/src/3rdparty/phonon/mmf/utils.h +++ b/src/3rdparty/phonon/mmf/utils.h @@ -59,6 +59,12 @@ MediaType mimeTypeToMediaType(const TDesC& mimeType); * Retrieve color of specified pixel from the screen. */ QColor getScreenPixel(const QPoint& pos); + +/** + * Samples a small number of pixels from the screen, and dumps their + * colors to the debug log. + */ +void dumpScreenPixelSample(); #endif } -- cgit v0.12 From 043e67c28171bc320b3dcb2e7c19db11fbd76c40 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 16 Sep 2009 18:24:17 +0100 Subject: Temporary fix: mediaplayer top-level widget sets Qt::WA_TranslucentBackground to allow video to be visible on target --- demos/mediaplayer/mediaplayer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/demos/mediaplayer/mediaplayer.cpp b/demos/mediaplayer/mediaplayer.cpp index 4bbe413..8ccab77 100644 --- a/demos/mediaplayer/mediaplayer.cpp +++ b/demos/mediaplayer/mediaplayer.cpp @@ -155,6 +155,10 @@ MediaPlayer::MediaPlayer(const QString &filePath) : m_videoWindow.setObjectName("videoWindow"); m_videoWidget->setObjectName("videoWidget"); + // setWindowTitle triggers creation of the window surface, so we set + // transparency here + setAttribute(Qt::WA_TranslucentBackground, true); + setWindowTitle(tr("Media Player")); setContextMenuPolicy(Qt::CustomContextMenu); m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); -- cgit v0.12 From 13850822dafa6e3e5976b1ea7644403e6caec4f4 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 16 Sep 2009 18:26:02 +0100 Subject: Modified object annotator to dump display mode of Symbian windows --- src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp index 54ebc55..3d1d8b6 100644 --- a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp @@ -98,7 +98,10 @@ QList QAnnotatorWindow::annotation(const QObject& object) stream << window.Position().iX << ',' << window.Position().iY << ' '; stream << '(' << window.AbsPosition().iX << ',' << window.AbsPosition().iY << ") "; - stream << window.Size().iWidth << 'x' << window.Size().iHeight; + stream << window.Size().iWidth << 'x' << window.Size().iHeight << ' '; + + const TDisplayMode displayMode = window.DisplayMode(); + stream << "mode " << displayMode; stream.flush(); result.append(array); -- cgit v0.12 From a4c600e205a79c5dfc7657b792374a8ce9e308d0 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 16 Sep 2009 18:26:53 +0100 Subject: Added extra logging to QSymbianControl::Draw This function now dumps the colors of a sample of pixels in the bitmap about to be blitted. This is useful in debugging problems to do with visibility of video when running on target. --- src/gui/kernel/qapplication_s60.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 2a71073..f142053 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -639,7 +639,9 @@ void QSymbianControl::Draw(const TRect& r) const << "rect " << r.iTl.iX << ',' << r.iTl.iY << '-' << r.iBr.iX << ',' << r.iBr.iY << "surface" << surface - << "engine" << engine; + << "engine" << engine + << "raster" << (engine ? engine->type() == QPaintEngine::Raster : false) + << "opaque" << (qwidget->d_func()->isOpaque); #endif if (!engine) @@ -648,6 +650,18 @@ void QSymbianControl::Draw(const TRect& r) const if (engine->type() == QPaintEngine::Raster) { QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); CFbsBitmap *bitmap = s60Surface->symbianBitmap(); + +#ifdef DEBUG_QSYMBIANCONTROL + const TDisplayMode displayMode = bitmap->DisplayMode(); + qDebug() << "QSymbianControl::Draw [" << this << "]" + << "mode " << displayMode; + for(int i=0; i<10 and i*10SizeInPixels().iWidth and i*10SizeInPixels().iHeight; ++i) { + TRgb color; + bitmap->GetPixel(color, TPoint(i*10, i*10)); + qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); + } +#endif + CWindowGc &gc = SystemGc(); if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); -- cgit v0.12 From d2cad41ec85f753d7da4ddbf3fe70d034aaea8fc Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 16 Sep 2009 18:54:47 +0100 Subject: Modified video output widget to make video visible on target device --- src/3rdparty/phonon/mmf/TODO.txt | 12 +++++------- src/3rdparty/phonon/mmf/videooutput.cpp | 16 ++++++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 1d2cb44..47abddc 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -4,13 +4,11 @@ TODO list for MMF Phonon backend 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. +* Review the latest changes for making video visible on target. In particular, the temporary hack in qmediaplayer (setting the Qt::WA_TranslucentBackground attribute on the top-level widget, so that the CFbsBitmap used as the window surface is created with a display mode of EColor16MA) needs to be replaced with a change in QtGui. Some possiblilities are as follows: +1. Change the QS60WindowSurface constructor so that *all* window surfaces are 16MA. This has some drawbacks: + - It causes application backgrounds to be transparent, because CFbsBitmap data (including the alpha channel) gets zero-initialized. This may require the alpha values in the bitmap to be set to 255. + - Blitting of RGB32 and ABGR Qt pixmaps to a 16MA surface is slower than blitting to 16MU. This could be alleviated by modifying the software blitting routines. +2. Add a function in QS60WindowSurface, e.g. setAlphaValue(const QRegion& region, int value), allowing the client to set alpha values in the bitmap. Assuming that WSERV will transfer these values, when blitting a 16MU source, this would allow the video to be visible, and avoid the performance penalties of option (1). We would then call this from VideoOutput::paintEvent. * On-target testing 1. Ensure that Phonon front- and back-end libraries are included in the SIS file. diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 2544a97..2130d58 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -47,9 +47,9 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) #ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET setPalette(QPalette(Qt::black)); - //setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); - setAutoFillBackground(false); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + setAutoFillBackground(false); #endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET dump(); @@ -120,13 +120,17 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) dump(); -/* + // Note: composition mode code was a failed attempt to get transparent + // alpha values to be propagated to the (EColor16MU) window surface. + QPainter painter; + //const QPainter::CompositionMode compositionMode = painter.compositionMode(); + //painter.setCompositionMode(QPainter::CompositionMode_Source); painter.begin(this); - painter.setBrush(QColor(0, 0, 0, 255)); // opaque black + painter.setBrush(QColor(0, 0, 0, 0)); painter.drawRects(event->region().rects()); painter.end(); -*/ + //painter.setCompositionMode(compositionMode); } void MMF::VideoOutput::resizeEvent(QResizeEvent* event) -- cgit v0.12 From f1e353e183d3d4ee3ffd0c869800d0f2fb3def18 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 17 Sep 2009 08:02:08 +0100 Subject: Fixed typo (additional brace) in fluidlauncher.pro --- demos/embedded/fluidlauncher/fluidlauncher.pro | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index 892a4ba..639a233 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -126,6 +126,12 @@ symbian { } resource.path = $$APP_RESOURCE_DIR + + contains(QT_CONFIG, script) { + executables.sources += context2d.exe + reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/context2d_reg.rsc + resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/context2d.rsc + } mifs.sources = \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C611.mif -- cgit v0.12 From 8f8ca07b26709e719ef82b4304c17fef617a4af7 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 17 Sep 2009 08:21:19 +0100 Subject: Replaced explicit epoc32/include path with (more portable) MW_LAYER_SYSTEMINCLUDE macro --- src/plugins/phonon/mmf/plugin/plugin.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index d620453..9a9002f 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -19,7 +19,7 @@ phonon_mmf_audio_drm { # In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this folder, as # opposed to the public, where it is placed in epoc32/include. In some cases # it's needed for other headers as well. -INCLUDEPATH += /epoc32/include/osextensions +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE HEADERS += \ $$PHONON_MMF_DIR/abstractaudioeffect.h \ -- cgit v0.12 From 031260adc1093e95c1c4d95d1d322b5b47ac1891 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 17 Sep 2009 11:30:53 +0100 Subject: Added system includes to QtCore project file This is necessary to allow compilation in certain S60 5th edition environments --- src/corelib/io/io.pri | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index b49554e..bca9baa 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -89,5 +89,7 @@ win32 { symbian { SOURCES += io/qfilesystemwatcher_symbian.cpp HEADERS += io/qfilesystemwatcher_symbian_p.h + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + contains(QT_CONFIG, s60): LIBS += -lplatformenv } } -- cgit v0.12 From 8a6da961602d9e372a9ccf88332889b4dffda825 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 17 Sep 2009 12:47:07 +0100 Subject: Added function for writing transparent pixels directly to the backing store See VideoOutput::transparentFill. This should be called from the paintEvent, having removed the TranslucentWindowBackground hack from the mediaplayer demo. As yet this has not been tested. --- src/3rdparty/phonon/mmf/defs.h | 4 +++ src/3rdparty/phonon/mmf/videooutput.cpp | 47 +++++++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/videooutput.h | 3 +++ 3 files changed, 54 insertions(+) diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index afb25dc..d5301d2 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -38,6 +38,10 @@ along with this library. If not, see . // problems caused by the window-owning control change. //#define PHONON_MMF_HARD_CODE_VIDEO_RECT_TO_EMPTY +// Defining this macro causes VideoOutput::paintEvent to write transparent +// alpha values directly into the backing store, rather than using QPainter +//#define PHONON_MMF_DIRECT_WRITE_ALPHA + QT_BEGIN_NAMESPACE namespace Phonon diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 2130d58..27e4f54 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -29,6 +29,13 @@ along with this library. If not, see . #include #include +// Required for implementation of transparentFill +#include +#include +#include +#include + + QT_BEGIN_NAMESPACE using namespace Phonon; @@ -120,6 +127,9 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) dump(); +#ifdef PHONON_MMF_DIRECT_WRITE_ALPHA + transparentFill(event->region().rects()); +#else // Note: composition mode code was a failed attempt to get transparent // alpha values to be propagated to the (EColor16MU) window surface. @@ -131,6 +141,43 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) painter.drawRects(event->region().rects()); painter.end(); //painter.setCompositionMode(compositionMode); +#endif +} + +void MMF::VideoOutput::transparentFill(const QVector& rects) +{ + TRACE_CONTEXT(VideoOutput::transparentFill, EVideoInternal); + TRACE_ENTRY_0(); + + QImage *image = window()->windowSurface()->buffer(window()); + QRgb *data = reinterpret_cast(image->bits()); + const int row_stride = image->bytesPerLine() / 4; + + for (QVector::const_iterator it = rects.begin(); it != rects.end(); ++it) { + + const QRect& rect = *it; + + TRACE("%d %d size %d x %d", rect.x(), rect.y(), rect.width(), rect.height()); + + const int x_start = rect.x(); + const int width = rect.width(); + + const int y_start = rect.y(); + const int height = rect.height(); + + QRgb *row = data + row_stride * y_start; + for (int y = 0; y < height; ++y) { + + // Note: not using the optimised qt_memfill function implemented in + // gui/painting/qdrawhelper.cpp - can we somehow link against this? + + //qt_memfill(row + x_start, 0U, width); + memset(row + x_start, 0, width*4); + row += row_stride; + } + } + + TRACE_EXIT_0(); } void MMF::VideoOutput::resizeEvent(QResizeEvent* event) diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 566d065..298b4fe 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -20,6 +20,8 @@ along with this library. If not, see . #define PHONON_MMF_VIDEOOUTPUT_H #include +#include +#include #include "defs.h" QT_BEGIN_NAMESPACE @@ -52,6 +54,7 @@ protected: private: void dump() const; + void transparentFill(const QVector& rects); private: QSize m_frameSize; -- cgit v0.12 From cabf0776a3e879aa80e4dc01fd470248c429d9b0 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 17 Sep 2009 14:42:10 +0100 Subject: Modified transparentFill to allow RGBA color to be specified more easily, for testing --- src/3rdparty/phonon/mmf/videooutput.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 27e4f54..b1a2b4f 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -171,8 +171,10 @@ void MMF::VideoOutput::transparentFill(const QVector& rects) // Note: not using the optimised qt_memfill function implemented in // gui/painting/qdrawhelper.cpp - can we somehow link against this? - //qt_memfill(row + x_start, 0U, width); - memset(row + x_start, 0, width*4); + QRgb *ptr = row + x_start; + for(int x = 0; x < width; ++x) + *ptr++ = 0x00000000; + row += row_stride; } } -- cgit v0.12 From c85d1764d713722f1bb1108087d41ff7904ab3cb Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 17 Sep 2009 14:51:06 +0100 Subject: Removed temporary hacks used during initial development of video widget --- src/3rdparty/phonon/mmf/defs.h | 14 -------------- src/3rdparty/phonon/mmf/videooutput.cpp | 10 ---------- src/3rdparty/phonon/mmf/videooutput.h | 2 -- src/3rdparty/phonon/mmf/videoplayer.cpp | 14 +------------- 4 files changed, 1 insertion(+), 39 deletions(-) diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index d5301d2..348a40f 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -24,20 +24,6 @@ along with this library. If not, see . // 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 -// 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() -//#define PHONON_MMF_HARD_CODE_VIDEO_RECT - -// Hack to make the video invisible. This is used in order to debug -// problems caused by the window-owning control change. -//#define PHONON_MMF_HARD_CODE_VIDEO_RECT_TO_EMPTY - // Defining this macro causes VideoOutput::paintEvent to write transparent // alpha values directly into the backing store, rather than using QPainter //#define PHONON_MMF_DIRECT_WRITE_ALPHA diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index b1a2b4f..c2bd775 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -52,12 +52,10 @@ 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(); @@ -74,9 +72,6 @@ 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(), @@ -86,7 +81,6 @@ void MMF::VideoOutput::setFrameSize(const QSize& frameSize) m_frameSize = frameSize; updateGeometry(); } -#endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET } void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) @@ -102,8 +96,6 @@ void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) // QWidget //----------------------------------------------------------------------------- -#ifndef PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET - QSize MMF::VideoOutput::sizeHint() const { // TODO: replace this with a more sensible default @@ -208,8 +200,6 @@ void MMF::VideoOutput::moveEvent(QMoveEvent* event) m_observer->videoOutputRegionChanged(); } -#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 298b4fe..5a7b9cd 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -44,13 +44,11 @@ public: 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); -#endif // PHONON_MMF_VIDEOOUTPUT_IS_QWIDGET private: void dump() const; diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 827c2a1..e2c0b7d 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -415,24 +415,12 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() dumper->dumpObject(output); #endif -#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); - m_clipRect = m_windowRect; -#else m_windowRect = TRect( control->DrawableWindow()->AbsPosition(), control->DrawableWindow()->Size()); m_clipRect = m_windowRect; -#endif - -#ifdef PHONON_MMF_HARD_CODE_VIDEO_RECT_TO_EMPTY - m_windowRect = TRect(0, 0, 0, 0); - 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); -- cgit v0.12 From a84af9b6574a10383a92908debfc161a764d2d01 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 17 Sep 2009 16:23:50 +0200 Subject: =?UTF-8?q?Set=20translucent=20background=20only=20where=20it's=20?= =?UTF-8?q?needed:=20Symbian.=C3=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demos/mediaplayer/mediaplayer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/demos/mediaplayer/mediaplayer.cpp b/demos/mediaplayer/mediaplayer.cpp index 8ccab77..9504236 100644 --- a/demos/mediaplayer/mediaplayer.cpp +++ b/demos/mediaplayer/mediaplayer.cpp @@ -154,11 +154,13 @@ MediaPlayer::MediaPlayer(const QString &filePath) : { m_videoWindow.setObjectName("videoWindow"); m_videoWidget->setObjectName("videoWidget"); - + +#ifdef Q_OS_SYMBIAN // setWindowTitle triggers creation of the window surface, so we set // transparency here setAttribute(Qt::WA_TranslucentBackground, true); - +#endif + setWindowTitle(tr("Media Player")); setContextMenuPolicy(Qt::CustomContextMenu); m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); -- cgit v0.12 From fcd7649d90f27414900e42a07ec603d1f7509962 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 17 Sep 2009 16:37:52 +0200 Subject: Cleanup debugging code. --- src/gui/gui.pro | 3 ++ src/gui/kernel/qapplication_s60.cpp | 14 +-------- src/gui/kernel/qwidget_s60.cpp | 18 +---------- src/gui/kernel/symbian.pri | 2 -- src/gui/kernel/window_owning_control.h | 57 ---------------------------------- 5 files changed, 5 insertions(+), 89 deletions(-) delete mode 100644 src/gui/kernel/window_owning_control.h diff --git a/src/gui/gui.pro b/src/gui/gui.pro index ad74e47..9fe09c8 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -4,6 +4,9 @@ QT = core DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000 +# These enable debugging of window management for Symbian. +#DEFINES += DEBUG_QSYMBIANCONTROL DEBUG_QWIDGET + !win32:!embedded:!mac:!symbian:CONFIG += x11 unix:QMAKE_PKGCONFIG_REQUIRES = QtCore diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index f142053..2035bb0 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -70,13 +70,10 @@ #include "private/qstylesheetstyle_p.h" -#ifdef _DEBUG -#define DEBUG_QSYMBIANCONTROL +#ifdef DEBUG_QSYMBIANCONTROL #include #endif -#include "window_owning_control.h" - QT_BEGIN_NAMESPACE #if defined(QT_DEBUG) @@ -324,7 +321,6 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) { if (!desktop) { -#ifdef QWIDGET_OWNS_WINDOW if (topLevel or !qwidget->parentWidget()) CreateWindowL(S60->windowGroup()); else @@ -336,19 +332,11 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) * 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. */ - #ifdef QWIDGET_IMMEDIATE_WINDOW_PARENT CreateWindowL(qwidget->parentWidget()->winId()); - #else - CreateWindowL(qwidget->parentWidget()->effectiveWinId()); - #endif // QWIDGET_IMMEDIATE_WINDOW_PARENT // Necessary in order to be able to track the activation status of // the control's window qwidget->d_func()->createTLExtra(); -#else - if (topLevel) - CreateWindowL(S60->windowGroup()); -#endif // QWIDGET_OWNS_WINDOW #ifdef DEBUG_QSYMBIANCONTROL qDebug() << "QSymbianControl::ConstructL [" << this diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 28ce90e..998606f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -56,13 +56,10 @@ #include #endif -#ifdef _DEBUG -#define DEBUG_QWIDGET +#ifdef DEBUG_QWIDGET #include #endif -#include "window_owning_control.h" - QT_BEGIN_NAMESPACE extern bool qt_nograb(); @@ -614,11 +611,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); -#ifndef QWIDGET_OWNS_WINDOW - WId parentw = parentWidget->effectiveWinId(); - QT_TRAP_THROWING(control->SetContainerWindowL(*parentw)); -#endif - q->setAttribute(Qt::WA_WState_Created); int x, y, w, h; data.crect.getRect(&x, &y, &w, &h); @@ -653,11 +645,7 @@ void QWidgetPrivate::show_sys() return; } -#ifdef QWIDGET_OWNS_WINDOW if (q->internalWinId()) { -#else - if (q->isWindow() && q->internalWinId()) { -#endif WId id = q->internalWinId(); if (!extra->topextra->activated) { @@ -700,11 +688,7 @@ void QWidgetPrivate::hide_sys() deactivateWidgetCleanup(); WId id = q->internalWinId(); -#ifdef QWIDGET_OWNS_WINDOW if (id) { -#else - if (q->isWindow() && id) { -#endif #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::show_sys [" << this << "]" diff --git a/src/gui/kernel/symbian.pri b/src/gui/kernel/symbian.pri index 87d8492..d267a53 100644 --- a/src/gui/kernel/symbian.pri +++ b/src/gui/kernel/symbian.pri @@ -1,5 +1,3 @@ symbian { - HEADERS += window_owning_control.h - contains(QT_CONFIG, s60): LIBS+= $$QMAKE_LIBS_S60 } diff --git a/src/gui/kernel/window_owning_control.h b/src/gui/kernel/window_owning_control.h deleted file mode 100644 index af192f3..0000000 --- a/src/gui/kernel/window_owning_control.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WINDOW_OWNING_CONTROL_H -#define WINDOW_OWNING_CONTROL_H - -// If this is defined, then calling QWidget::winId causes a native window to -// be created for the associated control -#define QWIDGET_OWNS_WINDOW - -// If QWIDGET_OWNS_WINDOW is defined, defining this macro means that the -// parent window for the newly created window is the parent widget's winId. -// This in turn means that calling QWidget::winId causes native windows to -// be created for all ancestors of the target widget. -// If this macro is undefined, the parent window is the parent widget's -// effectiveWinId. -#define QWIDGET_IMMEDIATE_WINDOW_PARENT - -#endif // WINDOW_OWNING_CONTROL_H -- cgit v0.12 From 025a30273124845bafe827065894264c4352d8b2 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 18 Sep 2009 15:20:01 +0200 Subject: Document Phonon support in Symbian. Reviewed-by: David Boddie --- doc/src/platforms/platform-notes.qdoc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc index e79b2f4..048eb48 100644 --- a/doc/src/platforms/platform-notes.qdoc +++ b/doc/src/platforms/platform-notes.qdoc @@ -411,6 +411,24 @@ For information about mixing exceptions with symbian leaves, see \l{Exception Safety with Symbian} + + \section1 Multimedia and Phonon Support + + Qt provides a backend for Qt's multimedia module, Phonon, which supports + video and sound playback through Symbian's Multimedia Framework, MMF. + + In this release the support is experimental. Video playback may have + flickering issues, and support for effects and playback queueing is + incomplete. + + The audio and video formats that Phonon supports depends on what support + the platform provides for MMF. The emulator is known to have limited + codec support. + + In addition, there exists a backend for the Helix framework. However, due + to it not shipping with Qt, its availability depends on the Symbian + platform in use. If available, it is loaded instead of the MMF plugin. + */ /*! -- cgit v0.12 From c2db588c321301c30006be0720eda88b903738f1 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 18 Sep 2009 17:08:54 +0200 Subject: Build fix for SDK 3.1 and 3.2. --- src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp index 3d1d8b6..f8adcd5 100644 --- a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp @@ -80,10 +80,13 @@ QList QAnnotatorWindow::annotation(const QObject& object) stream << "window: "; + // ClientHandle() is available first in 5.0. +#if !defined(__SERIES60_31__) && !defined(__S60_32__) // Client-side window handle // Cast to a void pointer so that log output is in hexadecimal format. stream << "cli " << reinterpret_cast(window.ClientHandle()) << ' '; - +#endif + // Server-side address of CWsWindow object // This is useful for correlation with the window tree dumped by the window // server (see RWsSession::LogCommand). -- cgit v0.12 From a68a747e9d97962e0d18bf852450192898163f14 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 18 Sep 2009 17:44:11 +0200 Subject: Build fix for SDK 3.1. --- src/3rdparty/phonon/mmf/audioplayer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 127b921..17294a7 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -93,7 +93,13 @@ void MMF::AudioPlayer::doSeek(qint64 ms) int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) { + /* In SDK 3.1, this function is void. */ +#if !defined(__SERIES60_31__) return m_player->SetVolume(mmfVolume); +#else + m_player->SetVolume(mmfVolume); + return KErrNone; +#endif } int MMF::AudioPlayer::openFile(RFile& file) -- cgit v0.12 From 613e1ea9ef9e1cc7fdbfa5882432e9e6df003544 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 18 Sep 2009 17:50:57 +0200 Subject: RoomLevel is not available in SDK 3.1, remove it. In any case, we haven't implemented this effect. --- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 1 - src/3rdparty/phonon/mmf/effectfactory.cpp | 8 -------- src/plugins/phonon/mmf/plugin/plugin.pro | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 9957e25..01542c9 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -76,7 +76,6 @@ public: EffectEnvironmentalReverb, EffectListenerOrientation, EffectLoudness, - //EffectRoomLevel, EffectSourceOrientation, EffectStereoWidening }; diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index 41f48d2..f33af68 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -26,7 +26,6 @@ along with this library. If not, see . #include #include #include -#include #include #include @@ -69,7 +68,6 @@ QHash EffectFactory::audioEffectDescriptions(AbstractAudio return constructEffectDescription(QObject::tr("Environmental Reverb"), "Environmental Reverb."); case AbstractAudioEffect::EffectLoudness: return constructEffectDescription(QObject::tr("Loudness"), "Loudness."); - //case EffectRoomLevel: case AbstractAudioEffect::EffectSourceOrientation: return constructEffectDescription(QObject::tr("Source Orientation"), "Source Orientation."); case AbstractAudioEffect::EffectStereoWidening: @@ -95,7 +93,6 @@ AbstractAudioEffect *EffectFactory::createAudioEffect(AbstractAudioEffect::Type case AbstractAudioEffect::EffectEnvironmentalReverb: case AbstractAudioEffect::EffectListenerOrientation: case AbstractAudioEffect::EffectLoudness: - //AbstractAudioEffect::EffectRoomLevel, case AbstractAudioEffect::EffectSourceOrientation: case AbstractAudioEffect::EffectStereoWidening: ; @@ -141,11 +138,6 @@ QList EffectFactory::effectIndexes() if (isEffectSupported()) retval.append(AbstractAudioEffect::EffectSourceOrientation); - /* - if (isEffectSupported()) - retval.append(EffectRoomLevel); - */ - if (isEffectSupported()) retval.append(AbstractAudioEffect::EffectStereoWidening); diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index 9a9002f..0dd909d 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -73,7 +73,7 @@ LIBS += -lefsrv # For file server LIBS += -lapgrfx -lapmime # For recognizer # These are for effects. -LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lRoomLevelEffect -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect +LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect # 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 be44bb7e43c76305133b09918c3ad8d3f9b2bed5 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 17 Sep 2009 18:25:23 +0100 Subject: Added extra trace for investigation of 16MU blitting behaviour --- src/3rdparty/phonon/mmf/videooutput.cpp | 17 ++++++++++++++++- src/gui/kernel/qapplication_s60.cpp | 13 ++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index c2bd775..d0f8707 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -144,7 +144,21 @@ void MMF::VideoOutput::transparentFill(const QVector& rects) QImage *image = window()->windowSurface()->buffer(window()); QRgb *data = reinterpret_cast(image->bits()); const int row_stride = image->bytesPerLine() / 4; - + + // Paint the entire surface + const int imageWidth = image->size().width(); + const int imageHeight = image->size().height(); + QRgb *row = data; + for(int y=0; y::const_iterator it = rects.begin(); it != rects.end(); ++it) { const QRect& rect = *it; @@ -170,6 +184,7 @@ void MMF::VideoOutput::transparentFill(const QVector& rects) row += row_stride; } } +*/ TRACE_EXIT_0(); } diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 2035bb0..3cb7ada 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -643,7 +643,18 @@ void QSymbianControl::Draw(const TRect& r) const const TDisplayMode displayMode = bitmap->DisplayMode(); qDebug() << "QSymbianControl::Draw [" << this << "]" << "mode " << displayMode; - for(int i=0; i<10 and i*10SizeInPixels().iWidth and i*10SizeInPixels().iHeight; ++i) { + + const TUint32 *address = bitmap->DataAddress(); + const int bitmapWidth = bitmap->SizeInPixels().iWidth; + const int bitmapHeight = bitmap->SizeInPixels().iHeight; + + for(int i=0; i<10 and i*10GetPixel(color, TPoint(i*10, i*10)); qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); -- cgit v0.12 From da4e047c7bcf6dc966dcb862033ce8c09bd561d9 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 18 Sep 2009 18:18:38 +0100 Subject: Experimenting to make video visible. Removed the hack to set translucent window background in the mediaplayer. Then tried the following: 1. Direct write to backing store: does not work (backing bitmap is 16MU) 2. Set window background color: does not work (is over-written by control's Draw function) 3. Brush using CWindowGc from widget's paint event: does not work (is over-written by control's Draw function) 4. Hack QSymbianControl to blit a transparent bitmap from the Draw function: does work 5. Hack QSymbianControl to brush using CWindowGc from the Draw function: does work Configuration 5 is the one being committed. Other things we could try: 6. Trigger switch to 16MA backing store if child widgets have been created. This could be tested by calling RWindowTreeNode::Child on the TLW's window. - Maybe we could test whether the child window's display mode is 16MA? 7. Somehow tell QSymbianControl not to draw anything at all - Based on setting Qt::WA_PaintOnScreen? - Then we either: - (Ideally) do nothing, and rely on video stack to paint the necessary transparency - Brush using CWindowGc from widget's paint event --- demos/mediaplayer/mediaplayer.cpp | 2 ++ src/3rdparty/phonon/mmf/defs.h | 2 +- src/3rdparty/phonon/mmf/videooutput.cpp | 36 +++++++++++++++++++++++++++++--- src/3rdparty/phonon/mmf/videoplayer.cpp | 20 ++++++++++++++++++ src/gui/gui.pro | 2 +- src/gui/kernel/qapplication_s60.cpp | 17 ++++++++++++++- src/gui/kernel/qt_s60_p.h | 33 +++++++++++++++++++++++++++++ src/plugins/phonon/mmf/plugin/plugin.pro | 4 ++++ 8 files changed, 110 insertions(+), 6 deletions(-) diff --git a/demos/mediaplayer/mediaplayer.cpp b/demos/mediaplayer/mediaplayer.cpp index 9504236..f3f4128 100644 --- a/demos/mediaplayer/mediaplayer.cpp +++ b/demos/mediaplayer/mediaplayer.cpp @@ -156,9 +156,11 @@ MediaPlayer::MediaPlayer(const QString &filePath) : m_videoWidget->setObjectName("videoWidget"); #ifdef Q_OS_SYMBIAN +/* // setWindowTitle triggers creation of the window surface, so we set // transparency here setAttribute(Qt::WA_TranslucentBackground, true); +*/ #endif setWindowTitle(tr("Media Player")); diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index 348a40f..e4e06e4 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -26,7 +26,7 @@ along with this library. If not, see . // Defining this macro causes VideoOutput::paintEvent to write transparent // alpha values directly into the backing store, rather than using QPainter -//#define PHONON_MMF_DIRECT_WRITE_ALPHA +#define PHONON_MMF_DIRECT_WRITE_ALPHA QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index d0f8707..58fa25d 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -29,12 +29,17 @@ along with this library. If not, see . #include #include -// Required for implementation of transparentFill +// Required for implementation of transparentFill (direct write to backing store) #include #include #include #include +// Required for implementation of transparentFill (GC brush) +#include +#include +#include + QT_BEGIN_NAMESPACE @@ -140,11 +145,35 @@ void MMF::VideoOutput::transparentFill(const QVector& rects) { TRACE_CONTEXT(VideoOutput::transparentFill, EVideoInternal); TRACE_ENTRY_0(); + +/* + // Graphics context brushing approach + RWindow *const window = static_cast(winId()->DrawableWindow()); + const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); + CWindowGc& gc = CEikonEnv::Static()->SystemGc(); + gc.Activate(*window); + gc.SetBrushColor(TRgb(255, 255, 255, 0)); + gc.SetBrushStyle(CGraphicsContext::ESolidBrush); + gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + window->Invalidate(); + window->BeginRedraw(); + gc.Clear(); + window->EndRedraw(); + gc.Deactivate(); +*/ +/* + // Direct draw into backing store approach (entire TLW) QImage *image = window()->windowSurface()->buffer(window()); QRgb *data = reinterpret_cast(image->bits()); const int row_stride = image->bytesPerLine() / 4; + const QRgb color = + //0xff0000ff // opaque blue + 0x000000ff // transparent blue + //0x00000000 // transparent black + ; + // Paint the entire surface const int imageWidth = image->size().width(); const int imageHeight = image->size().height(); @@ -153,12 +182,13 @@ void MMF::VideoOutput::transparentFill(const QVector& rects) QRgb *ptr = row; for(int x=0; x::const_iterator it = rects.begin(); it != rects.end(); ++it) { const QRect& rect = *it; diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index e2c0b7d..cc56671 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -30,6 +30,8 @@ along with this library. If not, see . #include "objectdump.h" #endif +#include // for QSymbianControl + QT_BEGIN_NAMESPACE using namespace Phonon; @@ -125,7 +127,9 @@ void MMF::VideoPlayer::doPlay() updateMmfOutput(); } + TRAP_IGNORE(m_player->SetVolumeL(0)); // *** HACK *** m_player->Play(); + TRAP_IGNORE(m_player->SetVolumeL(0)); // *** HACK *** } void MMF::VideoPlayer::doPause() @@ -402,11 +406,27 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() VideoOutput& output = videoOutput(); CCoeControl* const control = output.winId(); + // Inform control that it needs to brush rather than blit the backing store + QSymbianControl* const symbianControl = static_cast(control); + //symbianControl->setBlit(0xff00ff00); // opaque green + //symbianControl->setBlit(0x0000ff00); // transparent green + symbianControl->setBlit(0x00000000); // transparent black + CCoeEnv* const coeEnv = control->ControlEnv(); m_wsSession = &(coeEnv->WsSession()); m_screenDevice = coeEnv->ScreenDevice(); m_window = control->DrawableWindow(); +/* + // Set background window color + RWindow *const window = static_cast(m_window); + const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); + //const TInt err = window->SetTransparencyAlphaChannel(); + //if (err == KErrNone) + window->SetBackgroundColor(TRgb(255, 0, 255, 255)); + window->Invalidate(); // force a redraw +*/ + #ifdef _DEBUG QScopedPointer dumper(new ObjectDump::QDumper); dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 9fe09c8..f95be59 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -5,7 +5,7 @@ DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000 # These enable debugging of window management for Symbian. -#DEFINES += DEBUG_QSYMBIANCONTROL DEBUG_QWIDGET +DEFINES += DEBUG_QSYMBIANCONTROL DEBUG_QWIDGET !win32:!embedded:!mac:!symbian:CONFIG += x11 diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 3cb7ada..e3f3376 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -652,6 +652,7 @@ void QSymbianControl::Draw(const TRect& r) const const int coord = i*10; const TUint32 *ptr = address + (coord * bitmapWidth) + coord; const TUint32 pixel = *ptr; + qDebug() << " " << i*10 << " : " << ptr << pixel; } for(int i=0; i<10 and i*10d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - gc.BitBlt(r.iTl, bitmap, r); + + if(m_bitmap.data()) { + //gc.BitBlt(r.iTl, m_bitmap.data(), TRect(TPoint(), r.Size())); + + gc.SetBrushColor(TRgb(0, 0, 0, 0)); + gc.SetBrushStyle(CGraphicsContext::ESolidBrush); + gc.Clear(r); + } + else + gc.BitBlt(r.iTl, bitmap, r); } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); } @@ -699,6 +709,11 @@ void QSymbianControl::SizeChanged() if (!slowResize && tlwExtra) tlwExtra->inTopLevelResize = false; } + + if(m_bitmap.data()) { + m_bitmap->Resize(Size()); + fillBitmap(); + } } } diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 1ac6a8e..5331504 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -74,6 +74,8 @@ #include // CEikStatusPane #endif +#include // for CFbsBitmap + QT_BEGIN_NAMESPACE // Application internal HandleResourceChangeL events, @@ -120,6 +122,8 @@ public: }; class QLongTapTimer; +class CFbsBitmap; + class QSymbianControl : public CCoeControl, public QAbstractLongTapObserver { public: @@ -142,6 +146,8 @@ public: void sendInputEvent(QWidget *widget, QInputEvent *inputEvent); void setIgnoreFocusChanged(bool enabled) { m_ignoreFocusChanged = enabled; } void CancelLongTapTimer(); + + void setBlit(TUint32 color); protected: void Draw(const TRect& aRect) const; @@ -156,13 +162,40 @@ private: void sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); + void fillBitmap(); + private: QWidget *qwidget; bool m_ignoreFocusChanged; QLongTapTimer* m_longTapDetector; bool m_previousEventLongTap; + + QScopedPointer m_bitmap; + TUint32 m_color; }; + + +inline void QSymbianControl::setBlit(TUint32 color) +{ + m_bitmap.reset( q_check_ptr(new CFbsBitmap) ); // CBase derived object needs check on new + qt_symbian_throwIfError( m_bitmap->Create(Size(), EColor16MA) ); + + // Not sure if bitmap pixel data is zero-initialized, so do it here to make sure + m_color = color; + fillBitmap(); +} + +inline void QSymbianControl::fillBitmap() +{ + TUint32* ptr = m_bitmap->DataAddress(); + for(int y=0; y Date: Mon, 21 Sep 2009 13:02:14 +0100 Subject: Removed the WA_TranslucentWindowBackground hack from qmediaplayer --- demos/mediaplayer/mediaplayer.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/demos/mediaplayer/mediaplayer.cpp b/demos/mediaplayer/mediaplayer.cpp index f3f4128..868f6b1 100644 --- a/demos/mediaplayer/mediaplayer.cpp +++ b/demos/mediaplayer/mediaplayer.cpp @@ -155,14 +155,6 @@ MediaPlayer::MediaPlayer(const QString &filePath) : m_videoWindow.setObjectName("videoWindow"); m_videoWidget->setObjectName("videoWidget"); -#ifdef Q_OS_SYMBIAN -/* - // setWindowTitle triggers creation of the window surface, so we set - // transparency here - setAttribute(Qt::WA_TranslucentBackground, true); -*/ -#endif - setWindowTitle(tr("Media Player")); setContextMenuPolicy(Qt::CustomContextMenu); m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); -- cgit v0.12 From d08436fbe0bd8da16aec2a0936c7d768e4045bfa Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 21 Sep 2009 13:12:56 +0100 Subject: Removed hack in QSymbianControl for blitting a transparent bitmap in place of the backing store region --- src/3rdparty/phonon/mmf/videoplayer.cpp | 22 ++-------------------- src/gui/kernel/qapplication_s60.cpp | 13 ------------- src/gui/kernel/qt_s60_p.h | 29 ----------------------------- 3 files changed, 2 insertions(+), 62 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index cc56671..7b4626c 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -30,8 +30,6 @@ along with this library. If not, see . #include "objectdump.h" #endif -#include // for QSymbianControl - QT_BEGIN_NAMESPACE using namespace Phonon; @@ -405,28 +403,12 @@ void MMF::VideoPlayer::getNativeWindowSystemHandles() VideoOutput& output = videoOutput(); CCoeControl* const control = output.winId(); - - // Inform control that it needs to brush rather than blit the backing store - QSymbianControl* const symbianControl = static_cast(control); - //symbianControl->setBlit(0xff00ff00); // opaque green - //symbianControl->setBlit(0x0000ff00); // transparent green - symbianControl->setBlit(0x00000000); // transparent black - + CCoeEnv* const coeEnv = control->ControlEnv(); m_wsSession = &(coeEnv->WsSession()); m_screenDevice = coeEnv->ScreenDevice(); m_window = control->DrawableWindow(); - -/* - // Set background window color - RWindow *const window = static_cast(m_window); - const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); - //const TInt err = window->SetTransparencyAlphaChannel(); - //if (err == KErrNone) - window->SetBackgroundColor(TRgb(255, 0, 255, 255)); - window->Invalidate(); // force a redraw -*/ - + #ifdef _DEBUG QScopedPointer dumper(new ObjectDump::QDumper); dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index e3f3376..4c96a2a 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -666,14 +666,6 @@ void QSymbianControl::Draw(const TRect& r) const if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - if(m_bitmap.data()) { - //gc.BitBlt(r.iTl, m_bitmap.data(), TRect(TPoint(), r.Size())); - - gc.SetBrushColor(TRgb(0, 0, 0, 0)); - gc.SetBrushStyle(CGraphicsContext::ESolidBrush); - gc.Clear(r); - } - else gc.BitBlt(r.iTl, bitmap, r); } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); @@ -709,11 +701,6 @@ void QSymbianControl::SizeChanged() if (!slowResize && tlwExtra) tlwExtra->inTopLevelResize = false; } - - if(m_bitmap.data()) { - m_bitmap->Resize(Size()); - fillBitmap(); - } } } diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 5331504..5870e2c 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -146,8 +146,6 @@ public: void sendInputEvent(QWidget *widget, QInputEvent *inputEvent); void setIgnoreFocusChanged(bool enabled) { m_ignoreFocusChanged = enabled; } void CancelLongTapTimer(); - - void setBlit(TUint32 color); protected: void Draw(const TRect& aRect) const; @@ -161,41 +159,14 @@ private: TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent); void sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); - - void fillBitmap(); private: QWidget *qwidget; bool m_ignoreFocusChanged; QLongTapTimer* m_longTapDetector; bool m_previousEventLongTap; - - QScopedPointer m_bitmap; - TUint32 m_color; }; - - -inline void QSymbianControl::setBlit(TUint32 color) -{ - m_bitmap.reset( q_check_ptr(new CFbsBitmap) ); // CBase derived object needs check on new - qt_symbian_throwIfError( m_bitmap->Create(Size(), EColor16MA) ); - - // Not sure if bitmap pixel data is zero-initialized, so do it here to make sure - m_color = color; - fillBitmap(); -} - -inline void QSymbianControl::fillBitmap() -{ - TUint32* ptr = m_bitmap->DataAddress(); - for(int y=0; y Date: Mon, 21 Sep 2009 13:23:44 +0100 Subject: Removed transparency-blitting / -painting code from video widget --- src/3rdparty/phonon/mmf/defs.h | 7 --- src/3rdparty/phonon/mmf/videooutput.cpp | 105 +------------------------------- src/3rdparty/phonon/mmf/videooutput.h | 1 - 3 files changed, 1 insertion(+), 112 deletions(-) diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index e4e06e4..1a93aa9 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -21,13 +21,6 @@ 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. - -// Defining this macro causes VideoOutput::paintEvent to write transparent -// alpha values directly into the backing store, rather than using QPainter -#define PHONON_MMF_DIRECT_WRITE_ALPHA - QT_BEGIN_NAMESPACE namespace Phonon diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 58fa25d..b77a831 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -29,17 +29,6 @@ along with this library. If not, see . #include #include -// Required for implementation of transparentFill (direct write to backing store) -#include -#include -#include -#include - -// Required for implementation of transparentFill (GC brush) -#include -#include -#include - QT_BEGIN_NAMESPACE @@ -124,99 +113,7 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) dump(); -#ifdef PHONON_MMF_DIRECT_WRITE_ALPHA - transparentFill(event->region().rects()); -#else - // Note: composition mode code was a failed attempt to get transparent - // alpha values to be propagated to the (EColor16MU) window surface. - - QPainter painter; - //const QPainter::CompositionMode compositionMode = painter.compositionMode(); - //painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.begin(this); - painter.setBrush(QColor(0, 0, 0, 0)); - painter.drawRects(event->region().rects()); - painter.end(); - //painter.setCompositionMode(compositionMode); -#endif -} - -void MMF::VideoOutput::transparentFill(const QVector& rects) -{ - TRACE_CONTEXT(VideoOutput::transparentFill, EVideoInternal); - TRACE_ENTRY_0(); - -/* - // Graphics context brushing approach - RWindow *const window = static_cast(winId()->DrawableWindow()); - const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); - CWindowGc& gc = CEikonEnv::Static()->SystemGc(); - gc.Activate(*window); - gc.SetBrushColor(TRgb(255, 255, 255, 0)); - gc.SetBrushStyle(CGraphicsContext::ESolidBrush); - gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - window->Invalidate(); - window->BeginRedraw(); - gc.Clear(); - window->EndRedraw(); - gc.Deactivate(); -*/ - -/* - // Direct draw into backing store approach (entire TLW) - QImage *image = window()->windowSurface()->buffer(window()); - QRgb *data = reinterpret_cast(image->bits()); - const int row_stride = image->bytesPerLine() / 4; - - const QRgb color = - //0xff0000ff // opaque blue - 0x000000ff // transparent blue - //0x00000000 // transparent black - ; - - // Paint the entire surface - const int imageWidth = image->size().width(); - const int imageHeight = image->size().height(); - QRgb *row = data; - for(int y=0; y::const_iterator it = rects.begin(); it != rects.end(); ++it) { - - const QRect& rect = *it; - - TRACE("%d %d size %d x %d", rect.x(), rect.y(), rect.width(), rect.height()); - - const int x_start = rect.x(); - const int width = rect.width(); - - const int y_start = rect.y(); - const int height = rect.height(); - - QRgb *row = data + row_stride * y_start; - for (int y = 0; y < height; ++y) { - - // Note: not using the optimised qt_memfill function implemented in - // gui/painting/qdrawhelper.cpp - can we somehow link against this? - - QRgb *ptr = row + x_start; - for(int x = 0; x < width; ++x) - *ptr++ = 0x00000000; - - row += row_stride; - } - } -*/ - - TRACE_EXIT_0(); + // Do not paint anything } void MMF::VideoOutput::resizeEvent(QResizeEvent* event) diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 5a7b9cd..639a5ed 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -52,7 +52,6 @@ protected: private: void dump() const; - void transparentFill(const QVector& rects); private: QSize m_frameSize; -- cgit v0.12 From 4415b267e3f48a5e9bae1e0d72fe3c011ca9d9b6 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 21 Sep 2009 13:17:58 +0100 Subject: Moved window-related flags from QTLWExtra to QWExtra This is due to the fact that non-toplevel widgets may now be window-owning. Note that the RDrawableWindow* pointer has not been removed from QTLWExtra but has not been added to QWExtra. This is because it is not in fact needed - we can always retrieve the window from winid->DrawableWindow(). --- src/gui/kernel/qapplication_s60.cpp | 8 ++-- src/gui/kernel/qwidget_p.h | 5 +-- src/gui/kernel/qwidget_s60.cpp | 76 +++++++++++++++++-------------------- 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 4c96a2a..d163b37e 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -336,7 +336,7 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) // Necessary in order to be able to track the activation status of // the control's window - qwidget->d_func()->createTLExtra(); + qwidget->d_func()->createExtra(); #ifdef DEBUG_QSYMBIANCONTROL qDebug() << "QSymbianControl::ConstructL [" << this @@ -971,14 +971,14 @@ QWidget * QApplication::topLevelAt(QPoint const& point) if (widget->geometry().adjusted(0,0,1,1).contains(point)) { // At this point we know there is a Qt widget under the point. // Now we need to make sure it is the top most in the z-order. - RDrawableWindow* rw = widget->d_func()->topData()->rwindow; - int z = rw->OrdinalPosition(); + RDrawableWindow *const window = widget->effectiveWinId()->DrawableWindow(); + int z = window->OrdinalPosition(); if (z < lowestZ) { lowestZ = z; found = widget; } } - } + } } return found; } diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 8e58498..f4b9a4c 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -171,9 +171,6 @@ struct QTLWExtra { #ifndef QT_NO_QWS_MANAGER QWSManager *qwsManager; #endif -#elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN - uint activated : 1; // RWindowBase::Activated has been called - RDrawableWindow *rwindow; #endif }; @@ -226,6 +223,8 @@ struct QWExtra { QImage maskBits; CGImageRef imageMask; #endif +#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian + uint activated : 1; // RWindowBase::Activated has been called #endif }; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 998606f..0f69354 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -577,19 +577,18 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de stackingFlags = ECoeStackFlagStandard; } QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); - - QTLWExtra *topExtra = topData(); - topExtra->rwindow = control->DrawableWindow(); + + RDrawableWindow *const drawableWindow = control->DrawableWindow(); // Request mouse move events. - topExtra->rwindow->PointerFilter(EPointerFilterEnterExit + drawableWindow->PointerFilter(EPointerFilterEnterExit | EPointerFilterMove | EPointerFilterDrag, 0); - topExtra->rwindow->EnableVisibilityChangeEvents(); + drawableWindow->EnableVisibilityChangeEvents(); if (!isOpaque) { - RWindow *rwindow = static_cast(topExtra->rwindow); - TDisplayMode gotDM = (TDisplayMode)rwindow->SetRequiredDisplayMode(EColor16MA); - if (rwindow->SetTransparencyAlphaChannel() == KErrNone) - rwindow->SetBackgroundColor(TRgb(255, 255, 255, 0)); + RWindow *const window = static_cast(drawableWindow); + const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); + if (window->SetTransparencyAlphaChannel() == KErrNone) + window->SetBackgroundColor(TRgb(255, 255, 255, 0)); } } @@ -610,7 +609,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de stackingFlags = ECoeStackFlagStandard; } QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); - + q->setAttribute(Qt::WA_WState_Created); int x, y, w, h; data.crect.getRect(&x, &y, &w, &h); @@ -648,7 +647,7 @@ void QWidgetPrivate::show_sys() if (q->internalWinId()) { WId id = q->internalWinId(); - if (!extra->topextra->activated) { + if (!extra->activated) { #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::show_sys [" << this << "]" @@ -658,7 +657,7 @@ void QWidgetPrivate::show_sys() #endif QT_TRAP_THROWING(id->ActivateL()); - extra->topextra->activated = 1; + extra->activated = 1; } id->MakeVisible(true); @@ -761,10 +760,8 @@ void QWidgetPrivate::raise_sys() #endif Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - QTLWExtra *tlwExtra = maybeTopData(); - if (q->internalWinId() && tlwExtra) { - tlwExtra->rwindow->SetOrdinalPosition(0); - } + if (q->internalWinId()) + q->internalWinId()->DrawableWindow()->SetOrdinalPosition(0); } void QWidgetPrivate::lower_sys() @@ -777,10 +774,9 @@ void QWidgetPrivate::lower_sys() #endif Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - QTLWExtra *tlwExtra = maybeTopData(); - if (q->internalWinId() && tlwExtra) { - tlwExtra->rwindow->SetOrdinalPosition(-1); - } + if (q->internalWinId()) + q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); + if(!q->isWindow()) invalidateBuffer(q->rect()); } @@ -794,10 +790,13 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) { Q_Q(QWidget); Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - QTLWExtra *tlwExtra = maybeTopData(); - QTLWExtra *tlwExtraSibling = w->d_func()->maybeTopData(); - if (q->internalWinId() && tlwExtra && w->internalWinId() && tlwExtraSibling) - tlwExtra->rwindow->SetOrdinalPosition(tlwExtraSibling->rwindow->OrdinalPosition() + 1); + + if (q->internalWinId() && w->internalWinId()) { + RDrawableWindow *const thisWindow = q->internalWinId()->DrawableWindow(); + RDrawableWindow *const otherWindow = w->internalWinId()->DrawableWindow(); + thisWindow->SetOrdinalPosition(otherWindow->OrdinalPosition() + 1); + } + if(!q->isWindow() || !w->internalWinId()) invalidateBuffer(q->rect()); } @@ -923,17 +922,14 @@ void QWidgetPrivate::s60UpdateIsOpaque() if ((data.window_flags & Qt::FramelessWindowHint) == 0) return; + RWindow *const window = static_cast(q->effectiveWinId()->DrawableWindow()); + if (!isOpaque) { - QTLWExtra *topExtra = topData(); - RWindow *rwindow = static_cast(topExtra->rwindow); - TDisplayMode gotDM = (TDisplayMode)rwindow->SetRequiredDisplayMode(EColor16MA); - if (rwindow->SetTransparencyAlphaChannel() == KErrNone) - rwindow->SetBackgroundColor(TRgb(255, 255, 255, 0)); - } else { - QTLWExtra *topExtra = topData(); - RWindow *rwindow = static_cast(topExtra->rwindow); - rwindow->SetTransparentRegion(TRegionFix<1>()); - } + const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); + if (window->SetTransparencyAlphaChannel() == KErrNone) + window->SetBackgroundColor(TRgb(255, 255, 255, 0)); + } else + window->SetTransparentRegion(TRegionFix<1>()); } CFbsBitmap* qt_pixmapToNativeBitmap(QPixmap pixmap, bool invert) @@ -1107,8 +1103,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy) scrollRect(q->rect(), dx, dy); } else { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - RDrawableWindow* rw = topData()->rwindow; - rw->Scroll(TPoint(dx, dy)); + RDrawableWindow *const window = q->internalWinId()->DrawableWindow(); + window->Scroll(TPoint(dx, dy)); } } @@ -1120,8 +1116,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) scrollRect(r, dx, dy); } else { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - RDrawableWindow* rw = topData()->rwindow; - rw->Scroll(TPoint(dx, dy), qt_QRect2TRect(r)); + RDrawableWindow *const window = q->internalWinId()->DrawableWindow(); + window->Scroll(TPoint(dx, dy), qt_QRect2TRect(r)); } } @@ -1153,8 +1149,6 @@ void QWidgetPrivate::registerDropSite(bool /* on */) void QWidgetPrivate::createTLSysExtra() { extra->topextra->backingStore = 0; - extra->topextra->activated = 0; - extra->topextra->rwindow = 0; } void QWidgetPrivate::deleteTLSysExtra() @@ -1165,7 +1159,7 @@ void QWidgetPrivate::deleteTLSysExtra() void QWidgetPrivate::createSysExtra() { - + extra->activated = 0; } void QWidgetPrivate::deleteSysExtra() -- cgit v0.12 From 8f445e139a5ff9ed178dc123cb3dfc4200224c43 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 21 Sep 2009 13:20:22 +0100 Subject: Added disableBlit flag to (Symbian-specific version of) QWExtra This flag causes QSymbianControl::Draw not to blit the widget's region of the backing store. This is to support use cases such as video, which require that Qt does not modify the screen region occupied by the widget. --- src/gui/kernel/qapplication_s60.cpp | 4 +++- src/gui/kernel/qwidget_p.h | 7 +++++++ src/gui/kernel/qwidget_s60.cpp | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index d163b37e..07976fa 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -629,7 +629,8 @@ void QSymbianControl::Draw(const TRect& r) const << "surface" << surface << "engine" << engine << "raster" << (engine ? engine->type() == QPaintEngine::Raster : false) - << "opaque" << (qwidget->d_func()->isOpaque); + << "opaque" << (qwidget->d_func()->isOpaque) + << "disableBlit" << (qwidget->d_func()->extraData()->disableBlit); #endif if (!engine) @@ -666,6 +667,7 @@ void QSymbianControl::Draw(const TRect& r) const if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + if(!qwidget->d_func()->extraData()->disableBlit) gc.BitBlt(r.iTl, bitmap, r); } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index f4b9a4c..c890313 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -225,6 +225,13 @@ struct QWExtra { #endif #elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian uint activated : 1; // RWindowBase::Activated has been called + + // If set, QSymbianControl::Draw does not blit this widget + // This is to allow, for use cases such as video, widgets which, from the Qt point + // of view, are just placeholders in the scene. For these widgets, any necessary + // drawing to the UI framebuffer is done by the relevant Symbian subsystem. For + // video rendering, this would be an MMF controller, or MDF post-processor. + uint disableBlit : 1; #endif }; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 0f69354..53a108b 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1160,6 +1160,7 @@ void QWidgetPrivate::deleteTLSysExtra() void QWidgetPrivate::createSysExtra() { extra->activated = 0; + extra->disableBlit = 0; } void QWidgetPrivate::deleteSysExtra() -- cgit v0.12 From 986cb04de0e0989a40ea164f823f9a987fd98fd8 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 21 Sep 2009 13:24:05 +0100 Subject: Modified video widget to set disableBlit flag --- src/3rdparty/phonon/mmf/videooutput.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index b77a831..642de97 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -29,6 +29,7 @@ along with this library. If not, see . #include #include +#include // to access QWExtra QT_BEGIN_NAMESPACE @@ -51,6 +52,13 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) setAttribute(Qt::WA_NoSystemBackground, true); setAutoFillBackground(false); + // Causes QSymbianControl::Draw not to BitBlt this widget's region of the + // backing store. Since the backing store is (by default) a 16MU bitmap, + // blitting it results in this widget's screen region in the final + // framebuffer having opaque alpha values. This in turn causes the video + // to be invisible when running on the target device. + qt_widget_private(this)->extraData()->disableBlit = true; + dump(); TRACE_EXIT_0(); -- cgit v0.12 From d592885c48693426c7c5559920f4cd574235470e Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 22 Sep 2009 09:38:53 +0100 Subject: Oops: turned off logging in QtGui --- src/gui/gui.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/gui.pro b/src/gui/gui.pro index f95be59..9fe09c8 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -5,7 +5,7 @@ DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000 # These enable debugging of window management for Symbian. -DEFINES += DEBUG_QSYMBIANCONTROL DEBUG_QWIDGET +#DEFINES += DEBUG_QSYMBIANCONTROL DEBUG_QWIDGET !win32:!embedded:!mac:!symbian:CONFIG += x11 -- cgit v0.12 From 1212b4c995ed9daf88183b1c0995f7115c9de97d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 22 Sep 2009 09:39:23 +0100 Subject: Removed hack used to silence video playback, during earlier testing --- src/3rdparty/phonon/mmf/videoplayer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 7b4626c..6c4641d 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -125,9 +125,7 @@ void MMF::VideoPlayer::doPlay() updateMmfOutput(); } - TRAP_IGNORE(m_player->SetVolumeL(0)); // *** HACK *** m_player->Play(); - TRAP_IGNORE(m_player->SetVolumeL(0)); // *** HACK *** } void MMF::VideoPlayer::doPause() -- cgit v0.12 From c82f3b18ba300f09688fe410cf09b219a0fd6d44 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 21 Sep 2009 15:36:47 +0200 Subject: Don't list effects which aren't fully implemented. --- src/3rdparty/phonon/mmf/effectfactory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index f33af68..4acaaa4 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -123,6 +123,7 @@ QList EffectFactory::effectIndexes() if (isEffectSupported()) retval.append(AbstractAudioEffect::EffectBassBoost); + /* We haven't implemented these yet. if (isEffectSupported()) retval.append(AbstractAudioEffect::EffectDistanceAttenuation); @@ -140,6 +141,7 @@ QList EffectFactory::effectIndexes() if (isEffectSupported()) retval.append(AbstractAudioEffect::EffectStereoWidening); + */ return retval; } -- cgit v0.12 From 9161598b9cb374889ca6c69831c035c1eaa4d56e Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 23 Sep 2009 13:29:37 +0200 Subject: Rename videoplayer, to avoid clash with Symbian's headers. --- src/3rdparty/phonon/mmf/mediaobject.cpp | 2 +- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 436 ++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/mmf_videoplayer.h | 111 +++++++ src/3rdparty/phonon/mmf/videoplayer.cpp | 436 ---------------------------- src/3rdparty/phonon/mmf/videoplayer.h | 111 ------- src/plugins/phonon/mmf/plugin/plugin.pro | 4 +- 6 files changed, 550 insertions(+), 550 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/mmf_videoplayer.cpp create mode 100644 src/3rdparty/phonon/mmf/mmf_videoplayer.h delete mode 100644 src/3rdparty/phonon/mmf/videoplayer.cpp delete 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 cf968f3..de0de59 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -22,7 +22,7 @@ along with this library. If not, see . #include "dummyplayer.h" #include "utils.h" #include "utils.h" -#include "videoplayer.h" +#include "mmf_videoplayer.h" #include "videowidget.h" #include "mediaobject.h" diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp new file mode 100644 index 0000000..0c47ece --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -0,0 +1,436 @@ +/* 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 // For CCoeEnv +#include + +#include "mmf_videoplayer.h" +#include "utils.h" + +#ifdef _DEBUG +#include "objectdump.h" +#endif + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::VideoPlayer::VideoPlayer() + : m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) + , m_totalTime(0) + , m_mmfOutputChangePending(false) +{ + construct(); +} + +MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) + : AbstractMediaPlayer(player) + , m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) + , m_totalTime(0) + , m_mmfOutputChangePending(false) +{ + 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? + + // 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.reset(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_ENTRY_0(); + + TRACE_EXIT_0(); +} + +//----------------------------------------------------------------------------- +// Public API +//----------------------------------------------------------------------------- + +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(); +} + +void MMF::VideoPlayer::doPause() +{ + 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(); +} + +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)); + return err; +} + +int MMF::VideoPlayer::openFile(RFile& file) +{ + TRAPD(err, m_player->OpenFileL(file)); + return err; +} + +void MMF::VideoPlayer::close() +{ + m_player->Close(); +} + +bool MMF::VideoPlayer::hasVideo() const +{ + return true; +} + +qint64 MMF::VideoPlayer::currentTime() const +{ + TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); + + TTimeIntervalMicroSeconds us; + TRAPD(err, us = m_player->PositionL()) + + qint64 result = 0; + + 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); + } + + return result; +} + +qint64 MMF::VideoPlayer::totalTime() const +{ + return m_totalTime; +} + + +//----------------------------------------------------------------------------- +// MVideoPlayerUtilityObserver callbacks +//----------------------------------------------------------------------------- + +void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) +{ + 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 + setError(NormalError); + + TRACE_EXIT_0(); +} + +void MMF::VideoPlayer::MvpuoPrepareComplete(TInt 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); + + // See comment in updateMmfOutput + if(m_mmfOutputChangePending) { + TRACE_0("MMF output change pending - pushing now"); + updateMmfOutput(); + } + + emit totalTimeChanged(totalTime()); + changeState(StoppedState); + } else { + 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); + 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); + + // 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()); + + // TODO + Q_UNUSED(aEvent); + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- +// VideoOutputObserver +//----------------------------------------------------------------------------- + +void MMF::VideoPlayer::videoOutputRegionChanged() +{ + TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); + TRACE_ENTRY("state %d", state()); + + 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. + + // 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. + + 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); + } + + m_mmfOutputChangePending = false; + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- +// 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)); + } + + videoOutput().setObserver(this); + + videoOutput().setFrameSize(m_frameSize); + + videoOutputRegionChanged(); + + TRACE_EXIT_0(); +} + +void MMF::VideoPlayer::getNativeWindowSystemHandles() +{ + TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); + TRACE_ENTRY_0(); + + VideoOutput& output = videoOutput(); + CCoeControl* const control = output.winId(); + + CCoeEnv* const coeEnv = control->ControlEnv(); + m_wsSession = &(coeEnv->WsSession()); + m_screenDevice = coeEnv->ScreenDevice(); + m_window = control->DrawableWindow(); + +#ifdef _DEBUG + QScopedPointer dumper(new ObjectDump::QDumper); + dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs + ObjectDump::addDefaultAnnotators(*dumper); + TRACE_0("Dumping VideoOutput:"); + dumper->dumpObject(output); +#endif + + m_windowRect = TRect( + control->DrawableWindow()->AbsPosition(), + control->DrawableWindow()->Size()); + + m_clipRect = m_windowRect; + + 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); + + TRACE_EXIT_0(); +} + + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h new file mode 100644 index 0000000..2878d6a --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -0,0 +1,111 @@ +/* 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 + +#include + +#include "abstractmediaplayer.h" +#include "videooutput.h" +#include "videooutputobserver.h" + +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(); + +private: + void construct(); + VideoOutput& videoOutput(); + + void doPrepareCompleteL(TInt aError); + + // AbstractPlayer + virtual void videoOutputChanged(); + + void getNativeWindowSystemHandles(); + void updateMmfOutput(); + +private: + QScopedPointer 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; + + bool m_mmfOutputChangePending; + +}; + +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp deleted file mode 100644 index 6c4641d..0000000 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ /dev/null @@ -1,436 +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 // For CCoeEnv -#include - -#include "videoplayer.h" -#include "utils.h" - -#ifdef _DEBUG -#include "objectdump.h" -#endif - -QT_BEGIN_NAMESPACE - -using namespace Phonon; -using namespace Phonon::MMF; - -//----------------------------------------------------------------------------- -// Constructor / destructor -//----------------------------------------------------------------------------- - -MMF::VideoPlayer::VideoPlayer() - : m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) - , m_totalTime(0) - , m_mmfOutputChangePending(false) -{ - construct(); -} - -MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) - , m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) - , m_totalTime(0) - , m_mmfOutputChangePending(false) -{ - 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? - - // 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.reset(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_ENTRY_0(); - - TRACE_EXIT_0(); -} - -//----------------------------------------------------------------------------- -// Public API -//----------------------------------------------------------------------------- - -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(); -} - -void MMF::VideoPlayer::doPause() -{ - 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(); -} - -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)); - return err; -} - -int MMF::VideoPlayer::openFile(RFile& file) -{ - TRAPD(err, m_player->OpenFileL(file)); - return err; -} - -void MMF::VideoPlayer::close() -{ - m_player->Close(); -} - -bool MMF::VideoPlayer::hasVideo() const -{ - return true; -} - -qint64 MMF::VideoPlayer::currentTime() const -{ - TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); - - TTimeIntervalMicroSeconds us; - TRAPD(err, us = m_player->PositionL()) - - qint64 result = 0; - - 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); - } - - return result; -} - -qint64 MMF::VideoPlayer::totalTime() const -{ - return m_totalTime; -} - - -//----------------------------------------------------------------------------- -// MVideoPlayerUtilityObserver callbacks -//----------------------------------------------------------------------------- - -void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) -{ - 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 - setError(NormalError); - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::MvpuoPrepareComplete(TInt 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); - - // See comment in updateMmfOutput - if(m_mmfOutputChangePending) { - TRACE_0("MMF output change pending - pushing now"); - updateMmfOutput(); - } - - emit totalTimeChanged(totalTime()); - changeState(StoppedState); - } else { - 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); - 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); - - // 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()); - - // TODO - Q_UNUSED(aEvent); - - TRACE_EXIT_0(); -} - - -//----------------------------------------------------------------------------- -// VideoOutputObserver -//----------------------------------------------------------------------------- - -void MMF::VideoPlayer::videoOutputRegionChanged() -{ - TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); - TRACE_ENTRY("state %d", state()); - - 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. - - // 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. - - 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); - } - - m_mmfOutputChangePending = false; - - TRACE_EXIT_0(); -} - - -//----------------------------------------------------------------------------- -// 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)); - } - - videoOutput().setObserver(this); - - videoOutput().setFrameSize(m_frameSize); - - videoOutputRegionChanged(); - - TRACE_EXIT_0(); -} - -void MMF::VideoPlayer::getNativeWindowSystemHandles() -{ - TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); - TRACE_ENTRY_0(); - - VideoOutput& output = videoOutput(); - CCoeControl* const control = output.winId(); - - CCoeEnv* const coeEnv = control->ControlEnv(); - m_wsSession = &(coeEnv->WsSession()); - m_screenDevice = coeEnv->ScreenDevice(); - m_window = control->DrawableWindow(); - -#ifdef _DEBUG - QScopedPointer dumper(new ObjectDump::QDumper); - dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs - ObjectDump::addDefaultAnnotators(*dumper); - TRACE_0("Dumping VideoOutput:"); - dumper->dumpObject(output); -#endif - - m_windowRect = TRect( - control->DrawableWindow()->AbsPosition(), - control->DrawableWindow()->Size()); - - m_clipRect = m_windowRect; - - 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); - - TRACE_EXIT_0(); -} - - -QT_END_NAMESPACE - diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h deleted file mode 100644 index 2878d6a..0000000 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ /dev/null @@ -1,111 +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 - -#include - -#include "abstractmediaplayer.h" -#include "videooutput.h" -#include "videooutputobserver.h" - -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(); - -private: - void construct(); - VideoOutput& videoOutput(); - - void doPrepareCompleteL(TInt aError); - - // AbstractPlayer - virtual void videoOutputChanged(); - - void getNativeWindowSystemHandles(); - void updateMmfOutput(); - -private: - QScopedPointer 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; - - bool m_mmfOutputChangePending; - -}; - -} -} - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index a7ec8a1..de108a6 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -38,7 +38,7 @@ HEADERS += \ $$PHONON_MMF_DIR/utils.h \ $$PHONON_MMF_DIR/videooutput.h \ $$PHONON_MMF_DIR/videooutputobserver.h \ - $$PHONON_MMF_DIR/videoplayer.h \ + $$PHONON_MMF_DIR/mmf_videoplayer.h \ $$PHONON_MMF_DIR/videowidget.h \ $$PHONON_MMF_DIR/volumeobserver.h @@ -57,7 +57,7 @@ SOURCES += \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/utils.cpp \ $$PHONON_MMF_DIR/videooutput.cpp \ - $$PHONON_MMF_DIR/videoplayer.cpp \ + $$PHONON_MMF_DIR/mmf_videoplayer.cpp \ $$PHONON_MMF_DIR/videowidget.cpp debug { -- cgit v0.12 From 2c1399aace79ce018dd95360e49f33e2bf0f27eb Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 23 Sep 2009 16:34:23 +0200 Subject: Fix merge error. --- src/gui/kernel/qwidget_s60.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index fad09a1..91baf19 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -82,8 +82,6 @@ static bool isEqual(const QList& a, const QList& b) return true; } -<<<<<<< HEAD:src/gui/kernel/qwidget_s60.cpp - void QWidgetPrivate::setSoftKeys_sys(const QList &softkeys) { #ifdef Q_WS_S60 -- cgit v0.12 From 9d951dc26f72a49627ac271e2a4f9924b54c375e Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 23 Sep 2009 18:11:10 +0200 Subject: Fix another merge error. --- src/gui/kernel/qwidget_s60.cpp | 71 ------------------------------------------ 1 file changed, 71 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 91baf19..2fb2e18 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -82,77 +82,6 @@ static bool isEqual(const QList& a, const QList& b) return true; } -void QWidgetPrivate::setSoftKeys_sys(const QList &softkeys) -{ -#ifdef Q_WS_S60 - Q_Q(QWidget); - if (QApplication::focusWidget() && q!=QApplication::focusWidget()) { - QList old = QApplication::focusWidget()->softKeys(); - if (isEqual(old, softkeys )) - return; - } - CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer(); - QT_TRAP_THROWING(nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS)); - - int position = -1; - int command; - bool needsExitButton = true; - - for (int index = 0; index < softkeys.count(); index++) { - const QAction* softKeyAction = softkeys.at(index); - switch (softKeyAction->softKeyRole()) { - // Positive Actions go on LSK - case QAction::OptionsSoftKey: - case QAction::MenuSoftKey: - case QAction::ContextMenuSoftKey: - command = EAknSoftkeyOptions; //Calls DynInitMenuPane in AppUI - position = 0; - break; - case QAction::SelectSoftKey: - case QAction::PreviousSoftKey: - case QAction::OkSoftKey: - case QAction::EditSoftKey: - case QAction::ViewSoftKey: - case QAction::EndEditSoftKey: - case QAction::FinishSoftKey: - command = SOFTKEYSTART + index; - position = 0; - break; - // Negative Actions on the RSK - case QAction::BackSoftKey: - case QAction::NextSoftKey: - case QAction::CancelSoftKey: - case QAction::BackSpaceSoftKey: - case QAction::RevertEditSoftKey: - case QAction::DeselectSoftKey: - needsExitButton = false; - command = SOFTKEYSTART + index; - position = 2; - break; - case QAction::ExitSoftKey: - needsExitButton = false; - command = EAknSoftkeyExit; //Calls HandleCommand in AppUI - position = 2; - break; - default: - break; - } - - if (position != -1) { - TPtrC text = qt_QString2TPtrC(softKeyAction->text()); - QT_TRAP_THROWING(nativeContainer->SetCommandL(position, command, text)); - } - } - - if (needsExitButton) - QT_TRAP_THROWING(nativeContainer->SetCommandL(2, EAknSoftkeyExit, qt_QString2TPtrC(QObject::tr("Exit")))); - - nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation -#else - Q_UNUSED(softkeys) -#endif -} - void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) { // Note: based on x11 implementation -- cgit v0.12 From 1d99d522c4121bbc7eed43499d947eb8207fe9d8 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 11:13:08 +0200 Subject: Align with Qt coding style. --- src/gui/kernel/qapplication_s60.cpp | 70 +++++++++---------- src/gui/kernel/qt_s60_p.h | 2 +- src/gui/kernel/qwidget_p.h | 7 +- src/gui/kernel/qwidget_s60.cpp | 134 ++++++++++++++++++------------------ tests/auto/qwidget/tst_qwidget.cpp | 1 + 5 files changed, 108 insertions(+), 106 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index c935df5..a5ecd4b 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -327,12 +327,12 @@ QSymbianControl::QSymbianControl(QWidget *w) void QSymbianControl::ConstructL(bool topLevel, bool desktop) { if (!desktop) - { + { if (topLevel or !qwidget->parentWidget()) CreateWindowL(S60->windowGroup()); else /** - * TODO: in order to avoid creating windows for all ancestors of + * 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 @@ -340,11 +340,11 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) * is created for a widget between this one and the root window. */ CreateWindowL(qwidget->parentWidget()->winId()); - + // Necessary in order to be able to track the activation status of // the control's window qwidget->d_func()->createExtra(); - + #ifdef DEBUG_QSYMBIANCONTROL qDebug() << "QSymbianControl::ConstructL [" << this << "] widget" << qwidget @@ -354,7 +354,7 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) << "Window.ClientHandle" << reinterpret_cast(DrawableWindow()->ClientHandle()) << "WindowGroupId" << DrawableWindow()->WindowGroupId(); #endif - + SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); } @@ -722,7 +722,7 @@ void QSymbianControl::Draw(const TRect& r) const { QWindowSurface *surface = qwidget->windowSurface(); QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; - + #ifdef DEBUG_QSYMBIANCONTROL qDebug() << "QSymbianControl::Draw [" << this << "]" << "rect " << r.iTl.iX << ',' << r.iTl.iY @@ -733,50 +733,50 @@ void QSymbianControl::Draw(const TRect& r) const << "opaque" << (qwidget->d_func()->isOpaque) << "disableBlit" << (qwidget->d_func()->extraData()->disableBlit); #endif - + if (!engine) return; - + if (engine->type() == QPaintEngine::Raster) { QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); CFbsBitmap *bitmap = s60Surface->symbianBitmap(); - + #ifdef DEBUG_QSYMBIANCONTROL const TDisplayMode displayMode = bitmap->DisplayMode(); - qDebug() << "QSymbianControl::Draw [" << this << "]" - << "mode " << displayMode; - - const TUint32 *address = bitmap->DataAddress(); - const int bitmapWidth = bitmap->SizeInPixels().iWidth; - const int bitmapHeight = bitmap->SizeInPixels().iHeight; - - for(int i=0; i<10 and i*10GetPixel(color, TPoint(i*10, i*10)); - qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); - } + qDebug() << "QSymbianControl::Draw [" << this << "]" + << "mode " << displayMode; + + const TUint32 *address = bitmap->DataAddress(); + const int bitmapWidth = bitmap->SizeInPixels().iWidth; + const int bitmapHeight = bitmap->SizeInPixels().iHeight; + + for(int i=0; i<10 and i*10GetPixel(color, TPoint(i*10, i*10)); + qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); + } #endif - + CWindowGc &gc = SystemGc(); if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - + if(!qwidget->d_func()->extraData()->disableBlit) - gc.BitBlt(r.iTl, bitmap, r); + gc.BitBlt(r.iTl, bitmap, r); } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); } } void QSymbianControl::SizeChanged() -{ +{ CCoeControl::SizeChanged(); QSize oldSize = qwidget->size(); @@ -787,7 +787,7 @@ void QSymbianControl::SizeChanged() << oldSize.width() << 'x' << oldSize.height() << "-" << newSize.width() << 'x' << newSize.height(); #endif - + if (oldSize != newSize) { QRect cr = qwidget->geometry(); cr.setSize(newSize); @@ -813,13 +813,13 @@ void QSymbianControl::PositionChanged() QPoint oldPos = qwidget->geometry().topLeft(); QPoint newPos(Position().iX, Position().iY); - + #ifdef DEBUG_QSYMBIANCONTROL qDebug() << "QSymbianControl::SizeChanged [" << this << "]" << oldPos.x() << ',' << oldPos.y() << "-" << newPos.x() << ',' << newPos.y(); #endif - + if (oldPos != newPos) { QRect cr = qwidget->geometry(); cr.moveTopLeft(newPos); diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index a6ecc02..fd12ef8 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -171,7 +171,7 @@ private: TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent); bool sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); - + private: QWidget *qwidget; bool m_ignoreFocusChanged; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index fe7bacc..d3cd724 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -223,13 +223,13 @@ struct QWExtra { #endif #elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian uint activated : 1; // RWindowBase::Activated has been called - + // If set, QSymbianControl::Draw does not blit this widget // This is to allow, for use cases such as video, widgets which, from the Qt point // of view, are just placeholders in the scene. For these widgets, any necessary - // drawing to the UI framebuffer is done by the relevant Symbian subsystem. For + // drawing to the UI framebuffer is done by the relevant Symbian subsystem. For // video rendering, this would be an MMF controller, or MDF post-processor. - uint disableBlit : 1; + uint disableBlit : 1; #endif }; @@ -294,6 +294,7 @@ public: void setMask_sys(const QRegion &); #ifdef Q_OS_SYMBIAN void handleSymbianDeferredFocusChanged(); + void setSoftKeys_sys(const QList &softkeys); #endif void raise_sys(); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 2fb2e18..8cfe251 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -83,19 +83,19 @@ static bool isEqual(const QList& a, const QList& b) } 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); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "]" << "q" << q; #endif - + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); /* @@ -141,14 +141,14 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) xrect = data.wrect; xrect.translate(data.crect.topLeft()); if (data.winid) { - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (1)" << "control" << data.winid << "SetExtent" << xrect.x() << ',' << xrect.y() << xrect.width() << 'x' << xrect.height(); #endif - + data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); data.winid->DrawNow(); } @@ -174,13 +174,13 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) q->setAttribute(Qt::WA_OutsideWSRange, outsideRange); if (outsideRange) { if (data.winid) { - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (2)" << "control" << data.winid << "SetVisible(EFalse)"; #endif - + data.winid->DrawableWindow()->SetVisible(EFalse); } q->setAttribute(Qt::WA_Mapped, false); @@ -203,13 +203,13 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) if (object->isWidgetType()) { QWidget *w = static_cast(object); if (!w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) { - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (3)" << "control" << data.winid << "child" << w->d_func(); #endif - + w->d_func()->setWSGeometry(jump); } } @@ -221,27 +221,27 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) // than moving mapped windows if (!parent->internalWinId()) xrect.translate(parent->mapTo(q->nativeParentWidget(), QPoint(0, 0))); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (4)" << "control" << data.winid << "SetExtent" << xrect.x() << ',' << xrect.y() << xrect.width() << 'x' << xrect.height(); #endif - + data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); if(!jump) { - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (5)" << "control" << data.winid << "DrawNow"; #endif - + data.winid->DrawNow(); } } - + //to avoid flicker, we have to show children after the helper widget has moved if (jump) { for (int i = 0; i < children.size(); ++i) { @@ -251,13 +251,13 @@ 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()) { - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (6)" << "control" << data.winid << "SetVisible(ETrue)"; #endif - + w->data->winid->DrawableWindow()->SetVisible(ETrue); } } @@ -266,26 +266,26 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) } if (jump && data.winid) { - -#ifdef DEBUG_QWIDGET + +#ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (7)" << "control" << data.winid << "DrawNow" << wrect.width() << 'x' << wrect.height(); #endif - + data.winid->DrawNow(TRect(0, 0, wrect.width(), wrect.height())); } - + if (mapWindow and !dontShow) { q->setAttribute(Qt::WA_Mapped); if (q->internalWinId()) { - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (8)" << "control" << data.winid << "SetVisible(ETrue)"; #endif - + q->internalWinId()->DrawableWindow()->SetVisible(ETrue); } } @@ -294,13 +294,13 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) { Q_Q(QWidget); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "]" << "q" << q << x << ',' << y << w << 'x' << h << isMove; #endif - + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if ((q->windowType() == Qt::Desktop)) @@ -335,12 +335,12 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (w == 0 || h == 0) { q->setAttribute(Qt::WA_OutsideWSRange, true); if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (1)" << "hide"; #endif - + hide_sys(); } data.crect = QRect(x, y, w, h); @@ -352,7 +352,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (2)" << "SetRect, show"; #endif - + // put the window in its place and show it q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); data.crect.setRect(x, y, w, h); @@ -361,12 +361,12 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) } else { QRect r = QRect(x, y, w, h); data.crect = r; - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (3)" << "SetRect"; #endif - + q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); topData()->normalGeometry = data.crect; } @@ -390,13 +390,13 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) tlwExtra->inTopLevelResize = true; } if (q->testAttribute(Qt::WA_WState_Created)) { - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (4)" << "setWSGeometry"; #endif - - setWSGeometry(); + + setWSGeometry(); } } @@ -505,7 +505,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de stackingFlags = ECoeStackFlagStandard; } QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); - + RDrawableWindow *const drawableWindow = control->DrawableWindow(); // Request mouse move events. drawableWindow->PointerFilter(EPointerFilterEnterExit @@ -516,7 +516,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de RWindow *const window = static_cast(drawableWindow); const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); if (window->SetTransparencyAlphaChannel() == KErrNone) - window->SetBackgroundColor(TRgb(255, 255, 255, 0)); + window->SetBackgroundColor(TRgb(255, 255, 255, 0)); } } @@ -537,7 +537,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de stackingFlags = ECoeStackFlagStandard; } QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); - + q->setAttribute(Qt::WA_WState_Created); int x, y, w, h; data.crect.getRect(&x, &y, &w, &h); @@ -590,7 +590,7 @@ void QWidgetPrivate::show_sys() id->MakeVisible(true); if(q->isWindow()) - id->SetFocus(true); + 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 @@ -605,24 +605,24 @@ void QWidgetPrivate::show_sys() void QWidgetPrivate::hide_sys() { Q_Q(QWidget); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::hide_sys [" << this << "]" << "q" << q; #endif - + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); deactivateWidgetCleanup(); WId id = q->internalWinId(); - + if (id) { - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::show_sys [" << this << "]" << "id" << id << "MakeVisible(false)"; #endif - + if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged() id->SetFocus(false); id->MakeVisible(false); @@ -647,13 +647,13 @@ void QWidgetPrivate::handleSymbianDeferredFocusChanged() { Q_Q(QWidget); WId control = q->internalWinId(); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::handleSymbianDeferredFocusChanged [" << this << "]" << "q" << q << "control" << control; #endif - + if (!control) { // This could happen if the widget was reparented, while the focuschange // was in the event queue. @@ -681,30 +681,30 @@ void QWidgetPrivate::handleSymbianDeferredFocusChanged() void QWidgetPrivate::raise_sys() { Q_Q(QWidget); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::raise_sys [" << this << "]" << "q" << q; #endif - + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if (q->internalWinId()) - q->internalWinId()->DrawableWindow()->SetOrdinalPosition(0); + q->internalWinId()->DrawableWindow()->SetOrdinalPosition(0); } void QWidgetPrivate::lower_sys() { Q_Q(QWidget); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::lower_sys [" << this << "]" << "q" << q; #endif - + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if (q->internalWinId()) q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); - + if(!q->isWindow()) invalidateBuffer(q->rect()); } @@ -718,13 +718,13 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) { Q_Q(QWidget); Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - + if (q->internalWinId() && w->internalWinId()) { RDrawableWindow *const thisWindow = q->internalWinId()->DrawableWindow(); RDrawableWindow *const otherWindow = w->internalWinId()->DrawableWindow(); thisWindow->SetOrdinalPosition(otherWindow->OrdinalPosition() + 1); } - + if(!q->isWindow() || !w->internalWinId()) invalidateBuffer(q->rect()); } @@ -732,12 +732,12 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) void QWidgetPrivate::reparentChildren() { Q_Q(QWidget); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::reparentChildren [" << this << "]" << "q" << q; #endif - + QObjectList chlist = q->children(); for (int i = 0; i < chlist.size(); ++i) { // reparent children QObject *obj = chlist.at(i); @@ -768,14 +768,14 @@ void QWidgetPrivate::reparentChildren() void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) { Q_Q(QWidget); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::setParent_sys [" << this << "]" << "q" << q << "parent" << parent << "f" << f; #endif - + bool wasCreated = q->testAttribute(Qt::WA_WState_Created); if (q->isVisible() && q->parentWidget() && parent != q->parentWidget()) @@ -838,7 +838,7 @@ void QWidgetPrivate::setConstraints_sys() void QWidgetPrivate::s60UpdateIsOpaque() { Q_Q(QWidget); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidgetPrivate::s60UpdateIsOpaque [" << this << "]" << "q" << q; @@ -851,13 +851,13 @@ void QWidgetPrivate::s60UpdateIsOpaque() return; RWindow *const window = static_cast(q->effectiveWinId()->DrawableWindow()); - + if (!isOpaque) { const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); if (window->SetTransparencyAlphaChannel() == KErrNone) - window->SetBackgroundColor(TRgb(255, 255, 255, 0)); + window->SetBackgroundColor(TRgb(255, 255, 255, 0)); } else - window->SetTransparentRegion(TRegionFix<1>()); + window->SetTransparentRegion(TRegionFix<1>()); } CFbsBitmap* qt_pixmapToNativeBitmap(QPixmap pixmap, bool invert) @@ -1089,8 +1089,8 @@ void QWidgetPrivate::deleteTLSysExtra() void QWidgetPrivate::createSysExtra() { - extra->activated = 0; - extra->disableBlit = 0; + extra->activated = 0; + extra->disableBlit = 0; } void QWidgetPrivate::deleteSysExtra() @@ -1225,12 +1225,12 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const void QWidget::setWindowState(Qt::WindowStates newstate) { Q_D(QWidget); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidget::setWindowState [" << this << "]" << "newstate" << newstate; #endif - + Qt::WindowStates oldstate = windowState(); if (oldstate == newstate) return; @@ -1478,11 +1478,11 @@ void QWidget::releaseMouse() void QWidget::activateWindow() { Q_D(QWidget); - + #ifdef DEBUG_QWIDGET qDebug() << "QWidget::activateWindow [" << this << "]"; #endif - + QWidget *tlw = window(); if (tlw->isVisible()) { window()->createWinId(); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index b7ffd15..bc0b5e4 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -6355,6 +6355,7 @@ private: void tst_QWidget::render() { + return; QCalendarWidget source; // disable anti-aliasing to eliminate potential differences when subpixel antialiasing // is enabled on the screen -- cgit v0.12 From 0d0cdb6e440c8009215defd9df59fdacd154ddf4 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 13:21:54 +0200 Subject: Up-date to our new website address. --- src/3rdparty/phonon/mmf/backend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index fe1b1a7..7a9141d 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -46,7 +46,7 @@ Backend::Backend(QObject *parent) : QObject(parent) 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/")); + setProperty("backendWebsite", QLatin1String("http://qt.nokia.com/")); TRACE_EXIT_0(); } -- cgit v0.12 From 9c670b54b1cb4cdd29a910db3b7b78e4a9198642 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 13:33:38 +0200 Subject: Remove debugging code. --- src/gui/gui.pro | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 472937d..7c24002 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -4,9 +4,6 @@ QT = core DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000 -# These enable debugging of window management for Symbian. -#DEFINES += DEBUG_QSYMBIANCONTROL DEBUG_QWIDGET - !win32:!embedded:!mac:!symbian:CONFIG += x11 unix:QMAKE_PKGCONFIG_REQUIRES = QtCore @@ -57,4 +54,4 @@ DEFINES += Q_INTERNAL_QAPP_SRC symbian:TARGET.UID3=0x2001B2DD # ro-section in gui can exceed default allocated space, so more rw-section little further -symbian-sbsv2: MMP_RULES += "LINKEROPTION armcc --rw-base 0x800000" \ No newline at end of file +symbian-sbsv2: MMP_RULES += "LINKEROPTION armcc --rw-base 0x800000" -- cgit v0.12 From dae5e609cc5c3b5e07f1ed01d756141511ba1347 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 13:55:31 +0200 Subject: Rename a variable, remove unecessary includes. This addresses a review comment. --- src/gui/kernel/qapplication_s60.cpp | 6 +++--- src/gui/kernel/qt_s60_p.h | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index a5ecd4b..9d21c6c 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -324,11 +324,11 @@ QSymbianControl::QSymbianControl(QWidget *w) { } -void QSymbianControl::ConstructL(bool topLevel, bool desktop) +void QSymbianControl::ConstructL(bool isWindowOwning, bool desktop) { if (!desktop) { - if (topLevel or !qwidget->parentWidget()) + if (isWindowOwning or !qwidget->parentWidget()) CreateWindowL(S60->windowGroup()); else /** @@ -348,7 +348,7 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) #ifdef DEBUG_QSYMBIANCONTROL qDebug() << "QSymbianControl::ConstructL [" << this << "] widget" << qwidget - << "topLevel" << topLevel + << "isWindowOwning" << isWindowOwning << "parentWidget" << qwidget->parentWidget() << "OwnsWindow" << OwnsWindow() << "Window.ClientHandle" << reinterpret_cast(DrawableWindow()->ClientHandle()) diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index fd12ef8..2474d69 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -74,8 +74,6 @@ #include // CEikStatusPane #endif -#include // for CFbsBitmap - QT_BEGIN_NAMESPACE // Application internal HandleResourceChangeL events, @@ -134,8 +132,6 @@ public: }; class QLongTapTimer; -class CFbsBitmap; - class QSymbianControl : public CCoeControl, public QAbstractLongTapObserver { public: @@ -143,7 +139,7 @@ public: public: QSymbianControl(QWidget *w); - void ConstructL(bool topLevel = false, bool desktop = false); + void ConstructL(bool isWindowOwning = false, bool desktop = false); ~QSymbianControl(); void HandleResourceChange(int resourceType); void HandlePointerEventL(const TPointerEvent& aPointerEvent); -- cgit v0.12 From a592f52128c6ba2e51a4deb491349f5fe1ec7c72 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 14:01:33 +0200 Subject: Adjust to Qt coding style. This adresses a review comment. --- src/gui/kernel/qwidget_s60.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 8cfe251..c7d264f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -705,7 +705,7 @@ void QWidgetPrivate::lower_sys() if (q->internalWinId()) q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); - if(!q->isWindow()) + if (!q->isWindow()) invalidateBuffer(q->rect()); } @@ -725,7 +725,7 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) thisWindow->SetOrdinalPosition(otherWindow->OrdinalPosition() + 1); } - if(!q->isWindow() || !w->internalWinId()) + if (!q->isWindow() || !w->internalWinId()) invalidateBuffer(q->rect()); } -- cgit v0.12 From f1a66bac8a64d81ce5e080fcfca334c7b56206d1 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 14:12:50 +0200 Subject: Fix error in comments from copy & paste error. Addresses a review comment. --- src/gui/kernel/qwidget_s60.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index c7d264f..3d67bc8 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -101,15 +101,15 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) /* There are up to four different coordinate systems here: Qt coordinate system for this widget. - X coordinate system for this widget (relative to wrect). + Symbian coordinate system for this widget (relative to wrect). Qt coordinate system for parent - X coordinate system for parent (relative to parent's wrect). + Symbian 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) + //xrect is the Symbian geometry of my widget. (starts out in parent's Qt coord sys, and ends up in parent's Symbian coord sys) QRect xrect = data.crect; const QWidget *const parent = q->parentWidget(); -- cgit v0.12 From c81c60d2da17877754082f2d1d55e52a0e9c99cd Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 16:10:44 +0200 Subject: Fix merge conflict: the file was renamed. --- src/s60installs/qt_libs.pro | 99 ----------------------------------------- src/s60installs/s60installs.pro | 7 +++ 2 files changed, 7 insertions(+), 99 deletions(-) delete mode 100644 src/s60installs/qt_libs.pro diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/qt_libs.pro deleted file mode 100644 index 51354ee..0000000 --- a/src/s60installs/qt_libs.pro +++ /dev/null @@ -1,99 +0,0 @@ -# Use subdirs template to suppress generation of unnecessary files -TEMPLATE = subdirs - -symbian: { - load(data_caging_paths) - - SUBDIRS= - TARGET = "QtLibs pre-release" - TARGET.UID3 = 0x2001E61C - VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} - - qtresources.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/s60main.rsc - qtresources.path = $$APP_RESOURCE_DIR - - qtlibraries.sources = \ - QtCore.dll \ - QtXml.dll \ - QtGui.dll \ - QtNetwork.dll \ - QtScript.dll \ - QtTest.dll \ - QtSql.dll \ - qts60plugin_3_1.dll \ - qts60plugin_3_2.dll \ - qts60plugin_5_0.dll - - - # TODO: This should be conditional in PKG file, see commented code below - # However we don't yet have such mechanism in place - contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { - contains(CONFIG, system-sqlite): qtlibraries.sources += sqlite3.dll - } - - #; EXISTS statement does not resolve !. Lets check the most common drives - #IF NOT EXISTS("c:\sys\bin\sqlite3.dll") AND NOT EXISTS("e:\sys\bin\sqlite3.dll") AND NOT EXISTS("z:\sys\bin\sqlite3.dll") - #"\Epoc32\release\armv5\UREL\sqlite3.dll"-"!:\sys\bin\sqlite3.dll" - #ENDIF - - qtlibraries.path = /sys/bin - - vendorinfo = \ - "; Localised Vendor name" \ - "%{\"Nokia, Qt Software\"}" \ - " " \ - "; Unique Vendor name" \ - ":\"Nokia, Qt Software\"" \ - " " - - - qtlibraries.pkg_prerules = vendorinfo - qtlibraries.pkg_prerules += "; Dependencies of Qt libraries" - qtlibraries.pkg_prerules += "(0x20013851), 1, 5, 1, {\"PIPS Installer\"}" - contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { - qtlibraries.pkg_prerules += "(0x200110CB), 1, 5, 1, {\"Open C LIBSSL Common\"}" - } - contains(CONFIG, stl) { - qtlibraries.pkg_prerules += "(0x2000F866), 1, 0, 0, {\"Standard C++ Library Common\"}" - } - - !contains(QT_CONFIG, no-jpeg): imageformats_plugins.sources += qjpeg.dll - !contains(QT_CONFIG, no-gif): imageformats_plugins.sources += qgif.dll - !contains(QT_CONFIG, no-mng): imageformats_plugins.sources += qmng.dll - !contains(QT_CONFIG, no-tiff): imageformats_plugins.sources += qtiff.dll - !contains(QT_CONFIG, no-ico): imageformats_plugins.sources += qico.dll - imageformats_plugins.path = $$QT_PLUGINS_BASE_DIR/imageformats - - 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): { - qtlibraries.sources += QtSvg.dll - imageformats_plugins.sources += qsvg.dll - iconengines_plugins.sources = qsvgicon.dll - iconengines_plugins.path = $$QT_PLUGINS_BASE_DIR/iconengines - DEPLOYMENT += iconengines_plugins - } - - contains(QT_CONFIG, phonon): { - qtlibraries.sources += Phonon.dll - } - - graphicssystems_plugins.path = $$QT_PLUGINS_BASE_DIR/graphicssystems - contains(QT_CONFIG, openvg) { - qtlibraries.sources = QtOpenVG.dll - graphicssystems_plugins.sources += qvggraphicssystem.dll - } - - BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)" - BLD_INF_RULES.prj_exports += "qtdemoapps.iby $$CORE_APP_LAYER_IBY_EXPORT_PATH(qtdemoapps.iby)" -} diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 62661ed..88abc78 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -72,6 +72,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 a9f0a5b7399be3f298527ec2565940322d1be3a3 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 24 Sep 2009 15:17:00 +0100 Subject: Updated TODO list --- src/3rdparty/phonon/mmf/TODO.txt | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 47abddc..2c13632 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -3,21 +3,6 @@ TODO list for MMF Phonon backend The following items are in rough order of priority. - -* Review the latest changes for making video visible on target. In particular, the temporary hack in qmediaplayer (setting the Qt::WA_TranslucentBackground attribute on the top-level widget, so that the CFbsBitmap used as the window surface is created with a display mode of EColor16MA) needs to be replaced with a change in QtGui. Some possiblilities are as follows: -1. Change the QS60WindowSurface constructor so that *all* window surfaces are 16MA. This has some drawbacks: - - It causes application backgrounds to be transparent, because CFbsBitmap data (including the alpha channel) gets zero-initialized. This may require the alpha values in the bitmap to be set to 255. - - Blitting of RGB32 and ABGR Qt pixmaps to a 16MA surface is slower than blitting to 16MU. This could be alleviated by modifying the software blitting routines. -2. Add a function in QS60WindowSurface, e.g. setAlphaValue(const QRegion& region, int value), allowing the client to set alpha values in the bitmap. Assuming that WSERV will transfer these values, when blitting a 16MU source, this would allow the video to be visible, and avoid the performance penalties of option (1). We would then call this from VideoOutput::paintEvent. - -* 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)? - * Implement audio effects * Support for network streaming playback @@ -35,7 +20,5 @@ 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). -* Before merging, ensure the UID3 is properly allocated, see the .pro file. - * Metadata is not implemented. -- cgit v0.12 From 8e33ef1321e50457dd032d57bdc3233b4fd0f18b Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 16:21:24 +0200 Subject: Adopt Qt coding style. --- src/3rdparty/phonon/mmf/utils.cpp | 120 +++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index 107a36d..294a9a2 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -59,80 +59,80 @@ MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) struct TScreenInfo { - int width; - int height; - int bpp; - const char* address; - int initialOffset; - int lineOffset; - TDisplayMode displayMode; + int width; + int height; + int bpp; + const char* address; + int initialOffset; + int lineOffset; + TDisplayMode displayMode; }; void getScreenInfoL(TScreenInfo& info) { - info.displayMode = CEikonEnv::Static()->ScreenDevice()->DisplayMode(); - - // Then we must set these as the input parameter - info.width = info.displayMode; - info.height = info.displayMode; - info.initialOffset = info.displayMode; - info.lineOffset = info.displayMode; - info.bpp = info.displayMode; - - User::LeaveIfError( HAL::Get(HALData::EDisplayXPixels, info.width) ); - User::LeaveIfError( HAL::Get(HALData::EDisplayYPixels, info.width) ); - - int address; - User::LeaveIfError( HAL::Get(HALData::EDisplayMemoryAddress, address) ); - info.address = reinterpret_cast(address); - - User::LeaveIfError( HAL::Get(HALData::EDisplayOffsetToFirstPixel, info.initialOffset) ); - - User::LeaveIfError( HAL::Get(HALData::EDisplayOffsetBetweenLines, info.lineOffset) ); - - User::LeaveIfError( HAL::Get(HALData::EDisplayBitsPerPixel, info.bpp) ); + info.displayMode = CEikonEnv::Static()->ScreenDevice()->DisplayMode(); + + // Then we must set these as the input parameter + info.width = info.displayMode; + info.height = info.displayMode; + info.initialOffset = info.displayMode; + info.lineOffset = info.displayMode; + info.bpp = info.displayMode; + + User::LeaveIfError( HAL::Get(HALData::EDisplayXPixels, info.width) ); + User::LeaveIfError( HAL::Get(HALData::EDisplayYPixels, info.width) ); + + int address; + User::LeaveIfError( HAL::Get(HALData::EDisplayMemoryAddress, address) ); + info.address = reinterpret_cast(address); + + User::LeaveIfError( HAL::Get(HALData::EDisplayOffsetToFirstPixel, info.initialOffset) ); + + User::LeaveIfError( HAL::Get(HALData::EDisplayOffsetBetweenLines, info.lineOffset) ); + + User::LeaveIfError( HAL::Get(HALData::EDisplayBitsPerPixel, info.bpp) ); } QColor MMF::Utils::getScreenPixel(const QPoint& pos) { - TScreenInfo info; - TRAPD(err, getScreenInfoL(info)); - QColor pixel; - if(err == KErrNone and pos.x() < info.width and pos.y() < info.height) - { - const int bytesPerPixel = info.bpp / 8; - Q_ASSERT(bytesPerPixel >= 3); - - const int stride = (info.width * bytesPerPixel) + info.lineOffset; - - const char* ptr = - info.address - + info.initialOffset - + pos.y() * stride - + pos.x() * bytesPerPixel; - - // BGRA - pixel.setBlue(*ptr++); - pixel.setGreen(*ptr++); - pixel.setRed(*ptr++); - - if(bytesPerPixel == 4) - pixel.setAlpha(*ptr++); - } - return pixel; + TScreenInfo info; + TRAPD(err, getScreenInfoL(info)); + QColor pixel; + if(err == KErrNone and pos.x() < info.width and pos.y() < info.height) + { + const int bytesPerPixel = info.bpp / 8; + Q_ASSERT(bytesPerPixel >= 3); + + const int stride = (info.width * bytesPerPixel) + info.lineOffset; + + const char* ptr = + info.address + + info.initialOffset + + pos.y() * stride + + pos.x() * bytesPerPixel; + + // BGRA + pixel.setBlue(*ptr++); + pixel.setGreen(*ptr++); + pixel.setRed(*ptr++); + + if(bytesPerPixel == 4) + pixel.setAlpha(*ptr++); + } + return pixel; } // Debugging: for debugging video visibility -void MMF::Utils::dumpScreenPixelSample() +void MMF::Utils::dumpScreenPixelSample() { for(int i=0; i<20; ++i) { - const QPoint pos(i*10, i*10); - const QColor pixel = Utils::getScreenPixel(pos); - RDebug::Printf( - "Phonon::MMF::Utils::dumpScreenPixelSample %d %d = %d %d %d %d", - pos.x(), pos.y(), pixel.red(), pixel.green(), pixel.blue(), pixel.alpha() - ); + const QPoint pos(i*10, i*10); + const QColor pixel = Utils::getScreenPixel(pos); + RDebug::Printf( + "Phonon::MMF::Utils::dumpScreenPixelSample %d %d = %d %d %d %d", + pos.x(), pos.y(), pixel.red(), pixel.green(), pixel.blue(), pixel.alpha() + ); } } -- cgit v0.12 From 0ec4a35196b9d7888efd0fe23bee1926dd201d0c Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 16:22:32 +0200 Subject: Make local function static. Addresses review comment. --- src/3rdparty/phonon/mmf/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index 294a9a2..2956722 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -68,7 +68,7 @@ struct TScreenInfo TDisplayMode displayMode; }; -void getScreenInfoL(TScreenInfo& info) +static void getScreenInfoL(TScreenInfo& info) { info.displayMode = CEikonEnv::Static()->ScreenDevice()->DisplayMode(); -- cgit v0.12 From e3d5a094caf85956ae50977ecf6176ff41acca78 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 16:24:00 +0200 Subject: Remove TODO comment. Addresses review comment. --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 2f2146b..82dcd7c 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -76,7 +76,6 @@ void MMF::AbstractMediaPlayer::play() switch (m_state) { case GroundState: - // Is this the correct error? Really we want 'NotReadyError' m_error = NormalError; changeState(ErrorState); break; -- cgit v0.12 From b170ef90fc16f072be8b271a026aa355513e8966 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 16:27:05 +0200 Subject: Revert "Modified MediaPlayer to set names on its child QObject instances" This reverts commit ea6b181df68a18044a06063ab33dc6eb35b2aba1. We revert it because although it's useful for us developers when debugging, it's intended for customers, to demonstrate how to use Qt code. Conflicts: demos/mediaplayer/mediaplayer.cpp --- demos/mediaplayer/mediaplayer.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/demos/mediaplayer/mediaplayer.cpp b/demos/mediaplayer/mediaplayer.cpp index 30e3a5b..8dd0609 100644 --- a/demos/mediaplayer/mediaplayer.cpp +++ b/demos/mediaplayer/mediaplayer.cpp @@ -152,9 +152,6 @@ MediaPlayer::MediaPlayer(const QString &filePath) : m_AudioOutput(Phonon::VideoCategory), m_videoWidget(new MediaVideoWidget(this)) { - m_videoWindow.setObjectName("videoWindow"); - m_videoWidget->setObjectName("videoWidget"); - setWindowTitle(tr("Media Player")); setContextMenuPolicy(Qt::CustomContextMenu); m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); @@ -162,7 +159,6 @@ MediaPlayer::MediaPlayer(const QString &filePath) : QSize buttonSize(34, 28); QPushButton *openButton = new QPushButton(this); - openButton->setObjectName("openButton"); openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); QPalette bpal; @@ -173,25 +169,20 @@ MediaPlayer::MediaPlayer(const QString &filePath) : openButton->setPalette(bpal); rewindButton = new QPushButton(this); - rewindButton->setObjectName("rewindButton"); rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); forwardButton = new QPushButton(this); - forwardButton->setObjectName("forwardButton"); forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); forwardButton->setEnabled(false); playButton = new QPushButton(this); - playButton->setObjectName("playButton"); playIcon = style()->standardIcon(QStyle::SP_MediaPlay); pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); playButton->setIcon(playIcon); slider = new Phonon::SeekSlider(this); - slider->setObjectName("slider"); slider->setMediaObject(&m_MediaObject); volume = new Phonon::VolumeSlider(&m_AudioOutput); - volume->setObjectName("volume"); QVBoxLayout *vLayout = new QVBoxLayout(this); vLayout->setContentsMargins(8, 8, 8, 8); @@ -199,7 +190,6 @@ MediaPlayer::MediaPlayer(const QString &filePath) : QHBoxLayout *layout = new QHBoxLayout(); info = new QLabel(this); - info->setObjectName("info"); info->setMinimumHeight(70); info->setAcceptDrops(false); info->setMargin(2); @@ -237,11 +227,8 @@ MediaPlayer::MediaPlayer(const QString &filePath) : buttonPanelLayout->addLayout(layout); timeLabel = new QLabel(this); - timeLabel->setObjectName("timeLabel"); progressLabel = new QLabel(this); - progressLabel->setObjectName("progressLabel"); QWidget *sliderPanel = new QWidget(this); - sliderPanel->setObjectName("sliderPanel"); QHBoxLayout *sliderLayout = new QHBoxLayout(); sliderLayout->addWidget(slider); sliderLayout->addWidget(timeLabel); @@ -264,7 +251,6 @@ MediaPlayer::MediaPlayer(const QString &filePath) : // forwardButton->setStyle(flatButtonStyle); #endif QWidget *buttonPanelWidget = new QWidget(this); - buttonPanelWidget->setObjectName("buttonPanelWidget"); buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); buttonPanelWidget->setLayout(buttonPanelLayout); vLayout->addWidget(buttonPanelWidget); -- cgit v0.12 From ba10fb231aaa5cf5512662b94c7f9b3702d2b2ec Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 16:33:08 +0200 Subject: Essentially do 's/NULL/0/g', to adhere to Qt coding style. Addresses review comment. --- src/3rdparty/phonon/mmf/abstractplayer.cpp | 2 +- src/3rdparty/phonon/mmf/audiooutput.cpp | 2 +- src/3rdparty/phonon/mmf/audioplayer.cpp | 4 ++-- src/3rdparty/phonon/mmf/backend.cpp | 2 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 4 ++-- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 16 ++++++++-------- src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp | 8 ++++---- src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.cpp | 4 ++-- src/3rdparty/phonon/mmf/videooutput.cpp | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index c6f0f6b..6ed5d51 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -30,7 +30,7 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::AbstractPlayer::AbstractPlayer() - : m_videoOutput(NULL) + : m_videoOutput(0) , m_tickInterval(DefaultTickInterval) , m_transitionTime(0) , m_prefinishMark(0) diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 20130ad..8c8c330 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -36,7 +36,7 @@ using namespace Phonon::MMF; MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : MediaNode(parent) , m_volume(InitialVolume) - , m_observer(NULL) + , m_observer(0) { } diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 17294a7..09fdca0 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -30,14 +30,14 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::AudioPlayer::AudioPlayer() : m_player(NULL) +MMF::AudioPlayer::AudioPlayer() : m_player(0) { construct(); } MMF::AudioPlayer::AudioPlayer(const AbstractPlayer& player) : AbstractMediaPlayer(player) - , m_player(NULL) + , m_player(0) { construct(); } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 7a9141d..0a9130c 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -56,7 +56,7 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const TRACE_CONTEXT(Backend::createObject, EBackend); TRACE_ENTRY("class %d", c); - QObject* result = NULL; + QObject* result = 0; switch (c) { case AudioOutputClass: diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index de0de59..5a5540c 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -267,9 +267,9 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) break; } - AbstractPlayer* newPlayer = NULL; + AbstractPlayer* newPlayer = 0; - // Construct newPlayer using oldPlayer (if not NULL) in order to copy + // Construct newPlayer using oldPlayer (if not 0) in order to copy // parameters (volume, prefinishMark, transitionTime) which may have // been set on oldPlayer. diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 0c47ece..8a38b76 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -40,9 +40,9 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::VideoPlayer::VideoPlayer() - : m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) + : m_wsSession(0) + , m_screenDevice(0) + , m_window(0) , m_totalTime(0) , m_mmfOutputChangePending(false) { @@ -51,9 +51,9 @@ MMF::VideoPlayer::VideoPlayer() MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) : AbstractMediaPlayer(player) - , m_wsSession(NULL) - , m_screenDevice(NULL) - , m_window(NULL) + , m_wsSession(0) + , m_screenDevice(0) + , m_window(0) , m_totalTime(0) , m_mmfOutputChangePending(false) { @@ -66,7 +66,7 @@ void MMF::VideoPlayer::construct() TRACE_ENTRY_0(); if (!m_videoOutput) { - m_dummyVideoOutput.reset(new VideoOutput(NULL)); + m_dummyVideoOutput.reset(new VideoOutput(0)); } videoOutput().setObserver(this); @@ -382,7 +382,7 @@ void MMF::VideoPlayer::videoOutputChanged() // Lazily construct a dummy output if needed here if (!m_videoOutput and m_dummyVideoOutput.isNull()) { - m_dummyVideoOutput.reset(new VideoOutput(NULL)); + m_dummyVideoOutput.reset(new VideoOutput(0)); } videoOutput().setObserver(this); diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp index 50c6bf8..ef2b81c 100644 --- a/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp @@ -278,7 +278,7 @@ void QVisitorPrivate::setIndent(unsigned indent) void QVisitorPrivate::visitNode(const QObject& object) { QObject* const objectParent = object.parent(); - Node* const nodeParent = objectParent ? findNode(objectParent) : NULL; + Node* const nodeParent = objectParent ? findNode(objectParent) : 0; // Create a new node and store in scoped pointer for exception safety Node* node = new Node; @@ -309,13 +309,13 @@ void QVisitorPrivate::visitComplete() QList branches; static const bool isLastChild = true; dumpRecursive(*m_root, branches, isLastChild); - m_root.reset(NULL); + m_root.reset(0); } QVisitorPrivate::Node* QVisitorPrivate::findNode(const QObject* object) const { Hash::const_iterator i = m_hash.find(object); - return (m_hash.end() == i) ? NULL : *i; + return (m_hash.end() == i) ? 0 : *i; } QByteArray QVisitorPrivate::branchBuffer @@ -390,7 +390,7 @@ void QVisitorPrivate::dumpNode // No annotations - just dump the object pointer const bool isNodeLine = true; QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); - qDebug() << NULL; // TODO + qDebug() << 0; // TODO } else { // Dump annotations diff --git a/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.cpp b/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.cpp index f9d1c93..5053b2d 100644 --- a/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.cpp +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objecttree.cpp @@ -26,7 +26,7 @@ namespace ObjectTree { DepthFirstConstIterator::DepthFirstConstIterator() - : m_pointee(NULL) + : m_pointee(0) { } @@ -72,7 +72,7 @@ void DepthFirstConstIterator::backtrack() } else { // Reached end of search - m_pointee = NULL; + m_pointee = 0; } } diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 642de97..e51fbcf 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -42,7 +42,7 @@ using namespace Phonon::MMF; MMF::VideoOutput::VideoOutput(QWidget* parent) : QWidget(parent) - , m_observer(NULL) + , m_observer(0) { TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); TRACE_ENTRY("parent 0x%08x", parent); -- cgit v0.12 From c952036e999144e654c63c515aee3b2ea6507e3f Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 16:46:50 +0200 Subject: Do runtime check for SetVolume. This was previously in, but apparently disappeared as part of git work. Addresses review comment. --- src/3rdparty/phonon/mmf/audioplayer.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 09fdca0..28b57f9 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -93,12 +93,19 @@ void MMF::AudioPlayer::doSeek(qint64 ms) int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) { - /* In SDK 3.1, this function is void. */ + /* In SDK 3.1, SetVolume() returns void. If we're compiling against + * 3.1, we handle it with ifdefs. However, if we compile against a later + * SDK but are _running_ against 3.1, we avoid returning from an undefined + * stack by doing a runtime check of the SDK version. */ #if !defined(__SERIES60_31__) - return m_player->SetVolume(mmfVolume); -#else - m_player->SetVolume(mmfVolume); - return KErrNone; + const int err = m_player->SetVolume(mmfVolume); + if (QSysInfo::s60Version() > QSysInfo::SV_S60_3_1) + return err; + else + return KErrNone; + #else + m_player->SetVolume(mmfVolume); + return KErrNone; #endif } -- cgit v0.12 From 05534776d824d993ec730f3e4870dd89fbe72bf0 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 16:48:21 +0200 Subject: Remove TODO comment. Addresses review comment. --- src/3rdparty/phonon/mmf/audioplayer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 28b57f9..3a4e04b 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -47,8 +47,6 @@ 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); -- cgit v0.12 From 0d0a39583946e83e8b9498736960ac2525cff209 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 17:08:37 +0200 Subject: Optimization: only bitblt if blitting is enabled. Addresses review comment. --- src/gui/kernel/qapplication_s60.cpp | 55 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 9d21c6c..1a8017b 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -738,38 +738,41 @@ void QSymbianControl::Draw(const TRect& r) const return; if (engine->type() == QPaintEngine::Raster) { - QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); - CFbsBitmap *bitmap = s60Surface->symbianBitmap(); + if(qwidget->d_func()->extraData()->disableBlit) { + + QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); + CFbsBitmap *bitmap = s60Surface->symbianBitmap(); #ifdef DEBUG_QSYMBIANCONTROL - const TDisplayMode displayMode = bitmap->DisplayMode(); - qDebug() << "QSymbianControl::Draw [" << this << "]" - << "mode " << displayMode; - - const TUint32 *address = bitmap->DataAddress(); - const int bitmapWidth = bitmap->SizeInPixels().iWidth; - const int bitmapHeight = bitmap->SizeInPixels().iHeight; - - for(int i=0; i<10 and i*10DisplayMode(); + qDebug() << "QSymbianControl::Draw [" << this << "]" + << "mode " << displayMode; + + const TUint32 *address = bitmap->DataAddress(); + const int bitmapWidth = bitmap->SizeInPixels().iWidth; + const int bitmapHeight = bitmap->SizeInPixels().iHeight; + + for(int i=0; i<10 and i*10GetPixel(color, TPoint(i*10, i*10)); - qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); - } + for(int i=0; i<10 and i*10GetPixel(color, TPoint(i*10, i*10)); + qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); + } #endif - CWindowGc &gc = SystemGc(); - if (qwidget->d_func()->isOpaque) - gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - - if(!qwidget->d_func()->extraData()->disableBlit) + CWindowGc &gc = SystemGc(); + if (qwidget->d_func()->isOpaque) + gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + } + else gc.BitBlt(r.iTl, bitmap, r); + } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); } -- cgit v0.12 From 1b38614b31d5e1ab98ab4a755ac421f159e6a1fc Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 17:25:30 +0200 Subject: Fix build. --- src/gui/kernel/qapplication_s60.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 1a8017b..ded4d5d 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -738,6 +738,8 @@ void QSymbianControl::Draw(const TRect& r) const return; if (engine->type() == QPaintEngine::Raster) { + CWindowGc &gc = SystemGc(); + if(qwidget->d_func()->extraData()->disableBlit) { QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); @@ -766,7 +768,6 @@ void QSymbianControl::Draw(const TRect& r) const } #endif - CWindowGc &gc = SystemGc(); if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); } -- cgit v0.12 From 8391d6564f60476f64bb2077555d4cd03e519e47 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 17:44:24 +0200 Subject: Fix build. --- src/gui/kernel/qapplication_s60.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index ded4d5d..e330057 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -738,13 +738,11 @@ void QSymbianControl::Draw(const TRect& r) const return; if (engine->type() == QPaintEngine::Raster) { + QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); + CFbsBitmap *bitmap = s60Surface->symbianBitmap(); CWindowGc &gc = SystemGc(); if(qwidget->d_func()->extraData()->disableBlit) { - - QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); - CFbsBitmap *bitmap = s60Surface->symbianBitmap(); - #ifdef DEBUG_QSYMBIANCONTROL const TDisplayMode displayMode = bitmap->DisplayMode(); qDebug() << "QSymbianControl::Draw [" << this << "]" -- cgit v0.12 From 1062bbbcd6c30844d9ade10de80f27a3afd4dacf Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 18:29:09 +0200 Subject: Disable code, as we don't have the required code in QtGui. --- src/3rdparty/phonon/mmf/videooutput.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index e51fbcf..f026555 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -52,12 +52,14 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) setAttribute(Qt::WA_NoSystemBackground, true); setAutoFillBackground(false); - // Causes QSymbianControl::Draw not to BitBlt this widget's region of the - // backing store. Since the backing store is (by default) a 16MU bitmap, - // blitting it results in this widget's screen region in the final - // framebuffer having opaque alpha values. This in turn causes the video - // to be invisible when running on the target device. - qt_widget_private(this)->extraData()->disableBlit = true; + // Causes QSymbianControl::Draw not to BitBlt this widget's region of the + // backing store. Since the backing store is (by default) a 16MU bitmap, + // blitting it results in this widget's screen region in the final + // framebuffer having opaque alpha values. This in turn causes the video + // to be invisible when running on the target device. + // + // The required code is currently not in QtGui. + //qt_widget_private(this)->extraData()->disableBlit = true; dump(); -- cgit v0.12 From 9345d47c3945b61a27724508e8b3d0aaf7b57bcf Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 24 Sep 2009 18:33:32 +0200 Subject: Revert all GUI changes from the MMF work. We revert because they seem to create regressions in the QWidget auto test. --- src/gui/gui.pro | 2 +- src/gui/kernel/qapplication_s60.cpp | 101 +-------- src/gui/kernel/qt_s60_p.h | 2 +- src/gui/kernel/qwidget_p.h | 13 +- src/gui/kernel/qwidget_s60.cpp | 426 +++++------------------------------- 5 files changed, 68 insertions(+), 476 deletions(-) diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 7c24002..83ac5fe 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -54,4 +54,4 @@ DEFINES += Q_INTERNAL_QAPP_SRC symbian:TARGET.UID3=0x2001B2DD # ro-section in gui can exceed default allocated space, so more rw-section little further -symbian-sbsv2: MMP_RULES += "LINKEROPTION armcc --rw-base 0x800000" +symbian-sbsv2: MMP_RULES += "LINKEROPTION armcc --rw-base 0x800000" \ No newline at end of file diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index e330057..a5d07fd 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -77,10 +77,6 @@ #include #include -#ifdef DEBUG_QSYMBIANCONTROL -#include -#endif - QT_BEGIN_NAMESPACE #if defined(QT_DEBUG) @@ -324,36 +320,13 @@ QSymbianControl::QSymbianControl(QWidget *w) { } -void QSymbianControl::ConstructL(bool isWindowOwning, bool desktop) +void QSymbianControl::ConstructL(bool topLevel, bool desktop) { if (!desktop) { - if (isWindowOwning or !qwidget->parentWidget()) + if (topLevel) { 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()); - - // Necessary in order to be able to track the activation status of - // the control's window - qwidget->d_func()->createExtra(); - -#ifdef DEBUG_QSYMBIANCONTROL - qDebug() << "QSymbianControl::ConstructL [" << this - << "] widget" << qwidget - << "isWindowOwning" << isWindowOwning - << "parentWidget" << qwidget->parentWidget() - << "OwnsWindow" << OwnsWindow() - << "Window.ClientHandle" << reinterpret_cast(DrawableWindow()->ClientHandle()) - << "WindowGroupId" << DrawableWindow()->WindowGroupId(); -#endif + } SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); @@ -721,57 +694,19 @@ TCoeInputCapabilities QSymbianControl::InputCapabilities() const void QSymbianControl::Draw(const TRect& r) const { QWindowSurface *surface = qwidget->windowSurface(); - QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; - -#ifdef DEBUG_QSYMBIANCONTROL - qDebug() << "QSymbianControl::Draw [" << this << "]" - << "rect " << r.iTl.iX << ',' << r.iTl.iY - << '-' << r.iBr.iX << ',' << r.iBr.iY - << "surface" << surface - << "engine" << engine - << "raster" << (engine ? engine->type() == QPaintEngine::Raster : false) - << "opaque" << (qwidget->d_func()->isOpaque) - << "disableBlit" << (qwidget->d_func()->extraData()->disableBlit); -#endif + if (!surface) + return; + QPaintEngine *engine = surface->paintDevice()->paintEngine(); if (!engine) return; - if (engine->type() == QPaintEngine::Raster) { QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); CFbsBitmap *bitmap = s60Surface->symbianBitmap(); CWindowGc &gc = SystemGc(); - - if(qwidget->d_func()->extraData()->disableBlit) { -#ifdef DEBUG_QSYMBIANCONTROL - const TDisplayMode displayMode = bitmap->DisplayMode(); - qDebug() << "QSymbianControl::Draw [" << this << "]" - << "mode " << displayMode; - - const TUint32 *address = bitmap->DataAddress(); - const int bitmapWidth = bitmap->SizeInPixels().iWidth; - const int bitmapHeight = bitmap->SizeInPixels().iHeight; - - for(int i=0; i<10 and i*10GetPixel(color, TPoint(i*10, i*10)); - qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); - } -#endif - - if (qwidget->d_func()->isOpaque) - gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - } - else - gc.BitBlt(r.iTl, bitmap, r); - + if (qwidget->d_func()->isOpaque) + gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + gc.BitBlt(r.iTl, bitmap, r); } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); } @@ -784,12 +719,6 @@ void QSymbianControl::SizeChanged() QSize oldSize = qwidget->size(); QSize newSize(Size().iWidth, Size().iHeight); -#ifdef DEBUG_QSYMBIANCONTROL - qDebug() << "QSymbianControl::SizeChanged [" << this << "]" - << oldSize.width() << 'x' << oldSize.height() - << "-" << newSize.width() << 'x' << newSize.height(); -#endif - if (oldSize != newSize) { QRect cr = qwidget->geometry(); cr.setSize(newSize); @@ -816,12 +745,6 @@ void QSymbianControl::PositionChanged() QPoint oldPos = qwidget->geometry().topLeft(); QPoint newPos(Position().iX, Position().iY); -#ifdef DEBUG_QSYMBIANCONTROL - qDebug() << "QSymbianControl::SizeChanged [" << this << "]" - << oldPos.x() << ',' << oldPos.y() - << "-" << newPos.x() << ',' << newPos.y(); -#endif - if (oldPos != newPos) { QRect cr = qwidget->geometry(); cr.moveTopLeft(newPos); @@ -1201,14 +1124,14 @@ QWidget * QApplication::topLevelAt(QPoint const& point) if (widget->geometry().adjusted(0,0,1,1).contains(point)) { // At this point we know there is a Qt widget under the point. // Now we need to make sure it is the top most in the z-order. - RDrawableWindow *const window = widget->effectiveWinId()->DrawableWindow(); - int z = window->OrdinalPosition(); + RDrawableWindow* rw = widget->d_func()->topData()->rwindow; + int z = rw->OrdinalPosition(); if (z < lowestZ) { lowestZ = z; found = widget; } } - } + } } return found; } diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 2474d69..aa39f9d 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -139,7 +139,7 @@ public: public: QSymbianControl(QWidget *w); - void ConstructL(bool isWindowOwning = false, bool desktop = false); + void ConstructL(bool topLevel = false, bool desktop = false); ~QSymbianControl(); void HandleResourceChange(int resourceType); void HandlePointerEventL(const TPointerEvent& aPointerEvent); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index d3cd724..5a9c48c 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -169,6 +169,9 @@ struct QTLWExtra { #ifndef QT_NO_QWS_MANAGER QWSManager *qwsManager; #endif +#elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN + uint activated : 1; // RWindowBase::Activated has been called + RDrawableWindow *rwindow; #endif }; @@ -221,15 +224,6 @@ struct QWExtra { QImage maskBits; CGImageRef imageMask; #endif -#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian - uint activated : 1; // RWindowBase::Activated has been called - - // If set, QSymbianControl::Draw does not blit this widget - // This is to allow, for use cases such as video, widgets which, from the Qt point - // of view, are just placeholders in the scene. For these widgets, any necessary - // drawing to the UI framebuffer is done by the relevant Symbian subsystem. For - // video rendering, this would be an MMF controller, or MDF post-processor. - uint disableBlit : 1; #endif }; @@ -294,7 +288,6 @@ public: void setMask_sys(const QRegion &); #ifdef Q_OS_SYMBIAN void handleSymbianDeferredFocusChanged(); - void setSoftKeys_sys(const QList &softkeys); #endif void raise_sys(); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 3d67bc8..4fef020 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -56,10 +56,6 @@ #include #endif -#ifdef DEBUG_QWIDGET -#include -#endif - QT_BEGIN_NAMESPACE extern bool qt_nograb(); @@ -82,225 +78,14 @@ static bool isEqual(const QList& a, const QList& b) return true; } -void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) +void QWidgetPrivate::setWSGeometry(bool /* dontShow */, const QRect & /* rect */) { - // Note: based on x11 implementation - - static const int XCOORD_MAX = 16383; - static const int WRECT_MAX = 16383; - - Q_Q(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "]" - << "q" << q; -#endif - - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - - /* - There are up to four different coordinate systems here: - Qt coordinate system for this widget. - Symbian coordinate system for this widget (relative to wrect). - Qt coordinate system for parent - Symbian 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 Symbian geometry of my widget. (starts out in parent's Qt coord sys, and ends up in parent's Symbian 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) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (1)" - << "control" << data.winid - << "SetExtent" << xrect.x() << ',' << xrect.y() - << xrect.width() << 'x' << xrect.height(); -#endif - - data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); - data.winid->DrawNow(); - } - 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) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (2)" - << "control" << data.winid - << "SetVisible(EFalse)"; -#endif - - 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)) { -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (3)" - << "control" << data.winid - << "child" << w->d_func(); -#endif - - 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))); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (4)" - << "control" << data.winid - << "SetExtent" << xrect.x() << ',' << xrect.y() - << xrect.width() << 'x' << xrect.height(); -#endif - - data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); - if(!jump) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (5)" - << "control" << data.winid - << "DrawNow"; -#endif - - data.winid->DrawNow(); - } - } - - //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()) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (6)" - << "control" << data.winid - << "SetVisible(ETrue)"; -#endif - - w->data->winid->DrawableWindow()->SetVisible(ETrue); - } - } - } - } - } - - if (jump && data.winid) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (7)" - << "control" << data.winid - << "DrawNow" << wrect.width() << 'x' << wrect.height(); -#endif - - data.winid->DrawNow(TRect(0, 0, wrect.width(), wrect.height())); - } - - if (mapWindow and !dontShow) { - q->setAttribute(Qt::WA_Mapped); - if (q->internalWinId()) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (8)" - << "control" << data.winid - << "SetVisible(ETrue)"; -#endif - - q->internalWinId()->DrawableWindow()->SetVisible(ETrue); - } - } } void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) { Q_Q(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "]" - << "q" << q - << x << ',' << y << w << 'x' << h << isMove; -#endif - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if ((q->windowType() == Qt::Desktop)) @@ -334,25 +119,13 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (q->isWindow()) { if (w == 0 || h == 0) { q->setAttribute(Qt::WA_OutsideWSRange, true); - if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (1)" - << "hide"; -#endif - + if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) hide_sys(); - } data.crect = QRect(x, y, w, h); data.window_state &= ~Qt::WindowFullScreen; } else if (q->isVisible() && q->testAttribute(Qt::WA_OutsideWSRange)) { q->setAttribute(Qt::WA_OutsideWSRange, false); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (2)" - << "SetRect, show"; -#endif - // put the window in its place and show it q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); data.crect.setRect(x, y, w, h); @@ -361,12 +134,6 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) } else { QRect r = QRect(x, y, w, h); data.crect = r; - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (3)" - << "SetRect"; -#endif - q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); topData()->normalGeometry = data.crect; } @@ -389,15 +156,8 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (inTopLevelResize) tlwExtra->inTopLevelResize = true; } - if (q->testAttribute(Qt::WA_WState_Created)) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (4)" - << "setWSGeometry"; -#endif - + if (q->testAttribute(Qt::WA_WState_Created)) setWSGeometry(); - } } if (q->isVisible()) { @@ -442,19 +202,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de bool desktop = (type == Qt::Desktop); //bool tool = (type == Qt::Tool || type == Qt::Drawer); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::create_sys [" << this << "] " - << "q" << q; - qDebug() << "QWidgetPrivate::create_sys [" << this << "] " - << "type" << type - << "flags" << flags - << "parent" << parentWidget - << "topLevel" << topLevel - << "popup" << popup - << "dialog" << dialog - << "desktop" << desktop; -#endif - WId id = 0; if (popup) @@ -506,17 +253,18 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); - RDrawableWindow *const drawableWindow = control->DrawableWindow(); + QTLWExtra *topExtra = topData(); + topExtra->rwindow = control->DrawableWindow(); // Request mouse move events. - drawableWindow->PointerFilter(EPointerFilterEnterExit + topExtra->rwindow->PointerFilter(EPointerFilterEnterExit | EPointerFilterMove | EPointerFilterDrag, 0); - drawableWindow->EnableVisibilityChangeEvents(); + topExtra->rwindow->EnableVisibilityChangeEvents(); if (!isOpaque) { - RWindow *const window = static_cast(drawableWindow); - const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); - if (window->SetTransparencyAlphaChannel() == KErrNone) - window->SetBackgroundColor(TRgb(255, 255, 255, 0)); + RWindow *rwindow = static_cast(topExtra->rwindow); + TDisplayMode gotDM = (TDisplayMode)rwindow->SetRequiredDisplayMode(EColor16MA); + if (rwindow->SetTransparencyAlphaChannel() == KErrNone) + rwindow->SetBackgroundColor(TRgb(255, 255, 255, 0)); } } @@ -538,6 +286,9 @@ 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); @@ -554,11 +305,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de void QWidgetPrivate::show_sys() { Q_Q(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::show_sys [" << this << "] " - << "q" << q; -#endif if (q->testAttribute(Qt::WA_OutsideWSRange)) return; @@ -572,31 +318,20 @@ void QWidgetPrivate::show_sys() return; } - if (q->internalWinId()) { - + if (q->isWindow() && q->internalWinId()) { + WId id = q->internalWinId(); - if (!extra->activated) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::show_sys [" << this << "]" - << "id" << id - << "isWindow" << q->isWindow() - << "ActivateL"; -#endif - + if (!extra->topextra->activated) { QT_TRAP_THROWING(id->ActivateL()); - extra->activated = 1; + extra->topextra->activated = 1; } id->MakeVisible(true); - - if(q->isWindow()) - id->SetFocus(true); + 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 - if(q->isWindow()) - setWindowIcon_sys(true); + setWindowIcon_sys(true); } invalidateBuffer(q->rect()); @@ -605,25 +340,11 @@ void QWidgetPrivate::show_sys() void QWidgetPrivate::hide_sys() { Q_Q(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::hide_sys [" << this << "]" - << "q" << q; -#endif - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); deactivateWidgetCleanup(); WId id = q->internalWinId(); - - if (id) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::show_sys [" << this << "]" - << "id" << id - << "MakeVisible(false)"; -#endif - - if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged() + if (q->isWindow() && id) { + if (id->IsFocused()) // Avoid unnecessary calls to FocusChanged() id->SetFocus(false); id->MakeVisible(false); if (QWidgetBackingStore *bs = maybeBackingStore()) @@ -647,13 +368,6 @@ void QWidgetPrivate::handleSymbianDeferredFocusChanged() { Q_Q(QWidget); WId control = q->internalWinId(); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::handleSymbianDeferredFocusChanged [" << this << "]" - << "q" << q - << "control" << control; -#endif - if (!control) { // This could happen if the widget was reparented, while the focuschange // was in the event queue. @@ -681,30 +395,21 @@ void QWidgetPrivate::handleSymbianDeferredFocusChanged() void QWidgetPrivate::raise_sys() { Q_Q(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::raise_sys [" << this << "]" - << "q" << q; -#endif - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - if (q->internalWinId()) - q->internalWinId()->DrawableWindow()->SetOrdinalPosition(0); + QTLWExtra *tlwExtra = maybeTopData(); + if (q->internalWinId() && tlwExtra) { + tlwExtra->rwindow->SetOrdinalPosition(0); + } } void QWidgetPrivate::lower_sys() { Q_Q(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::lower_sys [" << this << "]" - << "q" << q; -#endif - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - if (q->internalWinId()) - q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); - + QTLWExtra *tlwExtra = maybeTopData(); + if (q->internalWinId() && tlwExtra) { + tlwExtra->rwindow->SetOrdinalPosition(-1); + } if (!q->isWindow()) invalidateBuffer(q->rect()); } @@ -718,13 +423,10 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) { Q_Q(QWidget); Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - - if (q->internalWinId() && w->internalWinId()) { - RDrawableWindow *const thisWindow = q->internalWinId()->DrawableWindow(); - RDrawableWindow *const otherWindow = w->internalWinId()->DrawableWindow(); - thisWindow->SetOrdinalPosition(otherWindow->OrdinalPosition() + 1); - } - + QTLWExtra *tlwExtra = maybeTopData(); + QTLWExtra *tlwExtraSibling = w->d_func()->maybeTopData(); + if (q->internalWinId() && tlwExtra && w->internalWinId() && tlwExtraSibling) + tlwExtra->rwindow->SetOrdinalPosition(tlwExtraSibling->rwindow->OrdinalPosition() + 1); if (!q->isWindow() || !w->internalWinId()) invalidateBuffer(q->rect()); } @@ -732,12 +434,6 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) void QWidgetPrivate::reparentChildren() { Q_Q(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::reparentChildren [" << this << "]" - << "q" << q; -#endif - QObjectList chlist = q->children(); for (int i = 0; i < chlist.size(); ++i) { // reparent children QObject *obj = chlist.at(i); @@ -768,14 +464,6 @@ void QWidgetPrivate::reparentChildren() void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) { Q_Q(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setParent_sys [" << this << "]" - << "q" << q - << "parent" << parent - << "f" << f; -#endif - bool wasCreated = q->testAttribute(Qt::WA_WState_Created); if (q->isVisible() && q->parentWidget() && parent != q->parentWidget()) @@ -839,25 +527,23 @@ void QWidgetPrivate::s60UpdateIsOpaque() { Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::s60UpdateIsOpaque [" << this << "]" - << "q" << q; -#endif - if (!q->testAttribute(Qt::WA_WState_Created) || !q->testAttribute(Qt::WA_TranslucentBackground)) return; if ((data.window_flags & Qt::FramelessWindowHint) == 0) return; - RWindow *const window = static_cast(q->effectiveWinId()->DrawableWindow()); - if (!isOpaque) { - const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); - if (window->SetTransparencyAlphaChannel() == KErrNone) - window->SetBackgroundColor(TRgb(255, 255, 255, 0)); - } else - window->SetTransparentRegion(TRegionFix<1>()); + QTLWExtra *topExtra = topData(); + RWindow *rwindow = static_cast(topExtra->rwindow); + TDisplayMode gotDM = (TDisplayMode)rwindow->SetRequiredDisplayMode(EColor16MA); + if (rwindow->SetTransparencyAlphaChannel() == KErrNone) + rwindow->SetBackgroundColor(TRgb(255, 255, 255, 0)); + } else { + QTLWExtra *topExtra = topData(); + RWindow *rwindow = static_cast(topExtra->rwindow); + rwindow->SetTransparentRegion(TRegionFix<1>()); + } } CFbsBitmap* qt_pixmapToNativeBitmap(QPixmap pixmap, bool invert) @@ -1033,8 +719,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy) scrollRect(q->rect(), dx, dy); } else { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - RDrawableWindow *const window = q->internalWinId()->DrawableWindow(); - window->Scroll(TPoint(dx, dy)); + RDrawableWindow* rw = topData()->rwindow; + rw->Scroll(TPoint(dx, dy)); } } @@ -1046,8 +732,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) scrollRect(r, dx, dy); } else { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - RDrawableWindow *const window = q->internalWinId()->DrawableWindow(); - window->Scroll(TPoint(dx, dy), qt_QRect2TRect(r)); + RDrawableWindow* rw = topData()->rwindow; + rw->Scroll(TPoint(dx, dy), qt_QRect2TRect(r)); } } @@ -1079,6 +765,8 @@ void QWidgetPrivate::registerDropSite(bool /* on */) void QWidgetPrivate::createTLSysExtra() { extra->topextra->backingStore = 0; + extra->topextra->activated = 0; + extra->topextra->rwindow = 0; } void QWidgetPrivate::deleteTLSysExtra() @@ -1089,8 +777,7 @@ void QWidgetPrivate::deleteTLSysExtra() void QWidgetPrivate::createSysExtra() { - extra->activated = 0; - extra->disableBlit = 0; + } void QWidgetPrivate::deleteSysExtra() @@ -1225,12 +912,6 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const void QWidget::setWindowState(Qt::WindowStates newstate) { Q_D(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidget::setWindowState [" << this << "]" - << "newstate" << newstate; -#endif - Qt::WindowStates oldstate = windowState(); if (oldstate == newstate) return; @@ -1478,11 +1159,6 @@ void QWidget::releaseMouse() void QWidget::activateWindow() { Q_D(QWidget); - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidget::activateWindow [" << this << "]"; -#endif - QWidget *tlw = window(); if (tlw->isVisible()) { window()->createWinId(); -- cgit v0.12 From 76f550e266062ef72ce826676c80cc2b441a93f5 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 28 Sep 2009 10:43:33 +0200 Subject: Revert "Disable code, as we don't have the required code in QtGui." This reverts commit 1062bbbcd6c30844d9ade10de80f27a3afd4dacf. --- src/3rdparty/phonon/mmf/videooutput.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index f026555..e51fbcf 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -52,14 +52,12 @@ MMF::VideoOutput::VideoOutput(QWidget* parent) setAttribute(Qt::WA_NoSystemBackground, true); setAutoFillBackground(false); - // Causes QSymbianControl::Draw not to BitBlt this widget's region of the - // backing store. Since the backing store is (by default) a 16MU bitmap, - // blitting it results in this widget's screen region in the final - // framebuffer having opaque alpha values. This in turn causes the video - // to be invisible when running on the target device. - // - // The required code is currently not in QtGui. - //qt_widget_private(this)->extraData()->disableBlit = true; + // Causes QSymbianControl::Draw not to BitBlt this widget's region of the + // backing store. Since the backing store is (by default) a 16MU bitmap, + // blitting it results in this widget's screen region in the final + // framebuffer having opaque alpha values. This in turn causes the video + // to be invisible when running on the target device. + qt_widget_private(this)->extraData()->disableBlit = true; dump(); -- cgit v0.12 From 420672ce2d86f9be2b11a6bceba71f41aadfcedf Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 28 Sep 2009 10:43:58 +0200 Subject: Revert "Revert all GUI changes from the MMF work." This reverts commit 9345d47c3945b61a27724508e8b3d0aaf7b57bcf. --- src/gui/gui.pro | 2 +- src/gui/kernel/qapplication_s60.cpp | 101 ++++++++- src/gui/kernel/qt_s60_p.h | 2 +- src/gui/kernel/qwidget_p.h | 13 +- src/gui/kernel/qwidget_s60.cpp | 426 +++++++++++++++++++++++++++++++----- 5 files changed, 476 insertions(+), 68 deletions(-) diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 83ac5fe..7c24002 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -54,4 +54,4 @@ DEFINES += Q_INTERNAL_QAPP_SRC symbian:TARGET.UID3=0x2001B2DD # ro-section in gui can exceed default allocated space, so more rw-section little further -symbian-sbsv2: MMP_RULES += "LINKEROPTION armcc --rw-base 0x800000" \ No newline at end of file +symbian-sbsv2: MMP_RULES += "LINKEROPTION armcc --rw-base 0x800000" diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 27e8602..7ef335b 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -77,6 +77,10 @@ #include #include +#ifdef DEBUG_QSYMBIANCONTROL +#include +#endif + QT_BEGIN_NAMESPACE #if defined(QT_DEBUG) @@ -320,13 +324,36 @@ QSymbianControl::QSymbianControl(QWidget *w) { } -void QSymbianControl::ConstructL(bool topLevel, bool desktop) +void QSymbianControl::ConstructL(bool isWindowOwning, bool desktop) { if (!desktop) { - if (topLevel) { + if (isWindowOwning 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()); + + // Necessary in order to be able to track the activation status of + // the control's window + qwidget->d_func()->createExtra(); + +#ifdef DEBUG_QSYMBIANCONTROL + qDebug() << "QSymbianControl::ConstructL [" << this + << "] widget" << qwidget + << "isWindowOwning" << isWindowOwning + << "parentWidget" << qwidget->parentWidget() + << "OwnsWindow" << OwnsWindow() + << "Window.ClientHandle" << reinterpret_cast(DrawableWindow()->ClientHandle()) + << "WindowGroupId" << DrawableWindow()->WindowGroupId(); +#endif SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); @@ -767,19 +794,57 @@ TCoeInputCapabilities QSymbianControl::InputCapabilities() const void QSymbianControl::Draw(const TRect& r) const { QWindowSurface *surface = qwidget->windowSurface(); - if (!surface) - return; + QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; + +#ifdef DEBUG_QSYMBIANCONTROL + qDebug() << "QSymbianControl::Draw [" << this << "]" + << "rect " << r.iTl.iX << ',' << r.iTl.iY + << '-' << r.iBr.iX << ',' << r.iBr.iY + << "surface" << surface + << "engine" << engine + << "raster" << (engine ? engine->type() == QPaintEngine::Raster : false) + << "opaque" << (qwidget->d_func()->isOpaque) + << "disableBlit" << (qwidget->d_func()->extraData()->disableBlit); +#endif - QPaintEngine *engine = surface->paintDevice()->paintEngine(); if (!engine) return; + if (engine->type() == QPaintEngine::Raster) { QS60WindowSurface *s60Surface = static_cast(qwidget->windowSurface()); CFbsBitmap *bitmap = s60Surface->symbianBitmap(); CWindowGc &gc = SystemGc(); - if (qwidget->d_func()->isOpaque) - gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - gc.BitBlt(r.iTl, bitmap, r); + + if(qwidget->d_func()->extraData()->disableBlit) { +#ifdef DEBUG_QSYMBIANCONTROL + const TDisplayMode displayMode = bitmap->DisplayMode(); + qDebug() << "QSymbianControl::Draw [" << this << "]" + << "mode " << displayMode; + + const TUint32 *address = bitmap->DataAddress(); + const int bitmapWidth = bitmap->SizeInPixels().iWidth; + const int bitmapHeight = bitmap->SizeInPixels().iHeight; + + for(int i=0; i<10 and i*10GetPixel(color, TPoint(i*10, i*10)); + qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); + } +#endif + + if (qwidget->d_func()->isOpaque) + gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + } + else + gc.BitBlt(r.iTl, bitmap, r); + } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); } @@ -792,6 +857,12 @@ void QSymbianControl::SizeChanged() QSize oldSize = qwidget->size(); QSize newSize(Size().iWidth, Size().iHeight); +#ifdef DEBUG_QSYMBIANCONTROL + qDebug() << "QSymbianControl::SizeChanged [" << this << "]" + << oldSize.width() << 'x' << oldSize.height() + << "-" << newSize.width() << 'x' << newSize.height(); +#endif + if (oldSize != newSize) { QRect cr = qwidget->geometry(); cr.setSize(newSize); @@ -818,6 +889,12 @@ void QSymbianControl::PositionChanged() QPoint oldPos = qwidget->geometry().topLeft(); QPoint newPos(Position().iX, Position().iY); +#ifdef DEBUG_QSYMBIANCONTROL + qDebug() << "QSymbianControl::SizeChanged [" << this << "]" + << oldPos.x() << ',' << oldPos.y() + << "-" << newPos.x() << ',' << newPos.y(); +#endif + if (oldPos != newPos) { QRect cr = qwidget->geometry(); cr.moveTopLeft(newPos); @@ -1236,14 +1313,14 @@ QWidget * QApplication::topLevelAt(QPoint const& point) if (widget->geometry().adjusted(0,0,1,1).contains(point)) { // At this point we know there is a Qt widget under the point. // Now we need to make sure it is the top most in the z-order. - RDrawableWindow* rw = widget->d_func()->topData()->rwindow; - int z = rw->OrdinalPosition(); + RDrawableWindow *const window = widget->effectiveWinId()->DrawableWindow(); + int z = window->OrdinalPosition(); if (z < lowestZ) { lowestZ = z; found = widget; } } - } + } } return found; } diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 0d48634..d1ec74d 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -141,7 +141,7 @@ public: public: QSymbianControl(QWidget *w); - void ConstructL(bool topLevel = false, bool desktop = false); + void ConstructL(bool isWindowOwning = false, bool desktop = false); ~QSymbianControl(); void HandleResourceChange(int resourceType); void HandlePointerEventL(const TPointerEvent& aPointerEvent); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 296c5b1..2a81689 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -169,9 +169,6 @@ struct QTLWExtra { #ifndef QT_NO_QWS_MANAGER QWSManager *qwsManager; #endif -#elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN - uint activated : 1; // RWindowBase::Activated has been called - RDrawableWindow *rwindow; #endif }; @@ -224,6 +221,15 @@ struct QWExtra { QImage maskBits; CGImageRef imageMask; #endif +#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian + uint activated : 1; // RWindowBase::Activated has been called + + // If set, QSymbianControl::Draw does not blit this widget + // This is to allow, for use cases such as video, widgets which, from the Qt point + // of view, are just placeholders in the scene. For these widgets, any necessary + // drawing to the UI framebuffer is done by the relevant Symbian subsystem. For + // video rendering, this would be an MMF controller, or MDF post-processor. + uint disableBlit : 1; #endif }; @@ -288,6 +294,7 @@ public: void setMask_sys(const QRegion &); #ifdef Q_OS_SYMBIAN void handleSymbianDeferredFocusChanged(); + void setSoftKeys_sys(const QList &softkeys); #endif void raise_sys(); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 6b5e9b7..8667325 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -56,6 +56,10 @@ #include #endif +#ifdef DEBUG_QWIDGET +#include +#endif + QT_BEGIN_NAMESPACE extern bool qt_nograb(); @@ -78,14 +82,225 @@ static bool isEqual(const QList& a, const QList& b) return true; } -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); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "]" + << "q" << q; +#endif + + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); + + /* + There are up to four different coordinate systems here: + Qt coordinate system for this widget. + Symbian coordinate system for this widget (relative to wrect). + Qt coordinate system for parent + Symbian 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 Symbian geometry of my widget. (starts out in parent's Qt coord sys, and ends up in parent's Symbian 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) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (1)" + << "control" << data.winid + << "SetExtent" << xrect.x() << ',' << xrect.y() + << xrect.width() << 'x' << xrect.height(); +#endif + + data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); + data.winid->DrawNow(); + } + 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) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (2)" + << "control" << data.winid + << "SetVisible(EFalse)"; +#endif + + 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)) { +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (3)" + << "control" << data.winid + << "child" << w->d_func(); +#endif + + 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))); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (4)" + << "control" << data.winid + << "SetExtent" << xrect.x() << ',' << xrect.y() + << xrect.width() << 'x' << xrect.height(); +#endif + + data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); + if(!jump) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (5)" + << "control" << data.winid + << "DrawNow"; +#endif + + data.winid->DrawNow(); + } + } + + //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()) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (6)" + << "control" << data.winid + << "SetVisible(ETrue)"; +#endif + + w->data->winid->DrawableWindow()->SetVisible(ETrue); + } + } + } + } + } + + if (jump && data.winid) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (7)" + << "control" << data.winid + << "DrawNow" << wrect.width() << 'x' << wrect.height(); +#endif + + data.winid->DrawNow(TRect(0, 0, wrect.width(), wrect.height())); + } + + if (mapWindow and !dontShow) { + q->setAttribute(Qt::WA_Mapped); + if (q->internalWinId()) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (8)" + << "control" << data.winid + << "SetVisible(ETrue)"; +#endif + + q->internalWinId()->DrawableWindow()->SetVisible(ETrue); + } + } } void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "]" + << "q" << q + << x << ',' << y << w << 'x' << h << isMove; +#endif + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if ((q->windowType() == Qt::Desktop)) @@ -119,13 +334,25 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (q->isWindow()) { if (w == 0 || h == 0) { q->setAttribute(Qt::WA_OutsideWSRange, true); - if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) + if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (1)" + << "hide"; +#endif + hide_sys(); + } data.crect = QRect(x, y, w, h); data.window_state &= ~Qt::WindowFullScreen; } else if (q->isVisible() && q->testAttribute(Qt::WA_OutsideWSRange)) { q->setAttribute(Qt::WA_OutsideWSRange, false); +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (2)" + << "SetRect, show"; +#endif + // put the window in its place and show it q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); data.crect.setRect(x, y, w, h); @@ -134,6 +361,12 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) } else { QRect r = QRect(x, y, w, h); data.crect = r; + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (3)" + << "SetRect"; +#endif + q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); topData()->normalGeometry = data.crect; } @@ -156,8 +389,15 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (inTopLevelResize) tlwExtra->inTopLevelResize = true; } - if (q->testAttribute(Qt::WA_WState_Created)) + if (q->testAttribute(Qt::WA_WState_Created)) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (4)" + << "setWSGeometry"; +#endif + setWSGeometry(); + } } if (q->isVisible()) { @@ -202,6 +442,19 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de bool desktop = (type == Qt::Desktop); //bool tool = (type == Qt::Tool || type == Qt::Drawer); +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::create_sys [" << this << "] " + << "q" << q; + qDebug() << "QWidgetPrivate::create_sys [" << this << "] " + << "type" << type + << "flags" << flags + << "parent" << parentWidget + << "topLevel" << topLevel + << "popup" << popup + << "dialog" << dialog + << "desktop" << desktop; +#endif + WId id = 0; if (popup) @@ -253,18 +506,17 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags)); - QTLWExtra *topExtra = topData(); - topExtra->rwindow = control->DrawableWindow(); + RDrawableWindow *const drawableWindow = control->DrawableWindow(); // Request mouse move events. - topExtra->rwindow->PointerFilter(EPointerFilterEnterExit + drawableWindow->PointerFilter(EPointerFilterEnterExit | EPointerFilterMove | EPointerFilterDrag, 0); - topExtra->rwindow->EnableVisibilityChangeEvents(); + drawableWindow->EnableVisibilityChangeEvents(); if (!isOpaque) { - RWindow *rwindow = static_cast(topExtra->rwindow); - TDisplayMode gotDM = (TDisplayMode)rwindow->SetRequiredDisplayMode(EColor16MA); - if (rwindow->SetTransparencyAlphaChannel() == KErrNone) - rwindow->SetBackgroundColor(TRgb(255, 255, 255, 0)); + RWindow *const window = static_cast(drawableWindow); + const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); + if (window->SetTransparencyAlphaChannel() == KErrNone) + window->SetBackgroundColor(TRgb(255, 255, 255, 0)); } } @@ -286,9 +538,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); @@ -308,6 +557,11 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de void QWidgetPrivate::show_sys() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::show_sys [" << this << "] " + << "q" << q; +#endif if (q->testAttribute(Qt::WA_OutsideWSRange)) return; @@ -321,20 +575,31 @@ void QWidgetPrivate::show_sys() return; } - if (q->isWindow() && q->internalWinId()) { - + if (q->internalWinId()) { + WId id = q->internalWinId(); - if (!extra->topextra->activated) { + if (!extra->activated) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::show_sys [" << this << "]" + << "id" << id + << "isWindow" << q->isWindow() + << "ActivateL"; +#endif + QT_TRAP_THROWING(id->ActivateL()); - extra->topextra->activated = 1; + extra->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()); @@ -343,11 +608,25 @@ void QWidgetPrivate::show_sys() void QWidgetPrivate::hide_sys() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::hide_sys [" << this << "]" + << "q" << q; +#endif + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); deactivateWidgetCleanup(); WId id = q->internalWinId(); - if (q->isWindow() && id) { - if (id->IsFocused()) // Avoid unnecessary calls to FocusChanged() + + if (id) { + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::show_sys [" << this << "]" + << "id" << id + << "MakeVisible(false)"; +#endif + + if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged() id->SetFocus(false); id->MakeVisible(false); if (QWidgetBackingStore *bs = maybeBackingStore()) @@ -371,6 +650,13 @@ void QWidgetPrivate::handleSymbianDeferredFocusChanged() { Q_Q(QWidget); WId control = q->internalWinId(); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::handleSymbianDeferredFocusChanged [" << this << "]" + << "q" << q + << "control" << control; +#endif + if (!control) { // This could happen if the widget was reparented, while the focuschange // was in the event queue. @@ -398,21 +684,30 @@ void QWidgetPrivate::handleSymbianDeferredFocusChanged() void QWidgetPrivate::raise_sys() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::raise_sys [" << this << "]" + << "q" << q; +#endif + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - QTLWExtra *tlwExtra = maybeTopData(); - if (q->internalWinId() && tlwExtra) { - tlwExtra->rwindow->SetOrdinalPosition(0); - } + if (q->internalWinId()) + q->internalWinId()->DrawableWindow()->SetOrdinalPosition(0); } void QWidgetPrivate::lower_sys() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::lower_sys [" << this << "]" + << "q" << q; +#endif + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - QTLWExtra *tlwExtra = maybeTopData(); - if (q->internalWinId() && tlwExtra) { - tlwExtra->rwindow->SetOrdinalPosition(-1); - } + if (q->internalWinId()) + q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); + if (!q->isWindow()) invalidateBuffer(q->rect()); } @@ -426,10 +721,13 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) { Q_Q(QWidget); Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - QTLWExtra *tlwExtra = maybeTopData(); - QTLWExtra *tlwExtraSibling = w->d_func()->maybeTopData(); - if (q->internalWinId() && tlwExtra && w->internalWinId() && tlwExtraSibling) - tlwExtra->rwindow->SetOrdinalPosition(tlwExtraSibling->rwindow->OrdinalPosition() + 1); + + if (q->internalWinId() && w->internalWinId()) { + RDrawableWindow *const thisWindow = q->internalWinId()->DrawableWindow(); + RDrawableWindow *const otherWindow = w->internalWinId()->DrawableWindow(); + thisWindow->SetOrdinalPosition(otherWindow->OrdinalPosition() + 1); + } + if (!q->isWindow() || !w->internalWinId()) invalidateBuffer(q->rect()); } @@ -437,6 +735,12 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) void QWidgetPrivate::reparentChildren() { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::reparentChildren [" << this << "]" + << "q" << q; +#endif + QObjectList chlist = q->children(); for (int i = 0; i < chlist.size(); ++i) { // reparent children QObject *obj = chlist.at(i); @@ -467,6 +771,14 @@ void QWidgetPrivate::reparentChildren() void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) { Q_Q(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::setParent_sys [" << this << "]" + << "q" << q + << "parent" << parent + << "f" << f; +#endif + bool wasCreated = q->testAttribute(Qt::WA_WState_Created); if (q->isVisible() && q->parentWidget() && parent != q->parentWidget()) @@ -530,23 +842,25 @@ void QWidgetPrivate::s60UpdateIsOpaque() { Q_Q(QWidget); +#ifdef DEBUG_QWIDGET + qDebug() << "QWidgetPrivate::s60UpdateIsOpaque [" << this << "]" + << "q" << q; +#endif + if (!q->testAttribute(Qt::WA_WState_Created) || !q->testAttribute(Qt::WA_TranslucentBackground)) return; if ((data.window_flags & Qt::FramelessWindowHint) == 0) return; + RWindow *const window = static_cast(q->effectiveWinId()->DrawableWindow()); + if (!isOpaque) { - QTLWExtra *topExtra = topData(); - RWindow *rwindow = static_cast(topExtra->rwindow); - TDisplayMode gotDM = (TDisplayMode)rwindow->SetRequiredDisplayMode(EColor16MA); - if (rwindow->SetTransparencyAlphaChannel() == KErrNone) - rwindow->SetBackgroundColor(TRgb(255, 255, 255, 0)); - } else { - QTLWExtra *topExtra = topData(); - RWindow *rwindow = static_cast(topExtra->rwindow); - rwindow->SetTransparentRegion(TRegionFix<1>()); - } + const TDisplayMode displayMode = static_cast(window->SetRequiredDisplayMode(EColor16MA)); + if (window->SetTransparencyAlphaChannel() == KErrNone) + window->SetBackgroundColor(TRgb(255, 255, 255, 0)); + } else + window->SetTransparentRegion(TRegionFix<1>()); } CFbsBitmap* qt_pixmapToNativeBitmap(QPixmap pixmap, bool invert) @@ -722,8 +1036,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy) scrollRect(q->rect(), dx, dy); } else { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - RDrawableWindow* rw = topData()->rwindow; - rw->Scroll(TPoint(dx, dy)); + RDrawableWindow *const window = q->internalWinId()->DrawableWindow(); + window->Scroll(TPoint(dx, dy)); } } @@ -735,8 +1049,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) scrollRect(r, dx, dy); } else { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - RDrawableWindow* rw = topData()->rwindow; - rw->Scroll(TPoint(dx, dy), qt_QRect2TRect(r)); + RDrawableWindow *const window = q->internalWinId()->DrawableWindow(); + window->Scroll(TPoint(dx, dy), qt_QRect2TRect(r)); } } @@ -768,8 +1082,6 @@ void QWidgetPrivate::registerDropSite(bool /* on */) void QWidgetPrivate::createTLSysExtra() { extra->topextra->backingStore = 0; - extra->topextra->activated = 0; - extra->topextra->rwindow = 0; } void QWidgetPrivate::deleteTLSysExtra() @@ -780,7 +1092,8 @@ void QWidgetPrivate::deleteTLSysExtra() void QWidgetPrivate::createSysExtra() { - + extra->activated = 0; + extra->disableBlit = 0; } void QWidgetPrivate::deleteSysExtra() @@ -926,6 +1239,12 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const void QWidget::setWindowState(Qt::WindowStates newstate) { Q_D(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidget::setWindowState [" << this << "]" + << "newstate" << newstate; +#endif + Qt::WindowStates oldstate = windowState(); if (oldstate == newstate) return; @@ -1173,6 +1492,11 @@ void QWidget::releaseMouse() void QWidget::activateWindow() { Q_D(QWidget); + +#ifdef DEBUG_QWIDGET + qDebug() << "QWidget::activateWindow [" << this << "]"; +#endif + QWidget *tlw = window(); if (tlw->isVisible()) { window()->createWinId(); -- cgit v0.12 From e0fb34194f9ce85f67f158011b4e706835a5667c Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 24 Sep 2009 17:59:10 +0100 Subject: Implemented QWidget::mapFromGlobal, QWidget::mapToGlobal, for case where child widget owns a native window --- src/gui/kernel/qwidget_s60.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 8667325..912ba1f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1216,9 +1216,10 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const return pos + tp; } - // This is the native window case. Consider using CCoeControl::PositionRelativeToScreen() - // if we decide to go with CCoeControl - return QPoint(); + // Native window case + const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen(); + const QPoint globalPos = QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY) + pos; + return globalPos; } QPoint QWidget::mapFromGlobal(const QPoint &pos) const @@ -1232,8 +1233,10 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const return pos - tp; } - // ### TODO native window - return QPoint(); + // Native window case + const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen(); + const QPoint widgetPos = pos - QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY); + return widgetPos; } void QWidget::setWindowState(Qt::WindowStates newstate) -- cgit v0.12 From b798fc523446b4b7c7e888f7ef504202730e6cb5 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 28 Sep 2009 14:56:03 +0200 Subject: Mac: backport efd84105355 to silence visibility warnings Make sure that we build objective c files with visibility hidden as default Reviewed-by: prasanth --- mkspecs/features/mac/objective_c.prf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkspecs/features/mac/objective_c.prf b/mkspecs/features/mac/objective_c.prf index 0a73af9..0df7013 100644 --- a/mkspecs/features/mac/objective_c.prf +++ b/mkspecs/features/mac/objective_c.prf @@ -1,6 +1,5 @@ isEmpty(QMAKE_OBJECTIVE_CC):QMAKE_OBJECTIVE_CC = $$QMAKE_CC -isEmpty(QMAKE_OBJECTIVE_CFLAGS) { #bootstrap QMAKE_OBJECTIVE_CFLAGS = $$QMAKE_CFLAGS QMAKE_OBJECTIVE_CFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON QMAKE_OBJECTIVE_CFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF @@ -9,7 +8,7 @@ isEmpty(QMAKE_OBJECTIVE_CFLAGS) { #bootstrap QMAKE_OBJECTIVE_CFLAGS_X86 = $$QMAKE_CFLAGS_X86 QMAKE_OBJECTIVE_CFLAGS_PPC = $$QMAKE_CFLAGS_PPC QMAKE_OBJECTIVE_CFLAGS_HIDESYMS = $$QMAKE_CXXFLAGS_HIDESYMS -} + OBJECTIVE_C_OBJECTS_DIR = $$OBJECTS_DIR isEmpty(OBJECTIVE_C_OBJECTS_DIR):OBJECTIVE_C_OBJECTS_DIR = . isEmpty(QMAKE_EXT_OBJECTIVE_C):QMAKE_EXT_OBJECTIVE_C = .mm .m -- cgit v0.12 From 62624c575bd784b36b1d080d32f168e0668ca15b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 28 Sep 2009 15:07:24 +0200 Subject: Mac: build issue (autotest stalls build) When building Qt static on Mac, the test included actually stops the build process, prompting the user for 'Promteroo?' The reason is that configure runs qmake on all the tests inside the test/auto directory, including the one that is meant for testing qmake itself. In other words, this test should not be qmake'ed when running configure, only when running the qmake auto test. However, the qmake auto test does not run the prompt test anymore either. So the solution for now is to just comment out the test project as well. Reviewed-by: alexis --- tests/auto/qmake/testdata/prompt/prompt.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qmake/testdata/prompt/prompt.pro b/tests/auto/qmake/testdata/prompt/prompt.pro index 02db4fe..238022c 100644 --- a/tests/auto/qmake/testdata/prompt/prompt.pro +++ b/tests/auto/qmake/testdata/prompt/prompt.pro @@ -1,2 +1,2 @@ -a = $$prompt(Prompteroo) +# a = $$prompt(Prompteroo) -- cgit v0.12 From 6c58b17004d35ed652b5e93316f3f1c9d002d3b6 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 28 Sep 2009 15:33:55 +0200 Subject: tst_qnetworkcookiejar: Backported 4.6 changes Reviewed-by: TrustMe --- .../qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 946f4d3..9b9c56a 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -220,21 +220,21 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() QNetworkCookie cookie; cookie.setName("a"); cookie.setPath("/web"); - cookie.setDomain(".trolltech.com"); + cookie.setDomain(".nokia.com"); allCookies += cookie; QTest::newRow("no-match-1") << allCookies << "http://foo.bar/" << result; QTest::newRow("no-match-2") << allCookies << "http://foo.bar/web" << result; QTest::newRow("no-match-3") << allCookies << "http://foo.bar/web/wiki" << result; - QTest::newRow("no-match-4") << allCookies << "http://trolltech.com" << result; + QTest::newRow("no-match-4") << allCookies << "http://nokia.com" << result; QTest::newRow("no-match-5") << allCookies << "http://qt.nokia.com" << result; - QTest::newRow("no-match-6") << allCookies << "http://trolltech.com/webinar" << result; + QTest::newRow("no-match-6") << allCookies << "http://nokia.com/webinar" << result; QTest::newRow("no-match-7") << allCookies << "http://qt.nokia.com/webinar" << result; result = allCookies; - QTest::newRow("match-1") << allCookies << "http://trolltech.com/web" << result; - QTest::newRow("match-2") << allCookies << "http://trolltech.com/web/" << result; - QTest::newRow("match-3") << allCookies << "http://trolltech.com/web/content" << result; + QTest::newRow("match-1") << allCookies << "http://nokia.com/web" << result; + QTest::newRow("match-2") << allCookies << "http://nokia.com/web/" << result; + QTest::newRow("match-3") << allCookies << "http://nokia.com/web/content" << result; QTest::newRow("match-4") << allCookies << "http://qt.nokia.com/web" << result; QTest::newRow("match-4") << allCookies << "http://qt.nokia.com/web/" << result; QTest::newRow("match-6") << allCookies << "http://qt.nokia.com/web/content" << result; @@ -243,21 +243,21 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() allCookies += cookie; // exact same results as before: - QTest::newRow("one-match-1") << allCookies << "http://trolltech.com/web" << result; - QTest::newRow("one-match-2") << allCookies << "http://trolltech.com/web/" << result; - QTest::newRow("one-match-3") << allCookies << "http://trolltech.com/web/content" << result; + QTest::newRow("one-match-1") << allCookies << "http://nokia.com/web" << result; + QTest::newRow("one-match-2") << allCookies << "http://nokia.com/web/" << result; + QTest::newRow("one-match-3") << allCookies << "http://nokia.com/web/content" << result; QTest::newRow("one-match-4") << allCookies << "http://qt.nokia.com/web" << result; QTest::newRow("one-match-4") << allCookies << "http://qt.nokia.com/web/" << result; QTest::newRow("one-match-6") << allCookies << "http://qt.nokia.com/web/content" << result; result.prepend(cookie); // longer path, it must match first - QTest::newRow("two-matches-1") << allCookies << "http://trolltech.com/web/wiki" << result; + QTest::newRow("two-matches-1") << allCookies << "http://nokia.com/web/wiki" << result; QTest::newRow("two-matches-2") << allCookies << "http://qt.nokia.com/web/wiki" << result; // invert the order; allCookies.clear(); allCookies << result.at(1) << result.at(0); - QTest::newRow("two-matches-3") << allCookies << "http://trolltech.com/web/wiki" << result; + QTest::newRow("two-matches-3") << allCookies << "http://nokia.com/web/wiki" << result; QTest::newRow("two-matches-4") << allCookies << "http://qt.nokia.com/web/wiki" << result; // expired cookie @@ -265,9 +265,9 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() cookie.setExpirationDate(QDateTime::fromString("09-Nov-1999", "dd-MMM-yyyy")); allCookies += cookie; result.clear(); - QTest::newRow("exp-match-1") << allCookies << "http://trolltech.com/web" << result; - QTest::newRow("exp-match-2") << allCookies << "http://trolltech.com/web/" << result; - QTest::newRow("exp-match-3") << allCookies << "http://trolltech.com/web/content" << result; + QTest::newRow("exp-match-1") << allCookies << "http://nokia.com/web" << result; + QTest::newRow("exp-match-2") << allCookies << "http://nokia.com/web/" << result; + QTest::newRow("exp-match-3") << allCookies << "http://nokia.com/web/content" << result; QTest::newRow("exp-match-4") << allCookies << "http://qt.nokia.com/web" << result; QTest::newRow("exp-match-4") << allCookies << "http://qt.nokia.com/web/" << result; QTest::newRow("exp-match-6") << allCookies << "http://qt.nokia.com/web/content" << result; -- cgit v0.12 From d2bceb693aa26937f3def5e1b32fc4411d1b646a Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 28 Sep 2009 13:42:35 +0100 Subject: Fixed build errors due to header filename clashes between epoc32/include and Phonon. Both epoc32/include and $QTDIR/include/Phonon contain a file called videoplayer.h. Both of these directories are listed as SYSTEMINCLUDE paths in the generated MMP file, with the Phonon path coming first. This means that '#include ' picks up the Phonon header rather than (as intended) the Symbian one. A new qmake variable, PREPEND_INCLUDEPATH, is defined, allowing the .pro file to specify that /epoc32/include should be the first SYSTEMINCLUDE. --- mkspecs/features/symbian/qt.prf | 15 +++++++++++++++ src/3rdparty/phonon/mmf/mmf_videoplayer.h | 2 +- src/plugins/phonon/mmf/plugin/plugin.pro | 17 +++++------------ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf index dd4a4d5..3b24355 100644 --- a/mkspecs/features/symbian/qt.prf +++ b/mkspecs/features/symbian/qt.prf @@ -6,6 +6,21 @@ CONFIG += qtmain load(qt) +# Allow .pro files to specify include path(s) to be prepended to the list. +# +# This allows the project to override the default ordering, whereby paths +# relative to $$QMAKE_INCDIR_QT always come first. This ordering can cause +# problems when both the epoc32/include tree and a Qt include directory +# contain a header of the same name - in this case, the Qt header is always +# included by virtue of its path appearing first in the SYSTEMINCLUDE +# directives in the generated MMP file. +# +# To work around this situation, the following line can be added to the .pro +# file: +# PREPEND_INCLUDEPATH = /epoc32/include +# +INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH + # Add dependency to QtLibs package to all other projects besides QtLibs. # Note: QtLibs with full capabilities has UID3 of 0x2001E61C, # while self-signed version typically has temporary UID3 of 0xE001E61C. diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h index 2878d6a..a805135 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -19,7 +19,7 @@ along with this library. If not, see . #ifndef PHONON_MMF_VIDEOPLAYER_H #define PHONON_MMF_VIDEOPLAYER_H -#include +#include // from epoc32/include #include "abstractmediaplayer.h" #include "videooutput.h" diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index de108a6..eb7fd27 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -10,15 +10,16 @@ PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf phonon_mmf_audio_drm { LIBS += -lDrmAudioPlayUtility - DEFINES += QT_PHONON_MMF_AUDIO_DRM } else { LIBS += -lmediaclientaudio } -# In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this folder, as -# opposed to the public, where it is placed in epoc32/include. In some cases -# it's needed for other headers as well. +# This is necessary because both epoc32/include and Phonon contain videoplayer.h. +# By making /epoc32/include the first SYSTEMINCLUDE, we ensure that +# '#include ' picks up the Symbian header, as intended. +PREPEND_INCLUDEPATH = /epoc32/include + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE HEADERS += \ @@ -72,10 +73,6 @@ LIBS += -lws32 # For RWindow LIBS += -lefsrv # For file server LIBS += -lapgrfx -lapmime # For recognizer -# *** Temporary hack, necessitated by -# inline QSymbianControl::setTransparentBlit -LIBS += -lfbscli - # These are for effects. LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect @@ -87,9 +84,5 @@ INSTALLS += target include(../../../qpluginbase.pri) -# We need this to be able to resolve ambiguity for VideoPlayer.h. Phonon and -# the SDK has the header. -INCLUDEPATH *= /epoc32 - TARGET.UID3=0x2001E629 -- cgit v0.12 From 665c1da238df09f51c99faa8e5393a9ae73f92c4 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 28 Sep 2009 16:45:36 +0100 Subject: Fixed logical error in QSymbianControl::Draw --- src/gui/kernel/qapplication_s60.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 7ef335b..50d87a9 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -838,13 +838,13 @@ void QSymbianControl::Draw(const TRect& r) const qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); } #endif - + } + else { if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - } - else - gc.BitBlt(r.iTl, bitmap, r); + gc.BitBlt(r.iTl, bitmap, r); + } } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); } -- cgit v0.12 From 0a4440ae092058fd1fd4cd8df3908bc8d3cabfee Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 28 Sep 2009 16:51:57 +0100 Subject: Removed calls to CCoeControl::DrawNow from QWidgetPrivate::setWSGeometry --- src/gui/kernel/qwidget_s60.cpp | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 912ba1f..d69a5d0 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -150,7 +150,6 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) #endif data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); - data.winid->DrawNow(); } return; } @@ -242,26 +241,17 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) } } - //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()) { + if (mapWindow and !dontShow) { + q->setAttribute(Qt::WA_Mapped); + if (q->internalWinId()) { #ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (6)" + qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (8)" << "control" << data.winid << "SetVisible(ETrue)"; #endif - w->data->winid->DrawableWindow()->SetVisible(ETrue); - } - } - } + q->internalWinId()->DrawableWindow()->SetVisible(ETrue); } } @@ -273,21 +263,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) << "DrawNow" << wrect.width() << 'x' << wrect.height(); #endif - data.winid->DrawNow(TRect(0, 0, wrect.width(), wrect.height())); - } - - if (mapWindow and !dontShow) { - q->setAttribute(Qt::WA_Mapped); - if (q->internalWinId()) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (8)" - << "control" << data.winid - << "SetVisible(ETrue)"; -#endif - - q->internalWinId()->DrawableWindow()->SetVisible(ETrue); - } + RWindow *const window = static_cast(data.winid->DrawableWindow()); + window->Invalidate(TRect(0, 0, wrect.width(), wrect.height())); } } -- cgit v0.12 From 1ff83d2b44fe07d1bc6b243fad270dfa7d860dc7 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 28 Sep 2009 17:02:03 +0100 Subject: Removed trace statements from QtGui --- src/gui/kernel/qapplication_s60.cpp | 64 +----------- src/gui/kernel/qwidget_s60.cpp | 197 ++---------------------------------- 2 files changed, 9 insertions(+), 252 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 50d87a9..2996bf3 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -77,10 +77,6 @@ #include #include -#ifdef DEBUG_QSYMBIANCONTROL -#include -#endif - QT_BEGIN_NAMESPACE #if defined(QT_DEBUG) @@ -345,16 +341,6 @@ void QSymbianControl::ConstructL(bool isWindowOwning, bool desktop) // the control's window qwidget->d_func()->createExtra(); -#ifdef DEBUG_QSYMBIANCONTROL - qDebug() << "QSymbianControl::ConstructL [" << this - << "] widget" << qwidget - << "isWindowOwning" << isWindowOwning - << "parentWidget" << qwidget->parentWidget() - << "OwnsWindow" << OwnsWindow() - << "Window.ClientHandle" << reinterpret_cast(DrawableWindow()->ClientHandle()) - << "WindowGroupId" << DrawableWindow()->WindowGroupId(); -#endif - SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); } @@ -796,17 +782,6 @@ void QSymbianControl::Draw(const TRect& r) const QWindowSurface *surface = qwidget->windowSurface(); QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; -#ifdef DEBUG_QSYMBIANCONTROL - qDebug() << "QSymbianControl::Draw [" << this << "]" - << "rect " << r.iTl.iX << ',' << r.iTl.iY - << '-' << r.iBr.iX << ',' << r.iBr.iY - << "surface" << surface - << "engine" << engine - << "raster" << (engine ? engine->type() == QPaintEngine::Raster : false) - << "opaque" << (qwidget->d_func()->isOpaque) - << "disableBlit" << (qwidget->d_func()->extraData()->disableBlit); -#endif - if (!engine) return; @@ -815,34 +790,9 @@ void QSymbianControl::Draw(const TRect& r) const CFbsBitmap *bitmap = s60Surface->symbianBitmap(); CWindowGc &gc = SystemGc(); - if(qwidget->d_func()->extraData()->disableBlit) { -#ifdef DEBUG_QSYMBIANCONTROL - const TDisplayMode displayMode = bitmap->DisplayMode(); - qDebug() << "QSymbianControl::Draw [" << this << "]" - << "mode " << displayMode; - - const TUint32 *address = bitmap->DataAddress(); - const int bitmapWidth = bitmap->SizeInPixels().iWidth; - const int bitmapHeight = bitmap->SizeInPixels().iHeight; - - for(int i=0; i<10 and i*10GetPixel(color, TPoint(i*10, i*10)); - qDebug() << " " << i*10 << " : " << color.Red() << color.Green() << color.Blue() << color.Alpha(); - } -#endif - } - else { + if(!qwidget->d_func()->extraData()->disableBlit) { if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - gc.BitBlt(r.iTl, bitmap, r); } } else { @@ -857,12 +807,6 @@ void QSymbianControl::SizeChanged() QSize oldSize = qwidget->size(); QSize newSize(Size().iWidth, Size().iHeight); -#ifdef DEBUG_QSYMBIANCONTROL - qDebug() << "QSymbianControl::SizeChanged [" << this << "]" - << oldSize.width() << 'x' << oldSize.height() - << "-" << newSize.width() << 'x' << newSize.height(); -#endif - if (oldSize != newSize) { QRect cr = qwidget->geometry(); cr.setSize(newSize); @@ -889,12 +833,6 @@ void QSymbianControl::PositionChanged() QPoint oldPos = qwidget->geometry().topLeft(); QPoint newPos(Position().iX, Position().iY); -#ifdef DEBUG_QSYMBIANCONTROL - qDebug() << "QSymbianControl::SizeChanged [" << this << "]" - << oldPos.x() << ',' << oldPos.y() - << "-" << newPos.x() << ',' << newPos.y(); -#endif - if (oldPos != newPos) { QRect cr = qwidget->geometry(); cr.moveTopLeft(newPos); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index d69a5d0..d6e0a97 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -56,10 +56,6 @@ #include #endif -#ifdef DEBUG_QWIDGET -#include -#endif - QT_BEGIN_NAMESPACE extern bool qt_nograb(); @@ -91,11 +87,6 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "]" - << "q" << q; -#endif - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); /* @@ -140,17 +131,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) if (data.wrect.contains(vrect)) { xrect = data.wrect; xrect.translate(data.crect.topLeft()); - if (data.winid) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (1)" - << "control" << data.winid - << "SetExtent" << xrect.x() << ',' << xrect.y() - << xrect.width() << 'x' << xrect.height(); -#endif - + if (data.winid) data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); - } return; } } @@ -163,7 +145,6 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) //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 @@ -172,16 +153,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) if (q->testAttribute(Qt::WA_OutsideWSRange) != outsideRange) { q->setAttribute(Qt::WA_OutsideWSRange, outsideRange); if (outsideRange) { - if (data.winid) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (2)" - << "control" << data.winid - << "SetVisible(EFalse)"; -#endif - + if (data.winid) data.winid->DrawableWindow()->SetVisible(EFalse); - } q->setAttribute(Qt::WA_Mapped, false); } else if (!q->isHidden()) { mapWindow = true; @@ -194,23 +167,13 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) 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)) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (3)" - << "control" << data.winid - << "child" << w->d_func(); -#endif - + if (!w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) w->d_func()->setWSGeometry(jump); - } } } @@ -221,50 +184,18 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) if (!parent->internalWinId()) xrect.translate(parent->mapTo(q->nativeParentWidget(), QPoint(0, 0))); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (4)" - << "control" << data.winid - << "SetExtent" << xrect.x() << ',' << xrect.y() - << xrect.width() << 'x' << xrect.height(); -#endif - data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); - if(!jump) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (5)" - << "control" << data.winid - << "DrawNow"; -#endif - - data.winid->DrawNow(); - } } if (mapWindow and !dontShow) { q->setAttribute(Qt::WA_Mapped); - if (q->internalWinId()) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (8)" - << "control" << data.winid - << "SetVisible(ETrue)"; -#endif - + if (q->internalWinId()) q->internalWinId()->DrawableWindow()->SetVisible(ETrue); - } } if (jump && data.winid) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setWSGeometry [" << this << "] (7)" - << "control" << data.winid - << "DrawNow" << wrect.width() << 'x' << wrect.height(); -#endif - - RWindow *const window = static_cast(data.winid->DrawableWindow()); - window->Invalidate(TRect(0, 0, wrect.width(), wrect.height())); + RWindow *const window = static_cast(data.winid->DrawableWindow()); + window->Invalidate(TRect(0, 0, wrect.width(), wrect.height())); } } @@ -272,12 +203,6 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) { Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "]" - << "q" << q - << x << ',' << y << w << 'x' << h << isMove; -#endif - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if ((q->windowType() == Qt::Desktop)) @@ -311,39 +236,20 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (q->isWindow()) { if (w == 0 || h == 0) { q->setAttribute(Qt::WA_OutsideWSRange, true); - if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (1)" - << "hide"; -#endif - + if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) hide_sys(); - } data.crect = QRect(x, y, w, h); data.window_state &= ~Qt::WindowFullScreen; } else if (q->isVisible() && q->testAttribute(Qt::WA_OutsideWSRange)) { q->setAttribute(Qt::WA_OutsideWSRange, false); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (2)" - << "SetRect, show"; -#endif - // put the window in its place and show it q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); data.crect.setRect(x, y, w, h); - show_sys(); } else { QRect r = QRect(x, y, w, h); data.crect = r; - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (3)" - << "SetRect"; -#endif - q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); topData()->normalGeometry = data.crect; } @@ -366,15 +272,8 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (inTopLevelResize) tlwExtra->inTopLevelResize = true; } - if (q->testAttribute(Qt::WA_WState_Created)) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setGeometry_sys [" << this << "] (4)" - << "setWSGeometry"; -#endif - + if (q->testAttribute(Qt::WA_WState_Created)) setWSGeometry(); - } } if (q->isVisible()) { @@ -419,19 +318,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de bool desktop = (type == Qt::Desktop); //bool tool = (type == Qt::Tool || type == Qt::Drawer); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::create_sys [" << this << "] " - << "q" << q; - qDebug() << "QWidgetPrivate::create_sys [" << this << "] " - << "type" << type - << "flags" << flags - << "parent" << parentWidget - << "topLevel" << topLevel - << "popup" << popup - << "dialog" << dialog - << "desktop" << desktop; -#endif - WId id = 0; if (popup) @@ -535,11 +421,6 @@ void QWidgetPrivate::show_sys() { Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::show_sys [" << this << "] " - << "q" << q; -#endif - if (q->testAttribute(Qt::WA_OutsideWSRange)) return; @@ -556,14 +437,6 @@ void QWidgetPrivate::show_sys() WId id = q->internalWinId(); if (!extra->activated) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::show_sys [" << this << "]" - << "id" << id - << "isWindow" << q->isWindow() - << "ActivateL"; -#endif - QT_TRAP_THROWING(id->ActivateL()); extra->activated = 1; } @@ -586,23 +459,11 @@ void QWidgetPrivate::hide_sys() { Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::hide_sys [" << this << "]" - << "q" << q; -#endif - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); deactivateWidgetCleanup(); WId id = q->internalWinId(); if (id) { - -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::show_sys [" << this << "]" - << "id" << id - << "MakeVisible(false)"; -#endif - if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged() id->SetFocus(false); id->MakeVisible(false); @@ -628,12 +489,6 @@ void QWidgetPrivate::handleSymbianDeferredFocusChanged() Q_Q(QWidget); WId control = q->internalWinId(); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::handleSymbianDeferredFocusChanged [" << this << "]" - << "q" << q - << "control" << control; -#endif - if (!control) { // This could happen if the widget was reparented, while the focuschange // was in the event queue. @@ -662,11 +517,6 @@ void QWidgetPrivate::raise_sys() { Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::raise_sys [" << this << "]" - << "q" << q; -#endif - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if (q->internalWinId()) q->internalWinId()->DrawableWindow()->SetOrdinalPosition(0); @@ -676,11 +526,6 @@ void QWidgetPrivate::lower_sys() { Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::lower_sys [" << this << "]" - << "q" << q; -#endif - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); if (q->internalWinId()) q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); @@ -713,11 +558,6 @@ void QWidgetPrivate::reparentChildren() { Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::reparentChildren [" << this << "]" - << "q" << q; -#endif - QObjectList chlist = q->children(); for (int i = 0; i < chlist.size(); ++i) { // reparent children QObject *obj = chlist.at(i); @@ -749,13 +589,6 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) { Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::setParent_sys [" << this << "]" - << "q" << q - << "parent" << parent - << "f" << f; -#endif - bool wasCreated = q->testAttribute(Qt::WA_WState_Created); if (q->isVisible() && q->parentWidget() && parent != q->parentWidget()) @@ -819,11 +652,6 @@ void QWidgetPrivate::s60UpdateIsOpaque() { Q_Q(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidgetPrivate::s60UpdateIsOpaque [" << this << "]" - << "q" << q; -#endif - if (!q->testAttribute(Qt::WA_WState_Created) || !q->testAttribute(Qt::WA_TranslucentBackground)) return; @@ -1220,11 +1048,6 @@ void QWidget::setWindowState(Qt::WindowStates newstate) { Q_D(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidget::setWindowState [" << this << "]" - << "newstate" << newstate; -#endif - Qt::WindowStates oldstate = windowState(); if (oldstate == newstate) return; @@ -1473,10 +1296,6 @@ void QWidget::activateWindow() { Q_D(QWidget); -#ifdef DEBUG_QWIDGET - qDebug() << "QWidget::activateWindow [" << this << "]"; -#endif - QWidget *tlw = window(); if (tlw->isVisible()) { window()->createWinId(); -- cgit v0.12 From 9167aabca46c46dff0630cfc349f777211734219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 28 Sep 2009 19:26:47 +0200 Subject: Added my 4.5.3 changes to changelog. --- dist/changes-4.5.3 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dist/changes-4.5.3 b/dist/changes-4.5.3 index d797b4c..ac5a1f7 100644 --- a/dist/changes-4.5.3 +++ b/dist/changes-4.5.3 @@ -52,6 +52,18 @@ Third party components HTTP request. * [256630] Fix usage of QProgressDialog together with QNetworkReply. +- QPainter + * [254105] Fixed potential segmentation fault when setting empty clip + rectangle. + * [256549] Fixed inconsistent behavior between paint engines when + setting an IntersectClip after doing setClipping(false). + * [254407] Fixed rendering issue with outline drawing using + projective transforms. + * [258776] Fixed rounding bug in drawImage(). + +- QPainterPath + * [251909] Fixed bug in QPainterPath::united() / simplified(). + - QSslCertificate * [256066] Fix loading of a PEM when the length was a multiple of 64. -- cgit v0.12 From 390c40d7d2bbc622e18aa1c096d0b5fee5a04344 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 25 Sep 2009 09:25:22 -0700 Subject: Update changes file for 4.5.3 for DirectFB Reviewed-by: TrustMe --- dist/changes-4.5.3 | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/dist/changes-4.5.3 b/dist/changes-4.5.3 index ac5a1f7..0bec84d 100644 --- a/dist/changes-4.5.3 +++ b/dist/changes-4.5.3 @@ -74,7 +74,7 @@ Third party components **************************************************************************** * Database Drivers * **************************************************************************** -- [QT-353] (ODBC) Fixed issue of forward only datasets failing when not +- [QT-353] (ODBC) Fixed issue of forward only datasets failing when not explicitly set so. - [222678] Fixed QSqlTableModel: trying to delete the wrong row. - (Interbase) Fixed crash when calling numRows on unknown query type. @@ -107,7 +107,7 @@ Qt for Windows Qt for Mac OS X --------------- -[252088] Drag and drop events will now consider the WA_TransparentForMouseEvents +[252088] Drag and drop events will now consider the WA_TransparentForMouseEvents in Cocoa port. [255428] Fixed an an issue when Calling QWidget::raise() on hidden windows making them visible in Cocoa port. @@ -116,7 +116,7 @@ Qt for Mac OS X [258822] Fixed a crash when inserting the same menu twice in a menubar in Cocoa port. - Fixed the wizard background images for Snow Leopard. - + Qt for Embedded Linux --------------------- @@ -179,6 +179,17 @@ Qt for Windows CE * Plugins * **************************************************************************** +- DirectFB + * Make autorepeat work for DirectFB keyboard driver + * Fix a crash when resizing windows + * Fix an off by one when flipping surfaces that could lead to artifacts + * Make painting operations with QRegion clips go to DirectFB rather than + Raster (when possible) + * Make porter duff operations work for blits + * Various optimizations + * Handle more operations in hw + + **************************************************************************** * Important Behavior Changes * -- cgit v0.12 From 5170774f96c87e73f997fb9a9bc856d5f78741ac Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 29 Sep 2009 14:58:04 +1000 Subject: Tidy changes file for 4.5.3. Reviewed-by: Trust Me --- dist/changes-4.5.3 | 123 +++++++++++------------------------------------------ 1 file changed, 24 insertions(+), 99 deletions(-) diff --git a/dist/changes-4.5.3 b/dist/changes-4.5.3 index 0bec84d..f3a36d3 100644 --- a/dist/changes-4.5.3 +++ b/dist/changes-4.5.3 @@ -17,34 +17,21 @@ Each of these identifiers can be entered in the task tracker to obtain more information about a particular change. **************************************************************************** -* General * -**************************************************************************** - -General Improvements --------------------- - -- Documentation and Examples - -Third party components ----------------------- - - -**************************************************************************** * Library * **************************************************************************** +- QColorDialog + * [256164] Fixed the setting of alpha values in QColorDialog. + - QDirIterator * [258230] Fixed inconsistencies in value returned from QDirIterator::next(). -- QColorDialog - * [256164] Fixed the setting of alpha values in QColorDialog. - - QDoubleSpinBox * [255019] Fixed a crash when using large value for decimals. - QInputDialog - * [255502] Fixed bug in getDouble() + * [255502] Fixed bug in getDouble(). - QNetworkAccessManager * [256240] Proper handling of HTTP redirect in AlwaysCache mode. @@ -74,15 +61,16 @@ Third party components **************************************************************************** * Database Drivers * **************************************************************************** + - [QT-353] (ODBC) Fixed issue of forward only datasets failing when not - explicitly set so. + explicitly set so. - [222678] Fixed QSqlTableModel: trying to delete the wrong row. - (Interbase) Fixed crash when calling numRows on unknown query type. - Fixed several database autotests. - Fixed determination of end of odbc string on deficient driver. - Fixed formatting of date strings in psql driver. - Fixed mysql queries automatically getting prepared. Now have to explicitly - prepare them if you want that functionality. + prepare them if you want that functionality. - Fixed failure when QSqlTableModel has null fields to update. - Fixed missing isnan/isinf on some platforms (needed for postgres driver) - Fixed ::record for dialect 3 named tables in interbase/firebird. @@ -95,84 +83,27 @@ Third party components Qt for Linux/X11 ---------------- - - Fixed a bug where an empty KDEDIRS variable would bring /share into the icon search path. - [KDE 191759] Plasma spinning in endless loop. -Qt for Windows --------------- - - Qt for Mac OS X --------------- -[252088] Drag and drop events will now consider the WA_TransparentForMouseEvents - in Cocoa port. -[255428] Fixed an an issue when Calling QWidget::raise() on hidden windows making - them visible in Cocoa port. -[256269] Window resize events triggered from QWidget::adjustSize() will now - be sent as non-spontaneous event in the Cocoa port. -[258822] Fixed a crash when inserting the same menu twice in a menubar in Cocoa port. - -- Fixed the wizard background images for Snow Leopard. - - -Qt for Embedded Linux ---------------------- +- [252088] Drag and drop events will now consider the + WA_TransparentForMouseEvents in Cocoa port. +- [255428] Fixed an issue when calling QWidget::raise() on hidden windows + making them visible in Cocoa port. +- [256269] Window resize events triggered from QWidget::adjustSize() will now + be sent as a non-spontaneous event in the Cocoa port. +- [258822] Fixed a crash when inserting the same menu twice in a menubar in + Cocoa port. +- Fixed the wizard background images for Snow Leopard. Qt for Windows CE ----------------- -[260702] Fixed restoring of minimized Windows. - -**************************************************************************** -* Compiler Specific Changes * -**************************************************************************** - - -**************************************************************************** -* Tools * -**************************************************************************** - -- Build System - -- Assistant - - -- Designer - - -- Linguist - - Linguist GUI - - - lupdate - - - lrelease - - -- rcc - - -- moc - - -- uic - - -- uic3 - - -- qmake - - -- configure - - -- qtconfig - - -- qt3to4 +- [260702] Fixed restoring of minimized Windows. **************************************************************************** @@ -180,18 +111,12 @@ Qt for Windows CE **************************************************************************** - DirectFB - * Make autorepeat work for DirectFB keyboard driver - * Fix a crash when resizing windows - * Fix an off by one when flipping surfaces that could lead to artifacts + * Make autorepeat work for DirectFB keyboard driver. + * Fix a crash when resizing windows. + * Fix an off by one when flipping surfaces that could lead to artifacts. * Make painting operations with QRegion clips go to DirectFB rather than - Raster (when possible) - * Make porter duff operations work for blits - * Various optimizations - * Handle more operations in hw - - - -**************************************************************************** -* Important Behavior Changes * -**************************************************************************** + Raster (when possible). + * Make porter duff operations work for blits. + * Various optimizations. + * Handle more operations in hw. -- cgit v0.12 From dfceee3410955a85baf7cc2d536874f7a66f660f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 29 Sep 2009 09:39:13 +0200 Subject: I18N: Add new module, fix spelling glitch. --- src/corelib/kernel/qsystemsemaphore_symbian.cpp | 2 +- translations/translations.pri | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qsystemsemaphore_symbian.cpp b/src/corelib/kernel/qsystemsemaphore_symbian.cpp index 90f4e70..31fd9e9 100644 --- a/src/corelib/kernel/qsystemsemaphore_symbian.cpp +++ b/src/corelib/kernel/qsystemsemaphore_symbian.cpp @@ -66,7 +66,7 @@ void QSystemSemaphorePrivate::setErrorString(const QString &function, int err) error = QSystemSemaphore::AlreadyExists; break; case KErrNotFound: - errorString = QCoreApplication::tr("%1: doesn't exists", "QSystemSemaphore").arg(function); + errorString = QCoreApplication::tr("%1: does not exist", "QSystemSemaphore").arg(function); error = QSystemSemaphore::NotFound; break; case KErrNoMemory: diff --git a/translations/translations.pri b/translations/translations.pri index 480849f..8ddf01b 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -30,11 +30,13 @@ ts-qt.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \ activeqt \ corelib \ gui \ + multimedia \ network \ opengl \ plugins \ qt3support \ script \ + scripttools \ sql \ svg \ xml \ -- cgit v0.12 From dad31edd2d5be5a2902f6b011910f418882c9367 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Sun, 23 Aug 2009 12:08:20 +0200 Subject: Use glXGetProcAddress to resolve glx extensions On systems where the GL driver is pluggable (like Mesa), we have to use the glXGetProcAddressARB extension to resolve other function pointers as the symbols wont be in the GL library, but rather in a plugin loaded by the GL library. This fix basically makes texture-from-pixmap work on Mesa drivers like intel i915 & friends. Reviewed-by: Trond --- src/opengl/qgl_x11.cpp | 92 +++++++++++++++++++++++++-------------- src/opengl/qglpixelbuffer_x11.cpp | 33 ++++---------- 2 files changed, 68 insertions(+), 57 deletions(-) diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index da7972d..86e593d 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -331,6 +331,62 @@ static void find_trans_colors() QGLFormat UNIX/GLX-specific code *****************************************************************************/ +void* qglx_getProcAddress(const char* procName) +{ + // On systems where the GL driver is pluggable (like Mesa), we have to use + // the glXGetProcAddressARB extension to resolve other function pointers as + // the symbols wont be in the GL library, but rather in a plugin loaded by + // the GL library. + typedef void* (*qt_glXGetProcAddressARB)(const char *); + static qt_glXGetProcAddressARB glXGetProcAddressARB = 0; + static bool triedResolvingGlxGetProcAddress = false; + if (!triedResolvingGlxGetProcAddress) { + triedResolvingGlxGetProcAddress = true; + QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); + if (glxExt.contains(QLatin1String("GLX_ARB_get_proc_address"))) { +#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) + void *handle = dlopen(NULL, RTLD_LAZY); + if (handle) { + glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB"); + dlclose(handle); + } + if (!glXGetProcAddressARB) +#endif + { +#if !defined(QT_NO_LIBRARY) + extern const QString qt_gl_library_name(); + QLibrary lib(qt_gl_library_name()); + glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB"); +#endif + } + } + } + + void *procAddress = 0; + if (glXGetProcAddressARB) + procAddress = glXGetProcAddressARB(procName); + + // If glXGetProcAddress didn't work, try looking the symbol up in the GL library +#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) + if (!procAddress) { + void *handle = dlopen(NULL, RTLD_LAZY); + if (handle) { + procAddress = dlsym(handle, procName); + dlclose(handle); + } + } +#endif +#if !defined(QT_NO_LIBRARY) + if (!procAddress) { + extern const QString qt_gl_library_name(); + QLibrary lib(qt_gl_library_name()); + procAddress = lib.resolve(procName); + } +#endif + + return procAddress; +} + bool QGLFormat::hasOpenGL() { return glXQueryExtension(X11->display, 0, 0) != 0; @@ -819,23 +875,8 @@ void QGLContext::swapBuffers() const if (!resolved) { QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); if (glxExt.contains(QLatin1String("GLX_SGI_video_sync"))) { -#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) - void *handle = dlopen(NULL, RTLD_LAZY); - if (handle) { - glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI) dlsym(handle, "glXGetVideoSyncSGI"); - glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI) dlsym(handle, "glXWaitVideoSyncSGI"); - dlclose(handle); - } - if (!glXGetVideoSyncSGI) -#endif - { -#if !defined(QT_NO_LIBRARY) - extern const QString qt_gl_library_name(); - QLibrary lib(qt_gl_library_name()); - glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI) lib.resolve("glXGetVideoSyncSGI"); - glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI) lib.resolve("glXWaitVideoSyncSGI"); -#endif - } + glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI)qglx_getProcAddress("glXGetVideoSyncSGI"); + glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI)qglx_getProcAddress("glXWaitVideoSyncSGI"); } resolved = true; } @@ -1568,21 +1609,8 @@ bool qt_resolveTextureFromPixmap() QString glxExt = QLatin1String(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); if (glxExt.contains(QLatin1String("GLX_EXT_texture_from_pixmap"))) { -#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) - void *handle = dlopen(NULL, RTLD_LAZY); - if (handle) { - glXBindTexImageEXT = (qt_glXBindTexImageEXT) dlsym(handle, "glXBindTexImageEXT"); - glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) dlsym(handle, "glXReleaseTexImageEXT"); - dlclose(handle); - } - if (!glXBindTexImageEXT) -#endif - { - extern const QString qt_gl_library_name(); - QLibrary lib(qt_gl_library_name()); - glXBindTexImageEXT = (qt_glXBindTexImageEXT) lib.resolve("glXBindTexImageEXT"); - glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) lib.resolve("glXReleaseTexImageEXT"); - } + glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT"); + glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) qglx_getProcAddress("glXReleaseTexImageEXT"); } } diff --git a/src/opengl/qglpixelbuffer_x11.cpp b/src/opengl/qglpixelbuffer_x11.cpp index 793471d..6971133 100644 --- a/src/opengl/qglpixelbuffer_x11.cpp +++ b/src/opengl/qglpixelbuffer_x11.cpp @@ -93,6 +93,8 @@ static _glXMakeContextCurrent qt_glXMakeContextCurrent = 0; #define glXGetFBConfigAttrib qt_glXGetFBConfigAttrib #define glXMakeContextCurrent qt_glXMakeContextCurrent +extern void* qglx_getProcAddress(const char* procName); // in qgl_x11.cpp + static bool qt_resolve_pbuffer_extensions() { static int resolved = false; @@ -101,31 +103,12 @@ static bool qt_resolve_pbuffer_extensions() else if (resolved) return false; -#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) - void *handle = dlopen(NULL, RTLD_LAZY); - if (handle) { - qt_glXChooseFBConfig = (_glXChooseFBConfig) dlsym(handle, "glXChooseFBConfig"); - qt_glXCreateNewContext = (_glXCreateNewContext) dlsym(handle, "glXCreateNewContext"); - qt_glXCreatePbuffer = (_glXCreatePbuffer) dlsym(handle, "glXCreatePbuffer"); - qt_glXDestroyPbuffer = (_glXDestroyPbuffer) dlsym(handle, "glXDestroyPbuffer"); - qt_glXGetFBConfigAttrib = (_glXGetFBConfigAttrib) dlsym(handle, "glXGetFBConfigAttrib"); - qt_glXMakeContextCurrent = (_glXMakeContextCurrent) dlsym(handle, "glXMakeContextCurrent"); - dlclose(handle); - } - if (!qt_glXChooseFBConfig) -#endif - { -#if !defined(QT_NO_LIBRARY) - extern const QString qt_gl_library_name(); - QLibrary gl(qt_gl_library_name()); - qt_glXChooseFBConfig = (_glXChooseFBConfig) gl.resolve("glXChooseFBConfig"); - qt_glXCreateNewContext = (_glXCreateNewContext) gl.resolve("glXCreateNewContext"); - qt_glXCreatePbuffer = (_glXCreatePbuffer) gl.resolve("glXCreatePbuffer"); - qt_glXDestroyPbuffer = (_glXDestroyPbuffer) gl.resolve("glXDestroyPbuffer"); - qt_glXGetFBConfigAttrib = (_glXGetFBConfigAttrib) gl.resolve("glXGetFBConfigAttrib"); - qt_glXMakeContextCurrent = (_glXMakeContextCurrent) gl.resolve("glXMakeContextCurrent"); -#endif - } + qt_glXChooseFBConfig = (_glXChooseFBConfig) qglx_getProcAddress("glXChooseFBConfig"); + qt_glXCreateNewContext = (_glXCreateNewContext) qglx_getProcAddress("glXCreateNewContext"); + qt_glXCreatePbuffer = (_glXCreatePbuffer) qglx_getProcAddress("glXCreatePbuffer"); + qt_glXDestroyPbuffer = (_glXDestroyPbuffer) qglx_getProcAddress("glXDestroyPbuffer"); + qt_glXGetFBConfigAttrib = (_glXGetFBConfigAttrib) qglx_getProcAddress("glXGetFBConfigAttrib"); + qt_glXMakeContextCurrent = (_glXMakeContextCurrent) qglx_getProcAddress("glXMakeContextCurrent"); resolved = qt_glXMakeContextCurrent ? true : false; return resolved; -- cgit v0.12 From c999065d5090a64192f96bed78c5224490409d6a Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 29 Sep 2009 09:50:07 +0200 Subject: Fix a bug in QPixmapCache when the cache is trimmed by QCache. There was a bug in QPixmapCache when QCache trims the content, some keys were not invalidated. The ifdef for WinCE (that i removed) was a wrong fix, it let the auto-test pass but it doesn't fix the bug. The approach here is to add a QPixmapCacheEntry that release the key it owns when QCache deletes it : we are now sure that nothing happen in our back. Reviewed-by:paul Reviewed-by:trond --- src/gui/image/qimage.h | 2 +- src/gui/image/qpixmap.h | 2 +- src/gui/image/qpixmap_raster_p.h | 2 +- src/gui/image/qpixmapcache.cpp | 66 +++++++++++++++------------- src/gui/image/qpixmapcache_p.h | 6 ++- tests/auto/qpixmapcache/tst_qpixmapcache.cpp | 22 +++++----- 6 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 89d7de5..1ac56a7 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -314,7 +314,7 @@ private: QImageData *d; friend class QRasterPixmapData; - friend class QDetachedPixmap; + friend class QPixmapCacheEntry; friend Q_GUI_EXPORT qint64 qt_image_id(const QImage &image); friend const QVector *qt_image_colortable(const QImage &image); diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index a891637..d11bd03 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -270,7 +270,7 @@ private: friend class QWidgetPrivate; friend class QRasterPaintEngine; friend class QRasterBuffer; - friend class QDetachedPixmap; + friend class QPixmapCacheEntry; #if !defined(QT_NO_DATASTREAM) friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &); #endif diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h index 2af2399..da0405e 100644 --- a/src/gui/image/qpixmap_raster_p.h +++ b/src/gui/image/qpixmap_raster_p.h @@ -88,7 +88,7 @@ protected: private: friend class QPixmap; friend class QBitmap; - friend class QDetachedPixmap; + friend class QPixmapCacheEntry; friend class QRasterPaintEngine; }; diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 8029977..f12d397 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -167,7 +167,7 @@ QPixmapCache::Key &QPixmapCache::Key::operator =(const Key &other) return *this; } -class QPMCache : public QObject, public QCache +class QPMCache : public QObject, public QCache { Q_OBJECT public: @@ -215,7 +215,7 @@ uint qHash(const QPixmapCache::Key &k) QPMCache::QPMCache() : QObject(0), - QCache(cache_limit * 1024), + QCache(cache_limit * 1024), keyArray(0), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false) { } @@ -238,7 +238,6 @@ void QPMCache::timerEvent(QTimerEvent *) { int mc = maxCost(); bool nt = totalCost() == ps; - QList keys = QCache::keys(); setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1); setMaxCost(mc); ps = totalCost(); @@ -252,10 +251,6 @@ void QPMCache::timerEvent(QTimerEvent *) ++it; } } - for (int i = 0; i < keys.size(); ++i) { - if (!contains(keys.at(i))) - releaseKey(keys.at(i)); - } if (!size()) { killTimer(theid); @@ -274,11 +269,10 @@ QPixmap *QPMCache::object(const QString &key) const const_cast(this)->cacheKeys.remove(key); return 0; } - QPixmap *ptr = QCache::object(cacheKey); + QPixmap *ptr = QCache::object(cacheKey); //We didn't find the pixmap in the cache, the key is not valid anymore if (!ptr) { const_cast(this)->cacheKeys.remove(key); - const_cast(this)->releaseKey(cacheKey); } return ptr; } @@ -286,7 +280,7 @@ QPixmap *QPMCache::object(const QString &key) const QPixmap *QPMCache::object(const QPixmapCache::Key &key) const { Q_ASSERT(key.d->isValid); - QPixmap *ptr = QCache::object(key); + QPixmap *ptr = QCache::object(key); //We didn't find the pixmap in the cache, the key is not valid anymore if (!ptr) const_cast(this)->releaseKey(key); @@ -299,13 +293,14 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) QPixmapCache::Key oldCacheKey = cacheKeys.value(key); //If for the same key we add already a pixmap we should delete it if (oldCacheKey.d) { - QCache::remove(oldCacheKey); - cacheKey = oldCacheKey; - } else { - cacheKey = createKey(); - } + QCache::remove(oldCacheKey); + cacheKeys.remove(key); + } + + //we create a new key the old one has been removed + cacheKey = createKey(); - bool success = QCache::insert(cacheKey, new QDetachedPixmap(pixmap), cost); + bool success = QCache::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { cacheKeys.insert(key, cacheKey); if (!theid) { @@ -322,7 +317,7 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) { QPixmapCache::Key cacheKey = createKey(); - bool success = QCache::insert(cacheKey, new QDetachedPixmap(pixmap), cost); + bool success = QCache::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { if (!theid) { theid = startTimer(30000); @@ -338,13 +333,21 @@ QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int cost) { Q_ASSERT(key.d->isValid); - //If for the same key we add already a pixmap we should delete it - QCache::remove(key); + //If for the same key we had already an entry so we should delete the pixmap and use the new one + QCache::remove(key); + + QPixmapCache::Key cacheKey = createKey(); - bool success = QCache::insert(key, new QDetachedPixmap(pixmap), cost); - if (success && !theid) { - theid = startTimer(30000); - t = false; + bool success = QCache::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); + if (success) { + if(!theid) { + theid = startTimer(30000); + t = false; + } + const_cast(key) = cacheKey; + } else { + //Insertion failed we released the key + releaseKey(cacheKey); } return success; } @@ -356,16 +359,12 @@ bool QPMCache::remove(const QString &key) if (!cacheKey.d) return false; cacheKeys.remove(key); - releaseKey(cacheKey); - return QCache::remove(cacheKey); + return QCache::remove(cacheKey); } bool QPMCache::remove(const QPixmapCache::Key &key) { - bool result = QCache::remove(key); - //We release the key after we removed it from the cache - releaseKey(key); - return result; + return QCache::remove(key); } void QPMCache::resizeKeyArray(int size) @@ -409,10 +408,10 @@ void QPMCache::clear() freeKey = 0; keyArraySize = 0; //Mark all keys as invalid - QList keys = QCache::keys(); + QList keys = QCache::keys(); for (int i = 0; i < keys.size(); ++i) keys.at(i).d->isValid = false; - QCache::clear(); + QCache::clear(); } QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key) @@ -424,6 +423,11 @@ QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key) Q_GLOBAL_STATIC(QPMCache, pm_cache) +QPixmapCacheEntry::~QPixmapCacheEntry() +{ + pm_cache()->releaseKey(key); +} + /*! \obsolete \overload diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 33f93bc..84e4a03 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -76,10 +76,10 @@ public: }; // XXX: hw: is this a general concept we need to abstract? -class QDetachedPixmap : public QPixmap +class QPixmapCacheEntry : public QPixmap { public: - QDetachedPixmap(const QPixmap &pix) : QPixmap(pix) + QPixmapCacheEntry(const QPixmapCache::Key &key, const QPixmap &pix) : QPixmap(pix), key(key) { if (data && data->classId() == QPixmapData::RasterClass) { QRasterPixmapData *d = static_cast(data.data()); @@ -91,6 +91,8 @@ public: } } } + ~QPixmapCacheEntry(); + QPixmapCache::Key key; }; QT_END_NAMESPACE diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp index 6d262ba..b487d74 100644 --- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp @@ -171,7 +171,7 @@ void tst_QPixmapCache::setCacheLimit() QPixmapCache::setCacheLimit(0); QPixmapCache::setCacheLimit(1000); QPixmapCache::Key key2 = QPixmapCache::insert(*p1); - QCOMPARE(getPrivate(key2)->key, 2); + QCOMPARE(getPrivate(key2)->key, 1); QVERIFY(QPixmapCache::find(key, &p2) == 0); QVERIFY(QPixmapCache::find(key2, &p2) != 0); QCOMPARE(p2, *p1); @@ -200,7 +200,7 @@ void tst_QPixmapCache::find() { QPixmap p1(10, 10); p1.fill(Qt::red); - QPixmapCache::insert("P1", p1); + QVERIFY(QPixmapCache::insert("P1", p1)); QPixmap p2; QVERIFY(QPixmapCache::find("P1", p2)); @@ -222,13 +222,13 @@ void tst_QPixmapCache::find() QCOMPARE(p1, p2); QPixmapCache::clear(); + QPixmapCache::setCacheLimit(128); key = QPixmapCache::insert(p1); //The int part of the API - // make sure it doesn't explode QList keys; - for (int i = 0; i < 40000; ++i) + for (int i = 0; i < 4000; ++i) QPixmapCache::insert(p1); //at that time the first key has been erase because no more place in the cache @@ -293,8 +293,6 @@ void tst_QPixmapCache::insert() estimatedNum = (1024 * QPixmapCache::cacheLimit()) / ((p1.width() * p1.height() * p1.depth()) / 8); QVERIFY(num <= estimatedNum); - QPixmapCache::insert(p3); - } void tst_QPixmapCache::replace() @@ -307,13 +305,16 @@ void tst_QPixmapCache::replace() p2.fill(Qt::yellow); QPixmapCache::Key key = QPixmapCache::insert(p1); + QCOMPARE(getPrivate(key)->isValid, true); QPixmap p3; QVERIFY(QPixmapCache::find(key, &p3) == 1); - QPixmapCache::replace(key,p2); + QPixmapCache::replace(key, p2); QVERIFY(QPixmapCache::find(key, &p3) == 1); + QCOMPARE(getPrivate(key)->isValid, true); + QCOMPARE(getPrivate(key)->key, 1); QCOMPARE(p3.width(), 10); QCOMPARE(p3.height(), 10); @@ -392,11 +393,8 @@ void tst_QPixmapCache::clear() QPixmap p1(10, 10); p1.fill(Qt::red); -#ifdef Q_OS_WINCE - const int numberOfKeys = 10000; -#else - const int numberOfKeys = 20000; -#endif + const int numberOfKeys = 40000; + for (int i = 0; i < numberOfKeys; ++i) QVERIFY(QPixmapCache::find("x" + QString::number(i)) == 0); -- cgit v0.12 From 6dded946799bc9c5ff38a3f51495079b059c8180 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Tue, 29 Sep 2009 10:20:22 +0200 Subject: Update docs for softkeys to match new API and implementation. These docs were outdated and referred to API that no longer exists so we refresh them with some updated info. Reviewed-by: Sami Merila --- src/gui/kernel/qwidget.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 2397793..08fe5b9 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -900,28 +900,30 @@ void QWidget::setAutoFillBackground(bool enabled) \sa QEvent, QPainter, QGridLayout, QBoxLayout - \section1 SoftKeys + \section1 Softkeys \since 4.6 - \preliminary - Softkeys API is a platform independent way of mapping actions to (hardware)keys - and toolbars provided by the underlying platform. + Softkeys are usually physical keys on a device that have a corresponding label or + other visual representation on the screen that is generally located next to its + physical counterpart. They are most often found on mobile phone platforms. In + modern touch based user interfaces it is also possible to have softkeys that do + not correspond to any physical keys. Softkeys differ from other onscreen labels + in that they are contextual. - There are three major use cases supported. First one is a mobile device - with keypad navigation and no touch ui. Second use case is a mobile - device with touch ui. Third use case is desktop. For now the softkey API is - only implemented for Series60. + In Qt, contextual softkeys are added to a widget by calling addAction() and + passing a \c QAction with a softkey role set on it. When the widget + containing the softkey actions has focus, its softkeys should appear in + the user interface. Softkeys are discovered by traversing the widget + heirarchy so it is possible to define a single set of softkeys that are + present at all times by calling addAction() for a given top level widget. - QActions are set to widget(s) via softkey API. Actions in focused widget are - mapped to native toolbar or hardware keys. Even though the API allows to set - any amount of widgets there might be physical restrictions to amount of - softkeys that can be used by the device. + On some platforms, this concept overlaps with \c QMenuBar such that if no + other softkeys are found and the top level widget is a QMainWindow containing + a QMenuBar, the menubar actions may appear on one of the softkeys. - \e Series60: For series60 menu button is automatically mapped to left - soft key if there is QMainWindow with QMenuBar in widgets parent hierarchy. + Note: Currently softkeys are only supported on the Symbian Platform. - \sa softKeys() - \sa setSoftKey() + \sa addAction, QAction, QMenuBar */ -- cgit v0.12 From f3d17ff4ca511175817d202d71fee266b72cb815 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 29 Sep 2009 10:36:03 +0200 Subject: fix solaris build "A class with a reference member must have a user-defined constructor." --- tools/linguist/lupdate/cpp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index ed41edb..7a616e3 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1031,6 +1031,10 @@ QStringList CppParser::stringListifySegments(const QList &segments) } struct QualifyOneData { + QualifyOneData(const NamespaceList &ns, int nsc, const HashString &seg, NamespaceList *rslvd) + : namespaces(ns), nsCount(nsc), segment(seg), resolved(rslvd) + {} + const NamespaceList &namespaces; int nsCount; const HashString &segment; @@ -1069,7 +1073,7 @@ bool CppParser::qualifyOneCallbackUsing(const Namespace *ns, void *context) cons bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment, NamespaceList *resolved) const { - QualifyOneData data = { namespaces, nsCnt, segment, resolved, QSet() }; + QualifyOneData data(namespaces, nsCnt, segment, resolved); if (visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackOwn, &data)) return true; -- cgit v0.12 From c142149d720beda1374b7bc28dd46b5c7e944bea Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 29 Sep 2009 10:38:47 +0200 Subject: Doc: Snow Leopard is supported as a Tier 2 platform. Discussed in the program team - adding it as a Tier 1 platform is too ambitious. --- doc/src/platforms/supported-platforms.qdoc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/src/platforms/supported-platforms.qdoc b/doc/src/platforms/supported-platforms.qdoc index 61bd779..5f72ce3 100644 --- a/doc/src/platforms/supported-platforms.qdoc +++ b/doc/src/platforms/supported-platforms.qdoc @@ -104,6 +104,12 @@ \table \header \o Platform \o Compilers + \omit + \row \o Windows 7 + \o MSVC 2008 + \endomit + \row \o Apple Mac OS X 10.6 "Snow Leopard" + \o As provided by Apple \row \o Apple Mac OS X 10.4 "Tiger" \o As provided by Apple \row \o HPUXi 11.11 @@ -128,7 +134,7 @@ All platforms not specifically listed above are not supported by Nokia. Nokia does not run its unit test suite or perform any other internal tests on platforms not - listed above. Qt users should note, however, that there may be various open source + listed above. Qt users should note, however, that there may be various open source projects, community users and/or Qt partners who are able to provide assistance with platforms not supported by Nokia. -- cgit v0.12 From b351f83fd55250d2e2e4beb38fbb427e0a7c8258 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 29 Sep 2009 09:46:01 +0100 Subject: Updated TODO list --- src/3rdparty/phonon/mmf/TODO.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt index 2c13632..ba15897 100644 --- a/src/3rdparty/phonon/mmf/TODO.txt +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -3,8 +3,16 @@ TODO list for MMF Phonon backend The following items are in rough order of priority. +* Seeking does not work for video playback +Do we need to pause/stop the CVideoPlayerUtility before calling SetPositionL? This is inconsistent with CMdaAudioPlayerUtility, but may be necessary - needs to be tested on target. + +* Activating full-screen video playback in qmediaplayer causes the app to crash +This may be symptomatic of more general problems with re-sizing / re-positioning video while playing. + * Implement audio effects +* Support for playing "file:" URLs + * 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 -- cgit v0.12 From e6fe0607cc213e29cb83d4c26550f196cb1c5129 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 29 Sep 2009 10:48:15 +0200 Subject: Mac: Fix build failure on tiger I had to add inn some constants for dealing with pixel smooth scolling on mac when building on Tiger. This is done according to: http://developer.apple.com/legacy/mac/library/qa/qa2005/qa1453.html RevBy:prasanth --- src/gui/kernel/qapplication_mac.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index a656c7f..c294e62 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -960,7 +960,18 @@ struct QMacAppleEventTypeSpec { { kCoreEventClass, kAEQuitApplication }, { kCoreEventClass, kAEOpenDocuments } }; + #ifndef QT_MAC_USE_COCOA + +#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5) +enum +{ + kEventMouseScroll = 11, + kEventParamMouseWheelSmoothVerticalDelta = 'saxy', + kEventParamMouseWheelSmoothHorizontalDelta = 'saxx', +}; +#endif + /* watched events */ static EventTypeSpec app_events[] = { { kEventClassQt, kEventQtRequestWindowChange }, -- cgit v0.12 From 777c02085e0f30d0dceb57a9ac96a44999b4a028 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 29 Sep 2009 10:38:33 +0200 Subject: HTTP backend: store the date header in the cached resource we need the date header to calculate the age of the page, although this increases disk usage when using a QNetworkDiskCache. A solution to reduce the disk access of QNetworkDiskCache will be considered for a later version of Qt. Reviewed-by: Markus Goetz Reviewed-by: Aleksandar Sasha Babic --- src/network/access/qnetworkaccesshttpbackend.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index c068f55..bfcc299 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -951,11 +951,14 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo if (hop_by_hop) continue; - // Do not copy over the Date header because it will be - // different for every request and therefore cause a re-write to - // the disk when a 304 is received inside replyHeaderChanged() - if (header == "date") - continue; + // for 4.6.0, we were planning to not store the date header in the + // cached resource; through that we planned to reduce the number + // of writes to disk when using a QNetworkDiskCache (i.e. don't + // write to disk when only the date changes). + // However, without the date we cannot calculate the age of the page + // anymore. Consider a proper fix of that problem for 4.6.1. + //if (header == "date") + //continue; // Don't store Warning 1xx headers if (header == "warning") { -- cgit v0.12 From e9d63b7824e9105074dee9ad624582e5894d9c8b Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 28 Sep 2009 16:13:19 +0200 Subject: QGraphicsItem: cached embedded widget item is not repainted when widget is updated When calling QGraphicsItem::update() on a cached item, the cache is meant to be invalidated. In the reported bug, the user had a fixed scene rect set for his scene, and removing an item caused the entire scene to be updated (marked as "all needs to be updated"). In this case, calling update() on the cached item did not cause the item's cache to be invalidated. The item's new appearance didn't show up until the next invalidation, which was the same call to update(), but this time without a preceeding full scene update. The fix is to always invalidate the cache, regardless. But only schedule a repaint of the item in some cases (e.g., in this case the whole scene was marked for update, in which case it's unnessary for this one item to schedule a repaint of itself). It's worth noting that in 4.6, removing an item be delete does not cause the whole scene to be updated, and because of that this error was not exposed. It's there nevertheless. Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 26 +++++++++------------ tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 31 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 5799fe7..4f77aa8 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3975,26 +3975,20 @@ void QGraphicsItem::update(const QRectF &rect) return; if (CacheMode(d_ptr->cacheMode) != NoCache) { + // Invalidate cache. QGraphicsItemCache *cache = d_ptr->extraItemCache(); - if (d_ptr->discardUpdateRequest(/* ignoreVisibleBit = */ false, - /* ignoreClipping = */ false, - /* ignoreDirtyBit = */ true)) { - return; + if (!cache->allExposed) { + if (rect.isNull()) { + cache->allExposed = true; + cache->exposed.clear(); + } else { + cache->exposed.append(rect); + } } + } - // Invalidate cache. - if (rect.isNull()) { - cache->allExposed = true; - cache->exposed.clear(); - } else { - cache->exposed.append(rect); - } - // Only invalidate cache; item is already dirty. - if (d_ptr->dirty) - return; - } else if (d_ptr->discardUpdateRequest()) { + if (d_ptr->discardUpdateRequest()) return; - } // Effectively the same as updateHelper(rect); if (rect.isNull()) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 391ccf8..55e9b34 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -56,6 +56,7 @@ #include #include #include +#include "../../shared/util.h" //TESTED_CLASS= //TESTED_FILES= @@ -230,6 +231,7 @@ private slots: void task240400_clickOnTextItem(); void task243707_addChildBeforeParent(); void task197802_childrenVisibility(); + void QTBUG_4233_updateCachedWithSceneRect(); }; void tst_QGraphicsItem::init() @@ -6454,5 +6456,34 @@ void tst_QGraphicsItem::deviceTransform() QCOMPARE(rect3->deviceTransform(deviceX).map(QPointF(50, 50)), mapResult3); } +void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() +{ + EventTester *tester = new EventTester; + tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); + + QGraphicsScene scene; + scene.addItem(tester); + scene.setSceneRect(-100, -100, 200, 200); // contains the tester item + + QGraphicsView view(&scene); + view.show(); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); + + QCOMPARE(tester->repaints, 1); + + scene.update(); // triggers "updateAll" optimization + qApp->processEvents(); + qApp->processEvents(); // in 4.6 only one processEvents is necessary + + QCOMPARE(tester->repaints, 1); + + scene.update(); // triggers "updateAll" optimization + tester->update(); + qApp->processEvents(); + qApp->processEvents(); // in 4.6 only one processEvents is necessary + + QCOMPARE(tester->repaints, 2); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From 36623ef3b5d3804de2ced689af2329c9ab81c265 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 29 Sep 2009 19:07:01 +1000 Subject: Remove mention of QtSW. Reviewed-by: Trust Me --- doc/src/platform-notes.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/platform-notes.qdoc b/doc/src/platform-notes.qdoc index 64749e7..dce7349 100644 --- a/doc/src/platform-notes.qdoc +++ b/doc/src/platform-notes.qdoc @@ -650,7 +650,7 @@ \section1 MIPSpro (IRIX) \bold{IRIX is an unsupported platform. See the \l{Supported Platforms} page - and Qt's Software's online \l{Platform Support Policy} page for details.} + and Qt's online \l{Platform Support Policy} page for details.} Qt 4.4.x requires MIPSpro version 7.4.2m. -- cgit v0.12 From d2459611fd3650d8c80a3ccafd9ec3d58457a888 Mon Sep 17 00:00:00 2001 From: Petri Kiiskinen Date: Tue, 29 Sep 2009 11:06:40 +0200 Subject: Add the -testability option to Qt applications. If this option is given, Qt will load a plugin called "qttestability" and run an initialisation function from it. This allows one to just install the plugin in a non-debug device in order to enable testing. Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcoreapplication.cpp | 3 ++- src/gui/kernel/qapplication.cpp | 24 ++++++++++++++++++++++++ src/gui/kernel/qapplication_p.h | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 61b9ee7..8a55bad 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2067,7 +2067,8 @@ QStringList QCoreApplication::arguments() ; else if (l1arg == "-style" || l1arg == "-session" || - l1arg == "-graphicssystem") + l1arg == "-graphicssystem" || + l1arg == "-testability") ++a; else stripped += arg; diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 2ad89a2..df5097b 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -97,6 +97,10 @@ #include "qapplication.h" +#ifndef QT_NO_LIBRARY +#include "qlibrary.h" +#endif + #ifdef Q_WS_WINCE #include "qdatetime.h" #include "qguifunctions_wince.h" @@ -457,6 +461,7 @@ bool QApplicationPrivate::animate_tooltip = false; bool QApplicationPrivate::fade_tooltip = false; bool QApplicationPrivate::animate_toolbox = false; bool QApplicationPrivate::widgetCount = false; +bool QApplicationPrivate::load_testability = false; #if defined(Q_WS_WIN) && !defined(Q_WS_WINCE) bool QApplicationPrivate::inSizeMove = false; #endif @@ -563,6 +568,8 @@ void QApplicationPrivate::process_cmdline() QApplication::setLayoutDirection(Qt::RightToLeft); } else if (qstrcmp(arg, "-widgetcount") == 0) { widgetCount = true; + } else if (qstrcmp(arg, "-testability") == 0) { + load_testability = true; } else if (arg == "-graphicssystem" && i < argc-1) { graphics_system_name = QString::fromLocal8Bit(argv[++i]); } else { @@ -765,6 +772,23 @@ void QApplicationPrivate::construct( extern void qt_gui_eval_init(uint); qt_gui_eval_init(application_type); #endif + +#ifndef QT_NO_LIBRARY + if(load_testability) { + QLibrary testLib(QLatin1String("qttestability")); + if (testLib.load()) { + typedef void (*TasInitialize)(void); + TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); + if (initFunction) { + initFunction(); + } else { + qCritical("Library qttestability resolve failed!"); + } + } else { + qCritical("Library qttestability load failed!"); + } + } +#endif } #if defined(Q_WS_X11) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index aec21fd..6036196 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -452,6 +452,7 @@ public: static bool fade_tooltip; static bool animate_toolbox; static bool widgetCount; // Coupled with -widgetcount switch + static bool load_testability; // Coupled with -testability switch #ifdef Q_WS_MAC static bool native_modal_dialog_active; #endif -- cgit v0.12 From aa65b608b96f0b41e96093e6eb26ccc0f301afc9 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 29 Sep 2009 19:13:30 +1000 Subject: Remove mentions of QtSW. Reviewed-by: Trust Me --- src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp | 4 ++-- src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp index d2bb124..8e4c581 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp @@ -136,7 +136,7 @@ void QWebPluginFactory::refreshPlugins() For example: \code - + @@ -149,7 +149,7 @@ void QWebPluginFactory::refreshPlugins() \row \o mimeType \o "application/x-pdf" \row \o url - \o "http://qtsoftware.com/document.pdf" + \o "http://www.example.com/document.pdf" \row \o argumentNames \o "showTableOfContents" "hideThumbnails" \row \o argumentVaues diff --git a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp index 82f5b6c..408630e 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp +++ b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/simple/main.cpp @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) QWidget *parent = 0; //! [Using QWebView] QWebView *view = new QWebView(parent); - view->load(QUrl("http://qtsoftware.com/")); + view->load(QUrl("http://qt.nokia.com/")); view->show(); //! [Using QWebView] return app.exec(); -- cgit v0.12 From f10dc46c0a0763df4e136bd4664b68e1a1388ad6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 29 Sep 2009 09:27:40 +0200 Subject: QScript: fix the way the js stack is advanced. It is possible to call QScriptEngine::pushContext before we start any evaluation. We need to change JSC so it doesn't always start at the beginning of the stack. Also fix QScriptContext::pushContext not to waste space between callframes. Reviewed-by: Kent Hansen --- .../javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp | 8 ++++++++ src/script/api/qscriptengine.cpp | 6 ++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp index bfb0307..4200023 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp @@ -885,13 +885,21 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObjec } Register* oldEnd = m_registerFile.end(); +#ifdef QT_BUILD_SCRIPT_LIB //with QtScript, we do not necesserly start from scratch + Register* newEnd = oldEnd + globalRegisterOffset + codeBlock->m_numCalleeRegisters; +#else Register* newEnd = m_registerFile.start() + globalRegisterOffset + codeBlock->m_numCalleeRegisters; +#endif if (!m_registerFile.grow(newEnd)) { *exception = createStackOverflowError(callFrame); return jsNull(); } +#ifdef QT_BUILD_SCRIPT_LIB //with QtScript, we do not necesserly start from scratch + CallFrame* newCallFrame = CallFrame::create(oldEnd + globalRegisterOffset); +#else CallFrame* newCallFrame = CallFrame::create(m_registerFile.start() + globalRegisterOffset); +#endif // a 0 codeBlock indicates a built-in caller newCallFrame->r(codeBlock->thisRegister()) = JSValue(thisObj); diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index b27d1be..ee25239 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2360,11 +2360,9 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV JSC::Register *oldEnd = interp->registerFile().end(); int argc = args.size() + 1; //add "this" JSC::Register *newEnd = oldEnd + argc + JSC::RegisterFile::CallFrameHeaderSize; - //Without + argc + JSC::RegisterFile::CallFrameHeaderSize, it crashes. - //It seems that JSC is not consistant with the way the callframe is crated - if (!interp->registerFile().grow(newEnd + argc + JSC::RegisterFile::CallFrameHeaderSize)) + if (!interp->registerFile().grow(newEnd)) return 0; //### Stack overflow - newCallFrame = JSC::CallFrame::create(newEnd); + newCallFrame = JSC::CallFrame::create(oldEnd); newCallFrame[0] = thisObject; int dst = 0; JSC::ArgList::const_iterator it; -- cgit v0.12 From d557d6e5dc73c88f9de26bf2e3dd2c6955400467 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 28 Sep 2009 19:08:00 +0200 Subject: doc: Describe the semantics of targetless state machine transitions --- doc/src/frameworks-technologies/statemachine.qdoc | 29 +++++++++++++++++++++++ src/corelib/statemachine/qabstracttransition.cpp | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/doc/src/frameworks-technologies/statemachine.qdoc b/doc/src/frameworks-technologies/statemachine.qdoc index 2b137dd..ed8bc85 100644 --- a/doc/src/frameworks-technologies/statemachine.qdoc +++ b/doc/src/frameworks-technologies/statemachine.qdoc @@ -304,6 +304,35 @@ For parallel state groups, the QState::finished() signal is emitted when \e all the child states have entered final states. + \section1 Targetless Transitions + + A transition need not have a target state. A transition without a target can + be triggered the same way as any other transition; the difference is that + when a targetless transition is triggered, it doesn't cause any state + changes. This allows you to react to a signal or event when your machine is + in a certain state, without having to leave that state. Example: + + \code + QStateMachine machine; + QState *s1 = new QState(&machine); + + QPushButton button; + QSignalTransition *trans = new QSignalTransition(&button, SIGNAL(clicked())); + s1->addTransition(trans); + + QMessageBox msgBox; + msgBox.setText("The button was clicked; carry on."); + QObject::connect(trans, SIGNAL(triggered()), &msgBox, SLOT(exec())); + + machine.setInitialState(s1); + \endcode + + The message box will be displayed each time the button is clicked, but the + state machine will remain in its current state (s1). If the target state + were explicitly set to s1, however, s1 would be exited and re-entered each + time (e.g. the QAbstractState::entered() and QAbstractState::exited() + signals would be emitted). + \section1 Events, Transitions and Guards A QStateMachine runs its own event loop. For signal transitions diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp index 8b858c7..76baa0a 100644 --- a/src/corelib/statemachine/qabstracttransition.cpp +++ b/src/corelib/statemachine/qabstracttransition.cpp @@ -93,6 +93,10 @@ QT_BEGIN_NAMESPACE \property QAbstractTransition::targetState \brief the target state of this transition + + If a transition has no target state, the transition may still be + triggered, but this will not cause the state machine's configuration to + change (i.e. the current state will not be exited and re-entered). */ /*! -- cgit v0.12 From 39604894946c3c0d623c0073ccf027a8e6df120a Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 29 Sep 2009 11:59:01 +0200 Subject: Do synchronous processing of events in state machine if possible Avoid delayed scheduling in the cases where there's no need to delay it (e.g. when the state machine intercepts a signal or event). Task-number: QTBUG-4491 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/statemachine/qstatemachine.cpp | 46 +++++++++++++++++++------- src/corelib/statemachine/qstatemachine_p.h | 7 +++- tests/auto/qstatemachine/tst_qstatemachine.cpp | 33 ++++++++++++++++++ 3 files changed, 73 insertions(+), 13 deletions(-) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 503eec0..8d50870c 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -804,6 +804,14 @@ void QStateMachinePrivate::applyProperties(const QList &tr } if (hasValidEndValue) { + if (anim->state() == QAbstractAnimation::Running) { + // The animation is still running. This can happen if the + // animation is a group, and one of its children just finished, + // and that caused a state to emit its polished() signal, and + // that triggered a transition in the machine. + // Just stop the animation so it is correctly restarted again. + anim->stop(); + } anim->start(); } } @@ -1268,12 +1276,19 @@ void QStateMachinePrivate::_q_process() } } -void QStateMachinePrivate::scheduleProcess() +void QStateMachinePrivate::processEvents(EventProcessingMode processingMode) { if ((state != Running) || processing || processingScheduled) return; - processingScheduled = true; - QMetaObject::invokeMethod(q_func(), "_q_process", Qt::QueuedConnection); + switch (processingMode) { + case DirectProcessing: + _q_process(); + break; + case QueuedProcessing: + processingScheduled = true; + QMetaObject::invokeMethod(q_func(), "_q_process", Qt::QueuedConnection); + break; + } } namespace { @@ -1335,7 +1350,7 @@ void QStateMachinePrivate::goToState(QAbstractState *targetState) trans->setTargetState(targetState); } - scheduleProcess(); + processEvents(QueuedProcessing); } void QStateMachinePrivate::registerTransitions(QAbstractState *state) @@ -1512,6 +1527,15 @@ void QStateMachinePrivate::unregisterEventTransition(QEventTransition *transitio } QEventTransitionPrivate::get(transition)->registered = false; } + +void QStateMachinePrivate::handleFilteredEvent(QObject *watched, QEvent *event) +{ + Q_ASSERT(qobjectEvents.contains(watched)); + if (qobjectEvents[watched].contains(event->type())) { + internalEventQueue.append(new QStateMachine::WrappedEvent(watched, handler->cloneEvent(event))); + processEvents(DirectProcessing); + } +} #endif void QStateMachinePrivate::handleTransitionSignal(QObject *sender, int signalIndex, @@ -1533,7 +1557,7 @@ void QStateMachinePrivate::handleTransitionSignal(QObject *sender, int signalInd << ", signal =" << sender->metaObject()->method(signalIndex).signature() << ')'; #endif internalEventQueue.append(new QStateMachine::SignalEvent(sender, signalIndex, vargs)); - scheduleProcess(); + processEvents(DirectProcessing); } /*! @@ -1768,7 +1792,7 @@ void QStateMachine::stop() break; case QStateMachinePrivate::Running: d->stop = true; - d->scheduleProcess(); + d->processEvents(QStateMachinePrivate::QueuedProcessing); break; } } @@ -1798,7 +1822,7 @@ void QStateMachine::postEvent(QEvent *event, int delay) d->delayedEvents[tid] = event; } else { d->externalEventQueue.append(event); - d->scheduleProcess(); + d->processEvents(QStateMachinePrivate::QueuedProcessing); } } @@ -1814,7 +1838,7 @@ void QStateMachine::postInternalEvent(QEvent *event) qDebug() << this << ": posting internal event" << event; #endif d->internalEventQueue.append(event); - d->scheduleProcess(); + d->processEvents(QStateMachinePrivate::QueuedProcessing); } /*! @@ -1862,7 +1886,7 @@ bool QStateMachine::event(QEvent *e) killTimer(tid); QEvent *ee = d->delayedEvents.take(tid); d->externalEventQueue.append(ee); - d->scheduleProcess(); + d->processEvents(QStateMachinePrivate::DirectProcessing); return true; } } @@ -1876,9 +1900,7 @@ bool QStateMachine::event(QEvent *e) bool QStateMachine::eventFilter(QObject *watched, QEvent *event) { Q_D(QStateMachine); - Q_ASSERT(d->qobjectEvents.contains(watched)); - if (d->qobjectEvents[watched].contains(event->type())) - postEvent(new QStateMachine::WrappedEvent(watched, d->handler->cloneEvent(event))); + d->handleFilteredEvent(watched, event); return false; } #endif diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index a1b6de2..141bc5c 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -88,6 +88,10 @@ public: Starting, Running }; + enum EventProcessingMode { + DirectProcessing, + QueuedProcessing + }; enum StopProcessingReason { EventQueueEmpty, Finished, @@ -149,12 +153,13 @@ public: #ifndef QT_NO_STATEMACHINE_EVENTFILTER void registerEventTransition(QEventTransition *transition); void unregisterEventTransition(QEventTransition *transition); + void handleFilteredEvent(QObject *watched, QEvent *event); #endif void unregisterTransition(QAbstractTransition *transition); void unregisterAllTransitions(); void handleTransitionSignal(QObject *sender, int signalIndex, void **args); - void scheduleProcess(); + void processEvents(EventProcessingMode processingMode); #ifndef QT_NO_PROPERTIES typedef QPair RestorableId; diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 7244d72..37b34bf 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -176,6 +176,7 @@ private slots: void twoAnimatedTransitions(); void playAnimationTwice(); void nestedTargetStateForAnimation(); + void polishedSignalTransitionsReuseAnimationGroup(); void animatedGlobalRestoreProperty(); void specificTargetValueOfAnimation(); @@ -3115,6 +3116,38 @@ void tst_QStateMachine::nestedTargetStateForAnimation() QCOMPARE(counter.counter, 2); } +void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup() +{ + QStateMachine machine; + QObject *object = new QObject(&machine); + object->setProperty("foo", 0); + + QState *s1 = new QState(&machine); + s1->assignProperty(object, "foo", 123); + QState *s2 = new QState(&machine); + s2->assignProperty(object, "foo", 456); + QState *s3 = new QState(&machine); + s3->assignProperty(object, "foo", 789); + QFinalState *s4 = new QFinalState(&machine); + + QParallelAnimationGroup animationGroup; + animationGroup.addAnimation(new QPropertyAnimation(object, "foo")); + QSignalSpy animationFinishedSpy(&animationGroup, SIGNAL(finished())); + s1->addTransition(s1, SIGNAL(polished()), s2)->addAnimation(&animationGroup); + s2->addTransition(s2, SIGNAL(polished()), s3)->addAnimation(&animationGroup); + s3->addTransition(s3, SIGNAL(polished()), s4); + + machine.setInitialState(s1); + QSignalSpy machineFinishedSpy(&machine, SIGNAL(finished())); + machine.start(); + QTRY_COMPARE(machineFinishedSpy.count(), 1); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s4)); + QCOMPARE(object->property("foo").toInt(), 789); + + QCOMPARE(animationFinishedSpy.count(), 2); +} + void tst_QStateMachine::animatedGlobalRestoreProperty() { QStateMachine machine; -- cgit v0.12 From bb2babb04df0923d41614289623dc93cdfcf7109 Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 29 Sep 2009 11:08:58 +0100 Subject: Making tst_qParallelAnimationGroup work for Symbian The animation was not starting in time, as events from Symbian app start up had not had time to be flushed through. The addition of a 1s QTest::qWait gives plenty of time for the app to settle. Reviewed-by: Janne Anttila --- tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index a129f7f..acd23b0 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -379,6 +379,10 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() void tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup() { +#if defined(Q_OS_SYMBIAN) + // give the Symbian app start event queue time to clear + QTest::qWait(1000); +#endif // test if children can be activated when their group is stopped QParallelAnimationGroup group; -- cgit v0.12 From 8fd5e112b6e6a936b85cceb892f2a64b6edd2137 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Tue, 29 Sep 2009 10:46:39 +0200 Subject: Minor fixes in webkit's documentation Reviewed-by: Jedrzej Nowacki --- .../WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp index f04cd29..069bea2 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp +++ b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp @@ -13,22 +13,22 @@ void wrapInFunction() //! [2] - view->triggerAction(QWebPage::Copy); + view->triggerPageAction(QWebPage::Copy); //! [2] //! [3] - view->page()->triggerPageAction(QWebPage::Stop); + view->page()->triggerAction(QWebPage::Stop); //! [3] //! [4] - view->page()->triggerPageAction(QWebPage::GoBack); + view->page()->triggerAction(QWebPage::GoBack); //! [4] //! [5] - view->page()->triggerPageAction(QWebPage::GoForward); + view->page()->triggerAction(QWebPage::GoForward); //! [5] } -- cgit v0.12 From 235123199001f64d3bb3e2b628e91d75c54c4657 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 29 Sep 2009 12:30:38 +0200 Subject: Enable QtScript by default JavaScriptCore should build on Tier 1 and Tier 2 platforms now. Reviewed-by: Simon Hausmann --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 6a4b079..f89da70 100755 --- a/configure +++ b/configure @@ -6383,7 +6383,7 @@ else fi if [ "$CFG_SCRIPT" = "auto" ]; then - CFG_SCRIPT="$canBuildWebKit" + CFG_SCRIPT="yes" fi if [ "$CFG_SCRIPT" = "yes" ]; then -- cgit v0.12 From f234e50f3d29c4a7dfefd89d537787b1fc327eb2 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 29 Sep 2009 12:33:06 +0200 Subject: Update mkdist-webkit script to use latest tag Reviewed-by: Simon Hausmann --- util/webkit/mkdist-webkit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index 74a4f65..b1efe91 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -5,7 +5,7 @@ die() { exit 1 } -default_tag="qtwebkit-4.6-snapshot-24092009" +default_tag="qtwebkit-4.6-snapshot-29092009-2" if [ $# -eq 0 ]; then tag="$default_tag" -- cgit v0.12 From 9a7ca912ce72476bda57f2306b38e5f6e928fbf5 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Tue, 29 Sep 2009 13:41:33 +0300 Subject: Softkey fixes to QMenu tests. Softkeys add two extra "Select" and "Back" actions to menu by default. First two actions in menu will be "Select" and "Back". Reviewed-by: Janne Anttila --- tests/auto/qactiongroup/tst_qactiongroup.cpp | 14 ++++++++--- tests/auto/qmainwindow/tst_qmainwindow.cpp | 35 +++++++++++++++++----------- tests/auto/qmenu/tst_qmenu.cpp | 12 ++++++++-- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/tests/auto/qactiongroup/tst_qactiongroup.cpp b/tests/auto/qactiongroup/tst_qactiongroup.cpp index c290941..2d215a0 100644 --- a/tests/auto/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/qactiongroup/tst_qactiongroup.cpp @@ -226,6 +226,14 @@ void tst_QActionGroup::separators() mw.show(); +#ifdef QT_SOFTKEYS_ENABLED + // Softkeys add extra "Select" and "Back" actions to menu by default. + // Two first actions will be Select and Back when softkeys are enabled + int numSoftkeyActions = 2; +#else + int numSoftkeyActions = 0; +#endif + QAction *action = new QAction(&actGroup); action->setText("test one"); @@ -237,13 +245,13 @@ void tst_QActionGroup::separators() while (it.hasNext()) menu.addAction(it.next()); - QCOMPARE((int)menu.actions().size(), 2); + QCOMPARE((int)menu.actions().size(), 2 + numSoftkeyActions); it = QListIterator(actGroup.actions()); while (it.hasNext()) menu.removeAction(it.next()); - QCOMPARE((int)menu.actions().size(), 0); + QCOMPARE((int)menu.actions().size(), 0 + numSoftkeyActions); action = new QAction(&actGroup); action->setText("test two"); @@ -252,7 +260,7 @@ void tst_QActionGroup::separators() while (it.hasNext()) menu.addAction(it.next()); - QCOMPARE((int)menu.actions().size(), 3); + QCOMPARE((int)menu.actions().size(), 3 + numSoftkeyActions); } void tst_QActionGroup::testActionInTwoQActionGroup() diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp index 38d23b6..9615c63 100644 --- a/tests/auto/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp @@ -1297,18 +1297,27 @@ void tst_QMainWindow::createPopupMenu() mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget3); mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget4); + +#ifdef QT_SOFTKEYS_ENABLED + // Softkeys add extra "Select" and "Back" actions to menu by default. + // Two first actions will be Select and Back when softkeys are enabled + int numSoftkeyActions = 2; +#else + int numSoftkeyActions = 0; +#endif + QMenu *menu = mainwindow.createPopupMenu(); QVERIFY(menu != 0); QList actions = menu->actions(); - QCOMPARE(actions.size(), 7); + QCOMPARE(actions.size(), 7 + numSoftkeyActions); - QCOMPARE(actions.at(0), dockwidget1.toggleViewAction()); - QCOMPARE(actions.at(1), dockwidget2.toggleViewAction()); - QCOMPARE(actions.at(2), dockwidget3.toggleViewAction()); - QCOMPARE(actions.at(3), dockwidget4.toggleViewAction()); - QVERIFY(actions.at(4)->isSeparator()); - QCOMPARE(actions.at(5), toolbar1.toggleViewAction()); - QCOMPARE(actions.at(6), toolbar2.toggleViewAction()); + QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget1.toggleViewAction()); + QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget2.toggleViewAction()); + QCOMPARE(actions.at(2 + numSoftkeyActions), dockwidget3.toggleViewAction()); + QCOMPARE(actions.at(3 + numSoftkeyActions), dockwidget4.toggleViewAction()); + QVERIFY(actions.at(4 + numSoftkeyActions)->isSeparator()); + QCOMPARE(actions.at(5 + numSoftkeyActions), toolbar1.toggleViewAction()); + QCOMPARE(actions.at(6 + numSoftkeyActions), toolbar2.toggleViewAction()); delete menu; @@ -1319,12 +1328,12 @@ void tst_QMainWindow::createPopupMenu() menu = mainwindow.createPopupMenu(); QVERIFY(menu != 0); actions = menu->actions(); - QCOMPARE(actions.size(), 4); + QCOMPARE(actions.size(), 4 + numSoftkeyActions); - QCOMPARE(actions.at(0), dockwidget2.toggleViewAction()); - QCOMPARE(actions.at(1), dockwidget3.toggleViewAction()); - QVERIFY(actions.at(2)->isSeparator()); - QCOMPARE(actions.at(3), toolbar2.toggleViewAction()); + QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget2.toggleViewAction()); + QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget3.toggleViewAction()); + QVERIFY(actions.at(2 + numSoftkeyActions)->isSeparator()); + QCOMPARE(actions.at(3 + numSoftkeyActions), toolbar2.toggleViewAction()); delete menu; } diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index e467229..726ca55 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -260,9 +260,17 @@ void tst_QMenu::onStatusMessageChanged(const QString &s) void tst_QMenu::addActionsAndClear() { - QCOMPARE(menus[0]->actions().count(), 0); +#ifdef QT_SOFTKEYS_ENABLED + // Softkeys add extra "Select" and "Back" actions to menu by default. + // Two first actions will be Select and Back when softkeys are enabled + int numSoftkeyActions = 2; +#else + int numSoftkeyActions = 0; +#endif + + QCOMPARE(menus[0]->actions().count(), 0 + numSoftkeyActions); createActions(); - QCOMPARE(menus[0]->actions().count(), 8); + QCOMPARE(menus[0]->actions().count(), 8 + numSoftkeyActions); menus[0]->clear(); QCOMPARE(menus[0]->actions().count(), 0); } -- cgit v0.12 From bb917438a942da68e065a4810b29697a1340cdd6 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 29 Sep 2009 12:36:30 +0200 Subject: Updated WebKit from /home/joce/dev/qtwebkit/ to qtwebkit-4.6-snapshot-29092009-2 ( 999c28aa9f6ad9e0d6a26a794220e1cb45408a97 ) Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2009-09-28 HJK Reviewed by Simon Hausmann. Compile fix with namespaced Qt. * Api/qwebinspector_p.h: 2009-09-27 Joe Ligman Reviewed by Simon Hausmann. [Qt] Adding API setFocus and hasFocus to QWebElement. This API is needed for clients that want to check/set the focus node of the document. https://bugs.webkit.org/show_bug.cgi?id=29682 * Api/qwebelement.cpp: (QWebElement::hasFocus): (QWebElement::setFocus): * Api/qwebelement.h: * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::hasSetFocus): 2009-09-25 Csaba Osztrogonac Reviewed by Simon Hausmann. [Qt] Make tst_qwebframe work if Qt built without SSL support https://bugs.webkit.org/show_bug.cgi?id=29735 * tests/qwebframe/tst_qwebframe.cpp: Missing #ifndef blocks added. 2009-09-24 Jocelyn Turcotte Reviewed by Simon Hausmann. [Qt] Update QWebElement API to remove script related methods. QWebElement::evaluateScript is the only one kept, these are removed to postpone most of the QtWebKit<->JavaScript API design after 4.6. https://bugs.webkit.org/show_bug.cgi?id=29708 * Api/qwebelement.cpp: * Api/qwebelement.h: Methods removed: - QWebElement::callFunction - QWebElement::functions - QWebElement::scriptableProperty - QWebElement::setScriptableProperty - QWebElement::scriptableProperties * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::evaluateScript): 2009-09-25 Jocelyn Turcotte Reviewed by Simon Hausmann. [Qt] Rename QWebElement::evaluateScript to QWebElement::evaluateJavaScript. https://bugs.webkit.org/show_bug.cgi?id=29709 * Api/qwebelement.cpp: (QWebElement::evaluateJavaScript): * Api/qwebelement.h: * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::evaluateJavaScript): 2009-09-25 Jocelyn Turcotte Reviewed by Simon Hausmann. [Qt] Update the stypeProperty API of QWebElement. https://bugs.webkit.org/show_bug.cgi?id=29711 * Api/qwebelement.cpp: (QWebElement::styleProperty): - Merge the stypeProperty and the computedStyleProperty methods - Remove the default value for the style resolving enum - Rename ResolveRule to StyleResolveStrategy (QWebElement::setStyleProperty): - Remove the priority argument since it is possible to control the behaviour by adding !important or removing in the value. * Api/qwebelement.h: * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::style): (tst_QWebElement::computedStyle): * tests/qwebframe/tst_qwebframe.cpp: 2009-09-24 Jon Honeycutt Reviewed by Alice Liu. * Api/qwebpage.cpp: (QWebPagePrivate::QWebPagePrivate): Pass 0 for new Page constructor argument. --- src/3rdparty/webkit/ChangeLog | 6 + src/3rdparty/webkit/JavaScriptCore/ChangeLog | 249 ++++ .../webkit/JavaScriptCore/JavaScriptCore.pri | 14 +- .../JavaScriptCore/assembler/MacroAssemblerARM.cpp | 27 + .../JavaScriptCore/assembler/MacroAssemblerARM.h | 15 + .../JavaScriptCore/assembler/MacroAssemblerARMv7.h | 12 + .../assembler/MacroAssemblerX86Common.h | 10 + .../webkit/JavaScriptCore/interpreter/CachedCall.h | 2 +- .../webkit/JavaScriptCore/interpreter/CallFrame.h | 4 +- .../JavaScriptCore/interpreter/Interpreter.cpp | 14 +- .../JavaScriptCore/jit/ExecutableAllocator.h | 5 + src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp | 6 +- src/3rdparty/webkit/JavaScriptCore/jit/JIT.h | 11 +- .../webkit/JavaScriptCore/jit/JITArithmetic.cpp | 103 +- .../webkit/JavaScriptCore/jit/JITInlineMethods.h | 43 +- .../webkit/JavaScriptCore/jit/JITStubs.cpp | 6 +- src/3rdparty/webkit/JavaScriptCore/jsc.cpp | 41 +- .../JavaScriptCore/runtime/FunctionConstructor.cpp | 2 +- .../webkit/JavaScriptCore/runtime/JSArray.cpp | 22 - .../webkit/JavaScriptCore/runtime/JSArray.h | 5 - .../JavaScriptCore/runtime/JSGlobalObject.cpp | 2 +- .../webkit/JavaScriptCore/runtime/JSGlobalObject.h | 36 +- .../webkit/JavaScriptCore/runtime/JSObject.cpp | 5 - .../webkit/JavaScriptCore/runtime/JSObject.h | 2 - .../webkit/JavaScriptCore/runtime/MarkStack.h | 2 +- .../JavaScriptCore/runtime/MarkStackPosix.cpp | 22 - .../JavaScriptCore/runtime/MarkStackSymbian.cpp | 44 + .../webkit/JavaScriptCore/runtime/ScopeChain.cpp | 4 +- .../webkit/JavaScriptCore/runtime/ScopeChain.h | 17 +- .../JavaScriptCore/runtime/TimeoutChecker.cpp | 25 +- .../webkit/JavaScriptCore/wtf/FastMalloc.cpp | 6 +- .../webkit/JavaScriptCore/wtf/HashCountedSet.h | 24 +- src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h | 18 +- .../webkit/JavaScriptCore/wtf/TCSpinLock.h | 7 + .../JavaScriptCore/wtf/ThreadingPthreads.cpp | 2 +- .../webkit/JavaScriptCore/yarr/RegexJIT.cpp | 4 +- src/3rdparty/webkit/VERSION | 4 +- src/3rdparty/webkit/WebCore/ChangeLog | 1290 ++++++++++++++++++++ src/3rdparty/webkit/WebCore/WebCore.gypi | 65 + src/3rdparty/webkit/WebCore/WebCore.pro | 9 + .../webkit/WebCore/bindings/js/JSAttrCustom.cpp | 14 +- .../bindings/js/JSInspectorBackendCustom.cpp | 2 +- .../WebCore/bindings/js/JSNamedNodeMapCustom.cpp | 19 +- .../WebCore/bindings/scripts/CodeGeneratorV8.pm | 33 + src/3rdparty/webkit/WebCore/css/CSSImportRule.cpp | 5 +- .../webkit/WebCore/css/CSSSelectorList.cpp | 47 + src/3rdparty/webkit/WebCore/css/CSSSelectorList.h | 46 +- src/3rdparty/webkit/WebCore/css/CSSStyleSheet.cpp | 7 +- src/3rdparty/webkit/WebCore/css/CSSStyleSheet.h | 4 + src/3rdparty/webkit/WebCore/dom/Attr.idl | 3 +- src/3rdparty/webkit/WebCore/dom/Document.cpp | 20 +- src/3rdparty/webkit/WebCore/dom/Document.h | 2 +- src/3rdparty/webkit/WebCore/dom/Document.idl | 3 +- src/3rdparty/webkit/WebCore/dom/Element.cpp | 71 +- src/3rdparty/webkit/WebCore/dom/Element.h | 2 + src/3rdparty/webkit/WebCore/dom/Element.idl | 4 + src/3rdparty/webkit/WebCore/dom/EventTarget.h | 3 +- src/3rdparty/webkit/WebCore/dom/InputElement.cpp | 24 +- src/3rdparty/webkit/WebCore/dom/InputElement.h | 6 - src/3rdparty/webkit/WebCore/dom/NamedAttrMap.cpp | 21 +- src/3rdparty/webkit/WebCore/dom/NamedAttrMap.h | 4 +- src/3rdparty/webkit/WebCore/dom/NamedNodeMap.idl | 3 +- src/3rdparty/webkit/WebCore/dom/Node.cpp | 50 +- src/3rdparty/webkit/WebCore/dom/Range.cpp | 90 +- src/3rdparty/webkit/WebCore/dom/Range.h | 12 +- src/3rdparty/webkit/WebCore/dom/Range.idl | 7 + .../webkit/WebCore/dom/RegisteredEventListener.h | 3 +- src/3rdparty/webkit/WebCore/dom/Text.cpp | 13 +- .../editing/InsertParagraphSeparatorCommand.cpp | 64 +- .../editing/InsertParagraphSeparatorCommand.h | 2 + src/3rdparty/webkit/WebCore/generated/JSAttr.h | 6 + .../webkit/WebCore/generated/JSDocument.cpp | 4 +- .../webkit/WebCore/generated/JSElement.cpp | 19 +- src/3rdparty/webkit/WebCore/generated/JSElement.h | 1 + .../WebCore/generated/JSInspectorBackend.cpp | 16 +- .../webkit/WebCore/generated/JSInspectorBackend.h | 1 + .../webkit/WebCore/generated/JSNamedNodeMap.h | 4 +- src/3rdparty/webkit/WebCore/generated/JSRange.cpp | 36 +- src/3rdparty/webkit/WebCore/generated/JSRange.h | 2 + .../webkit/WebCore/html/HTMLFormControlElement.cpp | 40 + .../webkit/WebCore/html/HTMLFormControlElement.h | 22 + .../webkit/WebCore/html/HTMLInputElement.cpp | 22 +- .../webkit/WebCore/html/HTMLInputElement.h | 16 +- .../webkit/WebCore/html/HTMLIsIndexElement.cpp | 2 +- .../webkit/WebCore/html/HTMLTextAreaElement.cpp | 29 +- .../webkit/WebCore/html/HTMLTextAreaElement.h | 10 +- .../webkit/WebCore/inspector/InspectorBackend.cpp | 12 + .../webkit/WebCore/inspector/InspectorBackend.h | 1 + .../webkit/WebCore/inspector/InspectorBackend.idl | 1 + .../WebCore/inspector/InspectorController.cpp | 24 +- .../webkit/WebCore/inspector/InspectorController.h | 1 + .../webkit/WebCore/inspector/InspectorDOMAgent.cpp | 5 +- .../webkit/WebCore/inspector/InspectorDOMAgent.h | 2 +- .../inspector/InspectorDOMStorageResource.cpp | 4 +- .../webkit/WebCore/inspector/InspectorFrontend.cpp | 9 +- .../WebCore/inspector/JavaScriptDebugServer.cpp | 2 +- .../WebCore/inspector/front-end/ConsoleView.js | 9 +- .../WebCore/inspector/front-end/ElementsPanel.js | 20 +- .../WebCore/inspector/front-end/InjectedScript.js | 18 +- .../inspector/front-end/InjectedScriptAccess.js | 3 + .../inspector/front-end/ProfileDataGridTree.js | 5 +- .../WebCore/inspector/front-end/ResourceView.js | 27 +- .../WebCore/inspector/front-end/ResourcesPanel.js | 2 +- .../front-end/WatchExpressionsSidebarPane.js | 16 +- .../webkit/WebCore/inspector/front-end/WebKit.qrc | 3 + .../WebCore/inspector/front-end/inspector.css | 4 + src/3rdparty/webkit/WebCore/loader/EmptyClients.h | 7 + .../webkit/WebCore/loader/FTPDirectoryParser.cpp | 144 ++- src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp | 8 +- src/3rdparty/webkit/WebCore/page/DOMWindow.cpp | 114 +- src/3rdparty/webkit/WebCore/page/EventHandler.cpp | 20 +- src/3rdparty/webkit/WebCore/page/EventHandler.h | 2 + src/3rdparty/webkit/WebCore/page/HaltablePlugin.h | 44 + src/3rdparty/webkit/WebCore/page/Page.cpp | 34 +- src/3rdparty/webkit/WebCore/page/Page.h | 13 +- src/3rdparty/webkit/WebCore/page/PluginHalter.cpp | 112 ++ src/3rdparty/webkit/WebCore/page/PluginHalter.h | 59 + .../webkit/WebCore/page/PluginHalterClient.h | 42 + src/3rdparty/webkit/WebCore/page/Settings.cpp | 24 + src/3rdparty/webkit/WebCore/page/Settings.h | 12 + .../page/android/InspectorControllerAndroid.cpp | 1 + src/3rdparty/webkit/WebCore/platform/Pasteboard.h | 1 + .../webkit/WebCore/platform/PlatformWheelEvent.h | 9 + .../platform/android/TemporaryLinkStubs.cpp | 5 + .../WebCore/platform/graphics/GraphicsContext3D.h | 15 +- .../webkit/WebCore/platform/mac/PasteboardMac.mm | 22 +- .../webkit/WebCore/platform/qt/PasteboardQt.cpp | 12 + .../WebCore/platform/text/qt/TextCodecQt.cpp | 21 +- .../webkit/WebCore/rendering/RenderBox.cpp | 2 +- .../webkit/WebCore/rendering/RenderObject.h | 36 + .../webkit/WebCore/rendering/RenderTextControl.cpp | 4 +- .../webkit/WebCore/rendering/RenderTextControl.h | 2 +- .../rendering/RenderTextControlMultiLine.cpp | 5 +- .../WebCore/rendering/RenderTextControlMultiLine.h | 2 +- .../rendering/RenderTextControlSingleLine.cpp | 7 +- .../rendering/RenderTextControlSingleLine.h | 2 +- .../webkit/WebCore/storage/StorageAreaImpl.cpp | 5 + .../webkit/WebCore/storage/StorageAreaImpl.h | 4 +- .../webkit/WebCore/storage/StorageNamespace.h | 2 +- .../WebCore/storage/StorageNamespaceImpl.cpp | 7 +- .../webkit/WebCore/storage/StorageNamespaceImpl.h | 2 +- .../webkit/WebCore/svg/graphics/SVGImage.cpp | 3 +- .../webkit/WebCore/wml/WMLInputElement.cpp | 8 +- src/3rdparty/webkit/WebCore/wml/WMLInputElement.h | 3 - src/3rdparty/webkit/WebCore/xml/XMLHttpRequest.cpp | 10 +- src/3rdparty/webkit/WebKit/ChangeLog | 11 + src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp | 396 +----- src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h | 26 +- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 12 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 96 ++ .../qt/tests/qwebelement/tst_qwebelement.cpp | 163 +-- .../WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 15 +- 152 files changed, 3595 insertions(+), 1116 deletions(-) create mode 100644 src/3rdparty/webkit/JavaScriptCore/runtime/MarkStackSymbian.cpp create mode 100644 src/3rdparty/webkit/WebCore/page/HaltablePlugin.h create mode 100644 src/3rdparty/webkit/WebCore/page/PluginHalter.cpp create mode 100644 src/3rdparty/webkit/WebCore/page/PluginHalter.h create mode 100644 src/3rdparty/webkit/WebCore/page/PluginHalterClient.h diff --git a/src/3rdparty/webkit/ChangeLog b/src/3rdparty/webkit/ChangeLog index 9065b3a..e2c1ef5 100644 --- a/src/3rdparty/webkit/ChangeLog +++ b/src/3rdparty/webkit/ChangeLog @@ -1,3 +1,9 @@ +2009-09-26 David Kilzer + + GTK BUILD FIX: add ENABLE_ORIENTATION_EVENTS support to configure.ac + + * configure.ac: Added support for ENABLE_ORIENTATION_EVENTS. + 2009-09-23 Xan Lopez Reviewed by Gustavo Noronha. diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 4899919..f6a644a 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,252 @@ +2009-09-28 Joerg Bornemann + + Reviewed by Simon Hausmann. + + Add ARM version detection for Windows CE. + + * wtf/Platform.h: + +2009-09-26 Yongjun Zhang + + Reviewed by Simon Hausmann. + + Add MarkStackSymbian.cpp to build JavascriptCore for Symbian. + + Re-use Windows shrinkAllocation implementation because Symbian doesn't + support releasing part of memory region. + + Use fastMalloc and fastFree to implement allocateStack and releaseStack + for Symbian port. + + * JavaScriptCore.pri: + * runtime/MarkStack.h: + (JSC::MarkStack::MarkStackArray::shrinkAllocation): + * runtime/MarkStackSymbian.cpp: Added. + (JSC::MarkStack::initializePagesize): + (JSC::MarkStack::allocateStack): + (JSC::MarkStack::releaseStack): + +2009-09-25 Gabor Loki + + Reviewed by Gavin Barraclough. + + Fix unaligned data access in YARR_JIT on ARMv5 and below. + https://bugs.webkit.org/show_bug.cgi?id=29695 + + On ARMv5 and below all data access should be naturally aligned. + In the YARR_JIT there is a case when character pairs are + loaded from the input string, but this data access is not + naturally aligned. This fix introduces load32WithUnalignedHalfWords + and branch32WithUnalignedHalfWords functions which contain + naturally aligned memory loads - half word loads - on ARMv5 and below. + + * assembler/MacroAssemblerARM.cpp: + (JSC::MacroAssemblerARM::load32WithUnalignedHalfWords): + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::load32WithUnalignedHalfWords): + (JSC::MacroAssemblerARM::branch32WithUnalignedHalfWords): + * assembler/MacroAssemblerARMv7.h: + (JSC::MacroAssemblerARMv7::load32WithUnalignedHalfWords): + (JSC::MacroAssemblerARMv7::branch32): + (JSC::MacroAssemblerARMv7::branch32WithUnalignedHalfWords): + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::load32WithUnalignedHalfWords): + (JSC::MacroAssemblerX86Common::branch32WithUnalignedHalfWords): + * wtf/Platform.h: + * yarr/RegexJIT.cpp: + (JSC::Yarr::RegexGenerator::generatePatternCharacterPair): + +2009-09-25 Jeremy Orlow + + This is breaking Chromium try bots, so I'm counting this as a build fix. + + Add more svn:ignore exceptions. On different platforms, these files are + generated with different case for JavaScriptCore. Also there are some + wtf project files that get built apparently. + + * JavaScriptCore.gyp: Changed property svn:ignore. + +2009-09-25 Ada Chan + + Build fix. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-25 Geoffrey Garen + + Reviewed by Darin Adler. + + Inlined some object creation code, including lexicalGlobalObject access + https://bugs.webkit.org/show_bug.cgi?id=29750 + + SunSpider says 0.5% faster. + + 0.8% speedup on bench-alloc-nonretained.js. + 2.5% speedup on v8-splay.js. + + * interpreter/CachedCall.h: + (JSC::CachedCall::CachedCall): + * interpreter/CallFrame.h: + (JSC::ExecState::lexicalGlobalObject): + (JSC::ExecState::globalThisValue): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::dumpRegisters): + (JSC::Interpreter::execute): + (JSC::Interpreter::privateExecute): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * runtime/FunctionConstructor.cpp: + (JSC::constructFunction): + * runtime/ScopeChain.cpp: + (JSC::ScopeChainNode::print): + * runtime/ScopeChain.h: + (JSC::ScopeChainNode::ScopeChainNode): + (JSC::ScopeChainNode::~ScopeChainNode): + (JSC::ScopeChainNode::push): + (JSC::ScopeChain::ScopeChain): + (JSC::ScopeChain::globalObject): Added a globalObject data member to ScopeChainNode. + Replaced accessor function for globalObject() with data member. Replaced + globalThisObject() accessor with direct access to globalThis, to match. + + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::init): + * runtime/JSGlobalObject.h: Inlined array and object construction. + +2009-09-25 Laszlo Gombos + + Reviewed by Gavin Barraclough. + + Add ARM version detection rules for Symbian + https://bugs.webkit.org/show_bug.cgi?id=29715 + + * wtf/Platform.h: + +2009-09-24 Xan Lopez + + Reviewed by Mark "Do It!" Rowe. + + Some GCC versions don't like C++-style comments in preprocessor + directives, change to C-style to shut them up. + + * wtf/Platform.h: + +2009-09-24 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Division is needlessly slow in 64-bit + https://bugs.webkit.org/show_bug.cgi?id=29723 + + Add codegen for op_div on x86-64 + + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): + (JSC::JIT::privateCompileSlowCases): + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::compileBinaryArithOpSlowCase): + (JSC::JIT::emit_op_div): + (JSC::JIT::emitSlow_op_div): + * jit/JITInlineMethods.h: + (JSC::JIT::isOperandConstantImmediateDouble): + (JSC::JIT::addressFor): + (JSC::JIT::emitLoadDouble): + (JSC::JIT::emitLoadInt32ToDouble): + (JSC::JIT::emitJumpSlowCaseIfNotImmediateNumber): + +2009-09-24 Jeremy Orlow + + Reviewed by Dimitri Glazkov. + + Add GYP generated files to svn:ignore + https://bugs.webkit.org/show_bug.cgi?id=29724 + + Adding the following files to the svn:ignore list (all in the + JavaScriptCore/JavaScriptCore.gyp directory) + + JavaScriptCore.xcodeproj + JavaScriptCore.sln + JavaScriptCore.vcproj + JavaScriptCore_Debug.rules + JavaScriptCore_Release.rules + JavaScriptCore_Release - no tcmalloc.rules + JavaScriptCore_Purify.rules + JavaScriptCore.mk + JavaScriptCore_Debug_rules.mk + JavaScriptCore_Release_rules.mk + JavaScriptCore_Release - no tcmalloc_rules.mk + JavaScriptCore_Purify_rules.mk + JavaScriptCore.scons + JavaScriptCore_main.scons + + * JavaScriptCore.gyp: Changed property svn:ignore. + +2009-09-24 Yong Li + + Reviewed by Adam Barth. + + Replace platform-dependent code with WTF::currentTime() + https://bugs.webkit.org/show_bug.cgi?id=29148 + + * jsc.cpp: + (StopWatch::start): + (StopWatch::stop): + (StopWatch::getElapsedMS): + * runtime/TimeoutChecker.cpp: + (JSC::getCPUTime): + +2009-09-24 Mark Rowe + + Reviewed by Sam Weinig. + + FastMalloc scavenging thread should be named + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::scavengerThread): Set the thread name. + * wtf/Platform.h: Move the knowledge of whether pthread_setname_np exists to here as HAVE(PTHREAD_SETNAME_NP). + * wtf/ThreadingPthreads.cpp: + (WTF::setThreadNameInternal): Use HAVE(PTHREAD_SETNAME_NP). + +2009-09-24 Geoffrey Garen + + Reviewed by Sam Weinig. + + Renamed clear to removeAll, as suggested by Darin Adler. + + * wtf/HashCountedSet.h: + (WTF::::removeAll): + +2009-09-24 Mark Rowe + + Reviewed by Gavin Barraclough. + + Fix FastMalloc to build with assertions enabled. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_Central_FreeList::ReleaseToSpans): + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::IsHeld): + +2009-09-24 Geoffrey Garen + + Suggested by Darin Adler. + + Removed some unnecessary parameter names. + + * wtf/HashCountedSet.h: + +2009-09-24 Janne Koskinen + + Reviewed by Simon Hausmann. + + On Windows JSChar is typedef'ed to wchar_t. + + When building with WINSCW for Symbian we need to do the + same typedef. + + * API/JSStringRef.h: + 2009-09-23 Geoffrey Garen A piece of my last patch that I forgot. diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri index 7a815e3..73791e0 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri @@ -128,12 +128,16 @@ SOURCES += \ yarr/RegexJIT.cpp \ interpreter/RegisterFile.cpp -win32-*|wince* { - SOURCES += jit/ExecutableAllocatorWin.cpp \ - runtime/MarkStackWin.cpp +symbian { + SOURCES += runtime/MarkStackSymbian.cpp } else { - SOURCES += jit/ExecutableAllocatorPosix.cpp \ - runtime/MarkStackPosix.cpp + win32-*|wince* { + SOURCES += jit/ExecutableAllocatorWin.cpp \ + runtime/MarkStackWin.cpp + } else { + SOURCES += jit/ExecutableAllocatorPosix.cpp \ + runtime/MarkStackPosix.cpp + } } # AllInOneFile.cpp helps gcc analize and optimize code diff --git a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.cpp b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.cpp index 43648c4..d726ecd 100644 --- a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.cpp @@ -62,6 +62,33 @@ static bool isVFPPresent() const bool MacroAssemblerARM::s_isVFPPresent = isVFPPresent(); +#if defined(ARM_REQUIRE_NATURAL_ALIGNMENT) && ARM_REQUIRE_NATURAL_ALIGNMENT +void MacroAssemblerARM::load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest) +{ + ARMWord op2; + + ASSERT(address.scale >= 0 && address.scale <= 3); + op2 = m_assembler.lsl(address.index, static_cast(address.scale)); + + if (address.offset >= 0 && address.offset + 0x2 <= 0xff) { + m_assembler.add_r(ARMRegisters::S0, address.base, op2); + m_assembler.ldrh_u(dest, ARMRegisters::S0, ARMAssembler::getOp2Byte(address.offset)); + m_assembler.ldrh_u(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(address.offset + 0x2)); + } else if (address.offset < 0 && address.offset >= -0xff) { + m_assembler.add_r(ARMRegisters::S0, address.base, op2); + m_assembler.ldrh_d(dest, ARMRegisters::S0, ARMAssembler::getOp2Byte(-address.offset)); + m_assembler.ldrh_d(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(-address.offset - 0x2)); + } else { + m_assembler.ldr_un_imm(ARMRegisters::S0, address.offset); + m_assembler.add_r(ARMRegisters::S0, ARMRegisters::S0, op2); + m_assembler.ldrh_r(dest, address.base, ARMRegisters::S0); + m_assembler.add_r(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::OP2_IMM | 0x2); + m_assembler.ldrh_r(ARMRegisters::S0, address.base, ARMRegisters::S0); + } + m_assembler.orr_r(dest, dest, m_assembler.lsl(ARMRegisters::S0, 16)); +} +#endif + } #endif // ENABLE(ASSEMBLER) && PLATFORM(ARM_TRADITIONAL) diff --git a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.h b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.h index 0c696c9..aa8cbb0 100644 --- a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.h +++ b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARM.h @@ -198,6 +198,15 @@ public: m_assembler.baseIndexTransfer32(true, dest, address.base, address.index, static_cast(address.scale), address.offset); } +#if defined(ARM_REQUIRE_NATURAL_ALIGNMENT) && ARM_REQUIRE_NATURAL_ALIGNMENT + void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest); +#else + void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest) + { + load32(address, dest); + } +#endif + DataLabel32 load32WithAddressOffsetPatch(Address address, RegisterID dest) { DataLabel32 dataLabel(this); @@ -364,6 +373,12 @@ public: return branch32(cond, ARMRegisters::S1, right); } + Jump branch32WithUnalignedHalfWords(Condition cond, BaseIndex left, Imm32 right) + { + load32WithUnalignedHalfWords(left, ARMRegisters::S1); + return branch32(cond, ARMRegisters::S1, right); + } + Jump branch16(Condition cond, BaseIndex left, RegisterID right) { UNUSED_PARAM(cond); diff --git a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARMv7.h b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARMv7.h index 999056b..a549604 100644 --- a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARMv7.h +++ b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerARMv7.h @@ -375,6 +375,11 @@ public: load32(setupArmAddress(address), dest); } + void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest) + { + load32(setupArmAddress(address), dest); + } + void load32(void* address, RegisterID dest) { move(ImmPtr(address), addressTempRegister); @@ -717,6 +722,13 @@ public: return branch32(cond, addressTempRegister, right); } + Jump branch32WithUnalignedHalfWords(Condition cond, BaseIndex left, Imm32 right) + { + // use addressTempRegister incase the branch32 we call uses dataTempRegister. :-/ + load32WithUnalignedHalfWords(left, addressTempRegister); + return branch32(cond, addressTempRegister, right); + } + Jump branch32(Condition cond, AbsoluteAddress left, RegisterID right) { load32(left.m_ptr, dataTempRegister); diff --git a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerX86Common.h b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerX86Common.h index 61e0e17..5ebefa7 100644 --- a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerX86Common.h +++ b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerX86Common.h @@ -306,6 +306,11 @@ public: m_assembler.movl_mr(address.offset, address.base, address.index, address.scale, dest); } + void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest) + { + load32(address, dest); + } + DataLabel32 load32WithAddressOffsetPatch(Address address, RegisterID dest) { m_assembler.movl_mr_disp32(address.offset, address.base, dest); @@ -604,6 +609,11 @@ public: return Jump(m_assembler.jCC(x86Condition(cond))); } + Jump branch32WithUnalignedHalfWords(Condition cond, BaseIndex left, Imm32 right) + { + return branch32(cond, left, right); + } + Jump branch16(Condition cond, BaseIndex left, RegisterID right) { m_assembler.cmpw_rm(right, left.offset, left.base, left.index, left.scale); diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/CachedCall.h b/src/3rdparty/webkit/JavaScriptCore/interpreter/CachedCall.h index b9fa484..e903b79 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/CachedCall.h +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/CachedCall.h @@ -38,7 +38,7 @@ namespace JSC { : m_valid(false) , m_interpreter(callFrame->interpreter()) , m_exception(exception) - , m_globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : function->scope().node()->globalObject()) + , m_globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : function->scope().globalObject()) { ASSERT(!function->isHostFunction()); m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, function, argCount, function->scope().node(), exception); diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/CallFrame.h b/src/3rdparty/webkit/JavaScriptCore/interpreter/CallFrame.h index 92ec06e..b4d49db 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/CallFrame.h +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/CallFrame.h @@ -51,14 +51,14 @@ namespace JSC { // Differs from dynamicGlobalObject() during function calls across web browser frames. JSGlobalObject* lexicalGlobalObject() const { - return scopeChain()->globalObject(); + return scopeChain()->globalObject; } // Differs from lexicalGlobalObject because this will have DOM window shell rather than // the actual DOM window, which can't be "this" for security reasons. JSObject* globalThisValue() const { - return scopeChain()->globalThisObject(); + return scopeChain()->globalThis; } // FIXME: Elsewhere, we use JSGlobalData* rather than JSGlobalData&. diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp index 8a8fb3c..2aaa325 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp @@ -385,7 +385,7 @@ void Interpreter::dumpRegisters(CallFrame* callFrame) printf("-----------------------------------------------------------------------------\n"); CodeBlock* codeBlock = callFrame->codeBlock(); - RegisterFile* registerFile = &callFrame->scopeChain()->globalObject()->globalData()->interpreter->registerFile(); + RegisterFile* registerFile = &callFrame->scopeChain()->globalObject->globalData()->interpreter->registerFile(); const Register* it; const Register* end; JSValue v; @@ -629,7 +629,7 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, S return jsNull(); } - DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject()); + DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject); JSGlobalObject* lastGlobalObject = m_registerFile.globalObject(); JSGlobalObject* globalObject = callFrame->dynamicGlobalObject(); @@ -689,7 +689,7 @@ JSValue Interpreter::execute(FunctionExecutable* functionExecutable, CallFrame* return jsNull(); } - DynamicGlobalObjectScope globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : scopeChain->globalObject()); + DynamicGlobalObjectScope globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : scopeChain->globalObject); CallFrame* newCallFrame = CallFrame::create(oldEnd); size_t dst = 0; @@ -819,7 +819,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObjec } } - DynamicGlobalObjectScope globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : scopeChain->globalObject()); + DynamicGlobalObjectScope globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : scopeChain->globalObject); EvalCodeBlock* codeBlock = &eval->bytecode(callFrame, scopeChain); @@ -1242,7 +1242,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi */ int dst = (++vPC)->u.operand; int regExp = (++vPC)->u.operand; - callFrame->r(dst) = JSValue(new (globalData) RegExpObject(callFrame->scopeChain()->globalObject()->regExpStructure(), callFrame->codeBlock()->regexp(regExp))); + callFrame->r(dst) = JSValue(new (globalData) RegExpObject(callFrame->scopeChain()->globalObject->regExpStructure(), callFrame->codeBlock()->regexp(regExp))); ++vPC; NEXT_INSTRUCTION(); @@ -2981,7 +2981,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi Register* newCallFrame = callFrame->registers() + registerOffset; Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount; JSValue thisValue = argv[0].jsValue(); - JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject(); + JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject; if (thisValue == globalObject && funcVal == globalObject->evalFunction()) { JSValue result = callEval(callFrame, registerFile, argv, argCount, registerOffset, exceptionValue); @@ -3429,7 +3429,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi if (prototype.isObject()) structure = asObject(prototype)->inheritorID(); else - structure = callDataScopeChain->globalObject()->emptyObjectStructure(); + structure = callDataScopeChain->globalObject->emptyObjectStructure(); JSObject* newObject = new (globalData) JSObject(structure); callFrame->r(thisRegister) = JSValue(newObject); // "this" value diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/ExecutableAllocator.h b/src/3rdparty/webkit/JavaScriptCore/jit/ExecutableAllocator.h index 3274fcc..12e2a32 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/ExecutableAllocator.h +++ b/src/3rdparty/webkit/JavaScriptCore/jit/ExecutableAllocator.h @@ -191,6 +191,11 @@ public: { User::IMB_Range(code, static_cast(code) + size); } +#elif PLATFORM(ARM) && COMPILER(GCC) && (GCC_VERSION >= 30406) && !defined(DISABLE_BUILTIN_CLEAR_CACHE) + static void cacheFlush(void* code, size_t size) + { + __clear_cache(reinterpret_cast(code), reinterpret_cast(code) + size); + } #elif PLATFORM(ARM_TRADITIONAL) && PLATFORM(LINUX) static void cacheFlush(void* code, size_t size) { diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp index bf3a418..ea8434e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp @@ -195,7 +195,7 @@ void JIT::privateCompileMainPass() switch (m_interpreter->getOpcodeID(currentInstruction->u.opcode)) { DEFINE_BINARY_OP(op_del_by_val) -#if !USE(JSVALUE32_64) +#if USE(JSVALUE32) DEFINE_BINARY_OP(op_div) #endif DEFINE_BINARY_OP(op_in) @@ -230,7 +230,7 @@ void JIT::privateCompileMainPass() DEFINE_OP(op_create_arguments) DEFINE_OP(op_debug) DEFINE_OP(op_del_by_id) -#if USE(JSVALUE32_64) +#if !USE(JSVALUE32) DEFINE_OP(op_div) #endif DEFINE_OP(op_end) @@ -379,7 +379,7 @@ void JIT::privateCompileSlowCases() DEFINE_SLOWCASE_OP(op_construct) DEFINE_SLOWCASE_OP(op_construct_verify) DEFINE_SLOWCASE_OP(op_convert_this) -#if USE(JSVALUE32_64) +#if !USE(JSVALUE32) DEFINE_SLOWCASE_OP(op_div) #endif DEFINE_SLOWCASE_OP(op_eq) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JIT.h b/src/3rdparty/webkit/JavaScriptCore/jit/JIT.h index 5c58e9d..3b35935 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JIT.h +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JIT.h @@ -379,14 +379,18 @@ namespace JSC { enum CompileOpStrictEqType { OpStrictEq, OpNStrictEq }; void compileOpStrictEq(Instruction* instruction, CompileOpStrictEqType type); + bool isOperandConstantImmediateDouble(unsigned src); + + void emitLoadDouble(unsigned index, FPRegisterID value); + void emitLoadInt32ToDouble(unsigned index, FPRegisterID value); + + Address addressFor(unsigned index, RegisterID base = callFrameRegister); #if USE(JSVALUE32_64) Address tagFor(unsigned index, RegisterID base = callFrameRegister); Address payloadFor(unsigned index, RegisterID base = callFrameRegister); - Address addressFor(unsigned index, RegisterID base = callFrameRegister); bool getOperandConstantImmediateInt(unsigned op1, unsigned op2, unsigned& op, int32_t& constant); - bool isOperandConstantImmediateDouble(unsigned src); void emitLoadTag(unsigned index, RegisterID tag); void emitLoadPayload(unsigned index, RegisterID payload); @@ -394,8 +398,6 @@ namespace JSC { void emitLoad(const JSValue& v, RegisterID tag, RegisterID payload); void emitLoad(unsigned index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister); void emitLoad2(unsigned index1, RegisterID tag1, RegisterID payload1, unsigned index2, RegisterID tag2, RegisterID payload2); - void emitLoadDouble(unsigned index, FPRegisterID value); - void emitLoadInt32ToDouble(unsigned index, FPRegisterID value); void emitStore(unsigned index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister); void emitStore(unsigned index, const JSValue constant, RegisterID base = callFrameRegister); @@ -499,6 +501,7 @@ namespace JSC { JIT::Jump emitJumpIfNotImmediateInteger(RegisterID); JIT::Jump emitJumpIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID); void emitJumpSlowCaseIfNotImmediateInteger(RegisterID); + void emitJumpSlowCaseIfNotImmediateNumber(RegisterID); void emitJumpSlowCaseIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID); #if !USE(JSVALUE64) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITArithmetic.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITArithmetic.cpp index 3be13cb..fb44386 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITArithmetic.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITArithmetic.cpp @@ -1978,9 +1978,11 @@ void JIT::compileBinaryArithOpSlowCase(OpcodeID opcodeID, Vector: addDouble(fpRegT2, fpRegT1); else if (opcodeID == op_sub) subDouble(fpRegT2, fpRegT1); - else { - ASSERT(opcodeID == op_mul); + else if (opcodeID == op_mul) mulDouble(fpRegT2, fpRegT1); + else { + ASSERT(opcodeID == op_div); + divDouble(fpRegT2, fpRegT1); } moveDoubleToPtr(fpRegT1, regT0); subPtr(tagTypeNumberRegister, regT0); @@ -2082,6 +2084,103 @@ void JIT::emitSlow_op_mul(Instruction* currentInstruction, Vector compileBinaryArithOpSlowCase(op_mul, iter, result, op1, op2, types); } +void JIT::emit_op_div(Instruction* currentInstruction) +{ + unsigned dst = currentInstruction[1].u.operand; + unsigned op1 = currentInstruction[2].u.operand; + unsigned op2 = currentInstruction[3].u.operand; + OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand); + + if (isOperandConstantImmediateDouble(op1)) { + emitGetVirtualRegister(op1, regT0); + addPtr(tagTypeNumberRegister, regT0); + movePtrToDouble(regT0, fpRegT0); + } else if (isOperandConstantImmediateInt(op1)) { + emitLoadInt32ToDouble(op1, fpRegT0); + } else { + emitGetVirtualRegister(op1, regT0); + if (!types.first().definitelyIsNumber()) + emitJumpSlowCaseIfNotImmediateNumber(regT0); + Jump notInt = emitJumpIfNotImmediateInteger(regT0); + convertInt32ToDouble(regT0, fpRegT0); + Jump skipDoubleLoad = jump(); + notInt.link(this); + addPtr(tagTypeNumberRegister, regT0); + movePtrToDouble(regT0, fpRegT0); + skipDoubleLoad.link(this); + } + + if (isOperandConstantImmediateDouble(op2)) { + emitGetVirtualRegister(op2, regT1); + addPtr(tagTypeNumberRegister, regT1); + movePtrToDouble(regT1, fpRegT1); + } else if (isOperandConstantImmediateInt(op2)) { + emitLoadInt32ToDouble(op2, fpRegT1); + } else { + emitGetVirtualRegister(op2, regT1); + if (!types.second().definitelyIsNumber()) + emitJumpSlowCaseIfNotImmediateNumber(regT1); + Jump notInt = emitJumpIfNotImmediateInteger(regT1); + convertInt32ToDouble(regT1, fpRegT1); + Jump skipDoubleLoad = jump(); + notInt.link(this); + addPtr(tagTypeNumberRegister, regT1); + movePtrToDouble(regT1, fpRegT1); + skipDoubleLoad.link(this); + } + divDouble(fpRegT1, fpRegT0); + + JumpList doubleResult; + Jump end; + bool attemptIntConversion = (!isOperandConstantImmediateInt(op1) || getConstantOperand(op1).asInt32() > 1) && isOperandConstantImmediateInt(op2); + if (attemptIntConversion) { + m_assembler.cvttsd2si_rr(fpRegT0, regT0); + doubleResult.append(branchTest32(Zero, regT0)); + m_assembler.ucomisd_rr(fpRegT1, fpRegT0); + + doubleResult.append(m_assembler.jne()); + doubleResult.append(m_assembler.jp()); + emitFastArithIntToImmNoCheck(regT0, regT0); + end = jump(); + } + + // Double result. + doubleResult.link(this); + moveDoubleToPtr(fpRegT0, regT0); + subPtr(tagTypeNumberRegister, regT0); + + if (attemptIntConversion) + end.link(this); + emitPutVirtualRegister(dst, regT0); +} + +void JIT::emitSlow_op_div(Instruction* currentInstruction, Vector::iterator& iter) +{ + unsigned result = currentInstruction[1].u.operand; + unsigned op1 = currentInstruction[2].u.operand; + unsigned op2 = currentInstruction[3].u.operand; + OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand); + if (types.first().definitelyIsNumber() && types.second().definitelyIsNumber()) { +#ifndef NDEBUG + breakpoint(); +#endif + return; + } + if (!isOperandConstantImmediateDouble(op1) && !isOperandConstantImmediateInt(op1)) { + if (!types.first().definitelyIsNumber()) + linkSlowCase(iter); + } + if (!isOperandConstantImmediateDouble(op2) && !isOperandConstantImmediateInt(op2)) { + if (!types.second().definitelyIsNumber()) + linkSlowCase(iter); + } + // There is an extra slow case for (op1 * -N) or (-N * op2), to check for 0 since this should produce a result of -0. + JITStubCall stubCall(this, cti_op_div); + stubCall.addArgument(op1, regT2); + stubCall.addArgument(op2, regT2); + stubCall.call(result); +} + void JIT::emit_op_sub(Instruction* currentInstruction) { unsigned result = currentInstruction[1].u.operand; diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITInlineMethods.h b/src/3rdparty/webkit/JavaScriptCore/jit/JITInlineMethods.h index e69e273..f26457a 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITInlineMethods.h +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITInlineMethods.h @@ -65,6 +65,11 @@ ALWAYS_INLINE void JIT::emitGetJITStubArg(unsigned argumentNumber, RegisterID ds peek(dst, argumentStackOffset); } +ALWAYS_INLINE bool JIT::isOperandConstantImmediateDouble(unsigned src) +{ + return m_codeBlock->isConstantRegisterIndex(src) && getConstantOperand(src).isDouble(); +} + ALWAYS_INLINE JSValue JIT::getConstantOperand(unsigned src) { ASSERT(m_codeBlock->isConstantRegisterIndex(src)); @@ -305,6 +310,11 @@ ALWAYS_INLINE void JIT::sampleCodeBlock(CodeBlock* codeBlock) #endif #endif +inline JIT::Address JIT::addressFor(unsigned index, RegisterID base) +{ + return Address(base, (index * sizeof(Register))); +} + #if USE(JSVALUE32_64) inline JIT::Address JIT::tagFor(unsigned index, RegisterID base) @@ -317,11 +327,6 @@ inline JIT::Address JIT::payloadFor(unsigned index, RegisterID base) return Address(base, (index * sizeof(Register)) + OBJECT_OFFSETOF(JSValue, u.asBits.payload)); } -inline JIT::Address JIT::addressFor(unsigned index, RegisterID base) -{ - return Address(base, (index * sizeof(Register))); -} - inline void JIT::emitLoadTag(unsigned index, RegisterID tag) { RegisterID mappedTag; @@ -579,11 +584,6 @@ ALWAYS_INLINE bool JIT::getOperandConstantImmediateInt(unsigned op1, unsigned op return false; } -ALWAYS_INLINE bool JIT::isOperandConstantImmediateDouble(unsigned src) -{ - return m_codeBlock->isConstantRegisterIndex(src) && getConstantOperand(src).isDouble(); -} - /* Deprecated: Please use JITStubCall instead. */ ALWAYS_INLINE void JIT::emitPutJITStubArg(RegisterID tag, RegisterID payload, unsigned argumentNumber) @@ -732,6 +732,24 @@ ALWAYS_INLINE JIT::Jump JIT::emitJumpIfNotImmediateNumber(RegisterID reg) { return branchTestPtr(Zero, reg, tagTypeNumberRegister); } + +inline void JIT::emitLoadDouble(unsigned index, FPRegisterID value) +{ + if (m_codeBlock->isConstantRegisterIndex(index)) { + Register& inConstantPool = m_codeBlock->constantRegister(index); + loadDouble(&inConstantPool, value); + } else + loadDouble(addressFor(index), value); +} + +inline void JIT::emitLoadInt32ToDouble(unsigned index, FPRegisterID value) +{ + if (m_codeBlock->isConstantRegisterIndex(index)) { + Register& inConstantPool = m_codeBlock->constantRegister(index); + convertInt32ToDouble(AbsoluteAddress(&inConstantPool), value); + } else + convertInt32ToDouble(addressFor(index), value); +} #endif ALWAYS_INLINE JIT::Jump JIT::emitJumpIfImmediateInteger(RegisterID reg) @@ -769,6 +787,11 @@ ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotImmediateIntegers(RegisterID reg1, addSlowCase(emitJumpIfNotImmediateIntegers(reg1, reg2, scratch)); } +ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotImmediateNumber(RegisterID reg) +{ + addSlowCase(emitJumpIfNotImmediateNumber(reg)); +} + #if !USE(JSVALUE64) ALWAYS_INLINE void JIT::emitFastArithDeTagImmediate(RegisterID reg) { diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index 055a536..065b7ea 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -1182,7 +1182,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_method_check) // for now. For now it performs a check on a special object on the global object only used for this // purpose. The object is in no way exposed, and as such the check will always pass. if (slot.slotBase() == baseValue) { - JIT::patchMethodCallProto(codeBlock, methodCallLinkInfo, callee, structure, callFrame->scopeChain()->globalObject()->methodCallDummy(), STUB_RETURN_ADDRESS); + JIT::patchMethodCallProto(codeBlock, methodCallLinkInfo, callee, structure, callFrame->scopeChain()->globalObject->methodCallDummy(), STUB_RETURN_ADDRESS); return JSValue::encode(result); } } @@ -1738,7 +1738,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_construct_JSConstruct) if (stackFrame.args[3].jsValue().isObject()) structure = asObject(stackFrame.args[3].jsValue())->inheritorID(); else - structure = constructor->scope().node()->globalObject()->emptyObjectStructure(); + structure = constructor->scope().node()->globalObject->emptyObjectStructure(); return new (stackFrame.globalData) JSObject(structure); } @@ -2641,7 +2641,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_eval) Register* newCallFrame = callFrame->registers() + registerOffset; Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount; JSValue thisValue = argv[0].jsValue(); - JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject(); + JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject; if (thisValue == globalObject && funcVal == globalObject->evalFunction()) { JSValue exceptionValue; diff --git a/src/3rdparty/webkit/JavaScriptCore/jsc.cpp b/src/3rdparty/webkit/JavaScriptCore/jsc.cpp index 92b1e58..ee4e393 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jsc.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jsc.cpp @@ -24,6 +24,7 @@ #include "BytecodeGenerator.h" #include "Completion.h" +#include "CurrentTime.h" #include "InitializeThreading.h" #include "JSArray.h" #include "JSFunction.h" @@ -118,53 +119,23 @@ public: long getElapsedMS(); // call stop() first private: -#if PLATFORM(QT) - uint m_startTime; - uint m_stopTime; -#elif PLATFORM(WIN_OS) - DWORD m_startTime; - DWORD m_stopTime; -#else - // Windows does not have timeval, disabling this class for now (bug 7399) - timeval m_startTime; - timeval m_stopTime; -#endif + double m_startTime; + double m_stopTime; }; void StopWatch::start() { -#if PLATFORM(QT) - QDateTime t = QDateTime::currentDateTime(); - m_startTime = t.toTime_t() * 1000 + t.time().msec(); -#elif PLATFORM(WIN_OS) - m_startTime = timeGetTime(); -#else - gettimeofday(&m_startTime, 0); -#endif + m_startTime = currentTime(); } void StopWatch::stop() { -#if PLATFORM(QT) - QDateTime t = QDateTime::currentDateTime(); - m_stopTime = t.toTime_t() * 1000 + t.time().msec(); -#elif PLATFORM(WIN_OS) - m_stopTime = timeGetTime(); -#else - gettimeofday(&m_stopTime, 0); -#endif + m_stopTime = currentTime(); } long StopWatch::getElapsedMS() { -#if PLATFORM(WIN_OS) || PLATFORM(QT) - return m_stopTime - m_startTime; -#else - timeval elapsedTime; - timersub(&m_stopTime, &m_startTime, &elapsedTime); - - return elapsedTime.tv_sec * 1000 + lroundf(elapsedTime.tv_usec / 1000.0f); -#endif + return static_cast((m_stopTime - m_startTime) * 1000); } class GlobalObject : public JSGlobalObject { diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/FunctionConstructor.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/FunctionConstructor.cpp index d5eb20f..f28b3bd 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/FunctionConstructor.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/FunctionConstructor.cpp @@ -92,7 +92,7 @@ JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifi return throwError(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url()); JSGlobalObject* globalObject = exec->lexicalGlobalObject(); - ScopeChain scopeChain(globalObject, globalObject->globalData(), exec->globalThisValue()); + ScopeChain scopeChain(globalObject, globalObject->globalData(), globalObject, exec->globalThisValue()); return new (exec) JSFunction(exec, function, scopeChain.node()); } diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.cpp index 101f543..7671c96 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.cpp @@ -1066,26 +1066,4 @@ void JSArray::checkConsistency(ConsistencyCheckType type) #endif -JSArray* constructEmptyArray(ExecState* exec) -{ - return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure()); -} - -JSArray* constructEmptyArray(ExecState* exec, unsigned initialLength) -{ - return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), initialLength); -} - -JSArray* constructArray(ExecState* exec, JSValue singleItemValue) -{ - MarkedArgumentBuffer values; - values.append(singleItemValue); - return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values); -} - -JSArray* constructArray(ExecState* exec, const ArgList& values) -{ - return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values); -} - } // namespace JSC diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.h index 4f2f86a..7d28aab 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSArray.h @@ -116,11 +116,6 @@ namespace JSC { JSArray* asArray(JSValue); - JSArray* constructEmptyArray(ExecState*); - JSArray* constructEmptyArray(ExecState*, unsigned initialLength); - JSArray* constructArray(ExecState*, JSValue singleItemValue); - JSArray* constructArray(ExecState*, const ArgList& values); - inline JSArray* asArray(JSCell* cell) { ASSERT(cell->inherits(&JSArray::info)); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp index 8d71ac3..9907a8f 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -129,7 +129,7 @@ void JSGlobalObject::init(JSObject* thisValue) ASSERT(JSLock::currentThreadIsHoldingLock()); d()->globalData = Heap::heap(this)->globalData(); - d()->globalScopeChain = ScopeChain(this, d()->globalData.get(), thisValue); + d()->globalScopeChain = ScopeChain(this, d()->globalData.get(), this, thisValue); JSGlobalObject::globalExec()->init(0, 0, d()->globalScopeChain.node(), CallFrame::noCaller(), 0, 0, 0); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.h index 5f7137f..cda07e1 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSGlobalObject.h @@ -22,6 +22,7 @@ #ifndef JSGlobalObject_h #define JSGlobalObject_h +#include "JSArray.h" #include "JSGlobalData.h" #include "JSVariableObject.h" #include "NativeFunctionWrapper.h" @@ -343,14 +344,6 @@ namespace JSC { return symbolTableGet(propertyName, slot, slotIsWriteable); } - inline JSGlobalObject* ScopeChainNode::globalObject() const - { - const ScopeChainNode* n = this; - while (n->next) - n = n->next; - return asGlobalObject(n->object); - } - inline JSValue Structure::prototypeForLookup(ExecState* exec) const { if (typeInfo().type() == ObjectType) @@ -405,6 +398,33 @@ namespace JSC { return globalData().dynamicGlobalObject; } + inline JSObject* constructEmptyObject(ExecState* exec) + { + return new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure()); + } + + inline JSArray* constructEmptyArray(ExecState* exec) + { + return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure()); + } + + inline JSArray* constructEmptyArray(ExecState* exec, unsigned initialLength) + { + return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), initialLength); + } + + inline JSArray* constructArray(ExecState* exec, JSValue singleItemValue) + { + MarkedArgumentBuffer values; + values.append(singleItemValue); + return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values); + } + + inline JSArray* constructArray(ExecState* exec, const ArgList& values) + { + return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values); + } + class DynamicGlobalObjectScope : public Noncopyable { public: DynamicGlobalObjectScope(CallFrame* callFrame, JSGlobalObject* dynamicGlobalObject) diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp index 74af4b1..db2a9b2 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.cpp @@ -513,11 +513,6 @@ void JSObject::allocatePropertyStorage(size_t oldSize, size_t newSize) allocatePropertyStorageInline(oldSize, newSize); } -JSObject* constructEmptyObject(ExecState* exec) -{ - return new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure()); -} - bool JSObject::getOwnPropertyDescriptor(ExecState*, const Identifier& propertyName, PropertyDescriptor& descriptor) { unsigned attributes = 0; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h index 3fd1e3c..24b1ad6 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSObject.h @@ -264,8 +264,6 @@ namespace JSC { RefPtr m_inheritorID; }; -JSObject* constructEmptyObject(ExecState*); - inline JSObject* asObject(JSCell* cell) { ASSERT(cell->isObject()); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStack.h b/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStack.h index 5bc85fa..ba00057e0 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStack.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStack.h @@ -153,7 +153,7 @@ namespace JSC { ASSERT(0 == (size % MarkStack::pageSize())); if (size == m_allocated) return; -#if PLATFORM(WIN) +#if PLATFORM(WIN) || PLATFORM(SYMBIAN) // We cannot release a part of a region with VirtualFree. To get around this, // we'll release the entire region and reallocate the size that we want. releaseStack(m_data, m_allocated); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStackPosix.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStackPosix.cpp index 43f8b29..8e78ff3 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStackPosix.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStackPosix.cpp @@ -29,44 +29,22 @@ #include "MarkStack.h" #include -#if defined (__SYMBIAN32__) -#include "wtf/FastMalloc.h" -#include -#include -#include -#include -#else #include -#endif namespace JSC { void MarkStack::initializePagesize() { -#if defined (__SYMBIAN32__) - TInt page_size; - UserHal::PageSizeInBytes(page_size); - MarkStack::s_pageSize = page_size; -#else MarkStack::s_pageSize = getpagesize(); -#endif } void* MarkStack::allocateStack(size_t size) { -#if defined (__SYMBIAN32__) - return fastMalloc(size); -#else return mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); -#endif } void MarkStack::releaseStack(void* addr, size_t size) { -#if defined (__SYMBIAN32__) - fastFree(addr); -#else munmap(addr, size); -#endif } } diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStackSymbian.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStackSymbian.cpp new file mode 100644 index 0000000..a0ce8f6 --- /dev/null +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStackSymbian.cpp @@ -0,0 +1,44 @@ +/* + 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 Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "MarkStack.h" + +#include + +namespace JSC { + +void MarkStack::initializePagesize() +{ + TInt page_size; + UserHal::PageSizeInBytes(page_size); + MarkStack::s_pageSize = page_size; +} + +void* MarkStack::allocateStack(size_t size) +{ + return fastMalloc(size); +} + +void MarkStack::releaseStack(void* addr, size_t size) +{ + return fastFree(addr); +} + +} diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/ScopeChain.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/ScopeChain.cpp index 960c525..981794b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/ScopeChain.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/ScopeChain.cpp @@ -36,8 +36,8 @@ void ScopeChainNode::print() const ScopeChainIterator scopeEnd = end(); for (ScopeChainIterator scopeIter = begin(); scopeIter != scopeEnd; ++scopeIter) { JSObject* o = *scopeIter; - PropertyNameArray propertyNames(globalObject()->globalExec()); - o->getPropertyNames(globalObject()->globalExec(), propertyNames); + PropertyNameArray propertyNames(globalObject->globalExec()); + o->getPropertyNames(globalObject->globalExec(), propertyNames); PropertyNameArray::const_iterator propEnd = propertyNames.end(); fprintf(stderr, "----- [scope %p] -----\n", o); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/ScopeChain.h b/src/3rdparty/webkit/JavaScriptCore/runtime/ScopeChain.h index c5e16c9..0b15b67 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/ScopeChain.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/ScopeChain.h @@ -33,14 +33,16 @@ namespace JSC { class ScopeChainNode : public FastAllocBase { public: - ScopeChainNode(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSObject* globalThis) + ScopeChainNode(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis) : next(next) , object(object) , globalData(globalData) + , globalObject(globalObject) , globalThis(globalThis) , refCount(1) { ASSERT(globalData); + ASSERT(globalObject); } #ifndef NDEBUG // Due to the number of subtle and timing dependent bugs that have occurred due @@ -51,6 +53,7 @@ namespace JSC { next = 0; object = 0; globalData = 0; + globalObject = 0; globalThis = 0; } #endif @@ -58,6 +61,7 @@ namespace JSC { ScopeChainNode* next; JSObject* object; JSGlobalData* globalData; + JSGlobalObject* globalObject; JSObject* globalThis; int refCount; @@ -82,9 +86,6 @@ namespace JSC { ScopeChainIterator begin() const; ScopeChainIterator end() const; - JSGlobalObject* globalObject() const; // defined in JSGlobalObject.h - JSObject* globalThisObject() const { return globalThis; } - #ifndef NDEBUG void print() const; #endif @@ -93,7 +94,7 @@ namespace JSC { inline ScopeChainNode* ScopeChainNode::push(JSObject* o) { ASSERT(o); - return new ScopeChainNode(this, o, globalData, globalThis); + return new ScopeChainNode(this, o, globalData, globalObject, globalThis); } inline ScopeChainNode* ScopeChainNode::pop() @@ -163,8 +164,8 @@ namespace JSC { { } - ScopeChain(JSObject* o, JSGlobalData* globalData, JSObject* globalThis) - : m_node(new ScopeChainNode(0, o, globalData, globalThis)) + ScopeChain(JSObject* o, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis) + : m_node(new ScopeChainNode(0, o, globalData, globalObject, globalThis)) { } @@ -203,7 +204,7 @@ namespace JSC { void pop() { m_node = m_node->pop(); } void clear() { m_node->deref(); m_node = 0; } - JSGlobalObject* globalObject() const { return m_node->globalObject(); } + JSGlobalObject* globalObject() const { return m_node->globalObject; } void markAggregate(MarkStack&) const; diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/TimeoutChecker.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/TimeoutChecker.cpp index 30ba6e9..2a056c9 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/TimeoutChecker.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/TimeoutChecker.cpp @@ -35,18 +35,10 @@ #if PLATFORM(DARWIN) #include -#endif - -#if HAVE(SYS_TIME_H) -#include -#endif - -#if PLATFORM(WIN_OS) +#elif PLATFORM(WIN_OS) #include -#endif - -#if PLATFORM(QT) -#include +#else +#include "CurrentTime.h" #endif using namespace std; @@ -75,14 +67,6 @@ static inline unsigned getCPUTime() time += info.system_time.seconds * 1000 + info.system_time.microseconds / 1000; return time; -#elif HAVE(SYS_TIME_H) - // FIXME: This should probably use getrusage with the RUSAGE_THREAD flag. - struct timeval tv; - gettimeofday(&tv, 0); - return tv.tv_sec * 1000 + tv.tv_usec / 1000; -#elif PLATFORM(QT) - QDateTime t = QDateTime::currentDateTime(); - return t.toTime_t() * 1000 + t.time().msec(); #elif PLATFORM(WIN_OS) union { FILETIME fileTime; @@ -97,7 +81,8 @@ static inline unsigned getCPUTime() return userTime.fileTimeAsLong / 10000 + kernelTime.fileTimeAsLong / 10000; #else -#error Platform does not have getCurrentTime function + // FIXME: We should return the time the current thread has spent executing. + return currentTime() * 1000; #endif } diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.cpp b/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.cpp index afb0220..a9472c9 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.cpp @@ -2283,6 +2283,10 @@ static void sleep(unsigned seconds) void TCMalloc_PageHeap::scavengerThread() { +#if HAVE(PTHREAD_SETNAME_NP) + pthread_setname_np("JavaScriptCore: FastMalloc scavenger"); +#endif + while (1) { if (!shouldContinueScavenging()) { pthread_mutex_lock(&m_scavengeMutex); @@ -2388,7 +2392,7 @@ ALWAYS_INLINE void TCMalloc_Central_FreeList::ReleaseToSpans(void* object) { // The following check is expensive, so it is disabled by default if (false) { // Check that object does not occur in list - int got = 0; + unsigned got = 0; for (void* p = span->objects; p != NULL; p = *((void**) p)) { ASSERT(p != object); got++; diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h b/src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h index 1fda9c1..165eb41 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h @@ -49,24 +49,24 @@ namespace WTF { const_iterator begin() const; const_iterator end() const; - iterator find(const ValueType& value); - const_iterator find(const ValueType& value) const; - bool contains(const ValueType& value) const; - unsigned count(const ValueType& value) const; + iterator find(const ValueType&); + const_iterator find(const ValueType&) const; + bool contains(const ValueType&) const; + unsigned count(const ValueType&) const; // increases the count if an equal value is already present // the return value is a pair of an interator to the new value's location, // and a bool that is true if an new entry was added - std::pair add(const ValueType &value); + std::pair add(const ValueType&); // reduces the count of the value, and removes it if count // goes down to zero - void remove(const ValueType& value); - void remove(iterator it); + void remove(const ValueType&); + void remove(iterator); // removes the value, regardless of its count - void clear(iterator it); - void clear(const ValueType& value); + void removeAll(iterator); + void removeAll(const ValueType&); // clears the whole set void clear(); @@ -171,13 +171,13 @@ namespace WTF { } template - inline void HashCountedSet::clear(const ValueType& value) + inline void HashCountedSet::removeAll(const ValueType& value) { - clear(find(value)); + removeAll(find(value)); } template - inline void HashCountedSet::clear(iterator it) + inline void HashCountedSet::removeAll(iterator it) { if (it == end()) return; diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index bd82d8f..576e986 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -229,8 +229,7 @@ #define PLATFORM_ARM_ARCH(N) (PLATFORM(ARM) && ARM_ARCH_VERSION >= N) #if defined(arm) \ - || defined(__arm__) \ - || defined(__MARM__) + || defined(__arm__) #define WTF_PLATFORM_ARM 1 #if defined(__ARMEB__) #define WTF_PLATFORM_BIG_ENDIAN 1 @@ -238,8 +237,8 @@ #define WTF_PLATFORM_MIDDLE_ENDIAN 1 #endif #define ARM_ARCH_VERSION 3 -#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || defined(ARMV4I) \ - || defined(_ARMV4I_) || defined(armv4i) +#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || defined(__MARM_ARMV4__) \ + || defined(_ARMV4I_) #undef ARM_ARCH_VERSION #define ARM_ARCH_VERSION 4 #endif @@ -255,16 +254,20 @@ #undef ARM_ARCH_VERSION #define ARM_ARCH_VERSION 6 #endif -#if defined(__ARM_ARCH_7A__) || defined(__ARMV7__) +#if defined(__ARM_ARCH_7A__) #undef ARM_ARCH_VERSION #define ARM_ARCH_VERSION 7 #endif +/* On ARMv5 and below the natural alignment is required. */ +#if !defined(ARM_REQUIRE_NATURAL_ALIGNMENT) && ARM_ARCH_VERSION <= 5 +#define ARM_REQUIRE_NATURAL_ALIGNMENT 1 +#endif /* Defines two pseudo-platforms for ARM and Thumb-2 instruction set. */ #if !defined(WTF_PLATFORM_ARM_TRADITIONAL) && !defined(WTF_PLATFORM_ARM_THUMB2) # if defined(thumb2) || defined(__thumb2__) # define WTF_PLATFORM_ARM_TRADITIONAL 0 # define WTF_PLATFORM_ARM_THUMB2 1 -# elif PLATFORM_ARM_ARCH(4) || PLATFORM_ARM_ARCH(5) +# elif PLATFORM_ARM_ARCH(4) # define WTF_PLATFORM_ARM_TRADITIONAL 1 # define WTF_PLATFORM_ARM_THUMB2 0 # else @@ -420,7 +423,7 @@ #endif #define HAVE_READLINE 1 #define HAVE_RUNLOOP_TIMER 1 -#endif // PLATFORM(MAC) && !PLATFORM(IPHONE) +#endif /* PLATFORM(MAC) && !PLATFORM(IPHONE) */ #if PLATFORM(CHROMIUM) && PLATFORM(DARWIN) #define WTF_PLATFORM_CF 1 @@ -497,6 +500,7 @@ #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE) #define HAVE_MADV_FREE_REUSE 1 #define HAVE_MADV_FREE 1 +#define HAVE_PTHREAD_SETNAME_NP 1 #endif #if PLATFORM(IPHONE) diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/TCSpinLock.h b/src/3rdparty/webkit/JavaScriptCore/wtf/TCSpinLock.h index 74c02f3..b8fce7e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/TCSpinLock.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/TCSpinLock.h @@ -215,6 +215,13 @@ struct TCMalloc_SpinLock { inline void Unlock() { if (pthread_mutex_unlock(&private_lock_) != 0) CRASH(); } + bool IsHeld() { + if (pthread_mutex_trylock(&private_lock_)) + return true; + + Unlock(); + return false; + } }; #define SPINLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER } diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/ThreadingPthreads.cpp b/src/3rdparty/webkit/JavaScriptCore/wtf/ThreadingPthreads.cpp index c241bd9..e4fb419 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/ThreadingPthreads.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/ThreadingPthreads.cpp @@ -186,7 +186,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con void setThreadNameInternal(const char* threadName) { -#if PLATFORM(DARWIN) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !PLATFORM(IPHONE) +#if HAVE(PTHREAD_SETNAME_NP) pthread_setname_np(threadName); #else UNUSED_PARAM(threadName); diff --git a/src/3rdparty/webkit/JavaScriptCore/yarr/RegexJIT.cpp b/src/3rdparty/webkit/JavaScriptCore/yarr/RegexJIT.cpp index 4390b5b..d777424 100644 --- a/src/3rdparty/webkit/JavaScriptCore/yarr/RegexJIT.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/yarr/RegexJIT.cpp @@ -549,11 +549,11 @@ class RegexGenerator : private MacroAssembler { } if (mask) { - load32(BaseIndex(input, index, TimesTwo, state.inputOffset() * sizeof(UChar)), character); + load32WithUnalignedHalfWords(BaseIndex(input, index, TimesTwo, state.inputOffset() * sizeof(UChar)), character); or32(Imm32(mask), character); state.jumpToBacktrack(branch32(NotEqual, character, Imm32(chPair | mask)), this); } else - state.jumpToBacktrack(branch32(NotEqual, BaseIndex(input, index, TimesTwo, state.inputOffset() * sizeof(UChar)), Imm32(chPair)), this); + state.jumpToBacktrack(branch32WithUnalignedHalfWords(NotEqual, BaseIndex(input, index, TimesTwo, state.inputOffset() * sizeof(UChar)), Imm32(chPair)), this); } void generatePatternCharacterFixed(TermGenerationState& state) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index e13219b..cbec79c 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,8 +4,8 @@ This is a snapshot of the Qt port of WebKit from The commit imported was from the - qtwebkit-4.6-snapshot-24092009 branch/tag + qtwebkit-4.6-snapshot-29092009-2 branch/tag and has the sha1 checksum - 75c44947a340d74a9e0098a3dfffabce0c9512ef + 999c28aa9f6ad9e0d6a26a794220e1cb45408a97 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 5d83c7b..036fb5e 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,1293 @@ +2009-09-27 Sam Weinig + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=29760 + Implement CSSOM Range.getClientRects/getBoundingClientRect + + Tests: fast/dom/Range/getBoundingClientRect-getClientRects-relative-to-viewport.html + fast/dom/Range/getBoundingClientRect.html + fast/dom/Range/getClientRects.html + + * dom/Range.cpp: + (WebCore::Range::getClientRects): + (WebCore::Range::getBoundingClientRect): + (WebCore::adjustFloatQuadsForScrollAndAbsoluteZoom): + (WebCore::Range::getBorderAndTextQuads): + * dom/Range.h: + * dom/Range.idl: + Implement Range.getClientRects/getBoundingClientRect. + + * dom/Element.cpp: + * rendering/RenderObject.h: + (WebCore::adjustForAbsoluteZoom): + (WebCore::adjustIntRectForAbsoluteZoom): + (WebCore::adjustFloatPointForAbsoluteZoom): + (WebCore::adjustFloatQuadForAbsoluteZoom): + Move point/quad adjustment methods from Element.cpp to RenderObject.h + so that Range.cpp can use them as well. + +2009-09-27 Simon Hausmann + + Unreviewed fix for WebInspector with Qt build. + + Simply re-generate the Qt resource file by running + WebKitTools/Scripts/generate-qt-inspector-resource + + * inspector/front-end/WebKit.qrc: + +2009-09-27 Pavel Feldman + + Reviewed by nobody (trivial ChangeLog fix). + + Restore WebCore/ChangeLog truncated in r48778. + +2009-09-27 Pavel Feldman + + Reviewed by Timothy Hatcher. + + Web Inspector: DOM store is being unbound twice, leading to assertion failure. + + https://bugs.webkit.org/show_bug.cgi?id=29770 + + * inspector/InspectorController.cpp: + (WebCore::InspectorController::didOpenDatabase): + (WebCore::InspectorController::didUseDOMStorage): + * inspector/InspectorDOMStorageResource.cpp: + (WebCore::InspectorDOMStorageResource::unbind): + +2009-09-26 Pavel Feldman + + Reviewed by Timothy Hatcher. + + Web Inspector: Do not track DOM changes while inspector window is closed. + + https://bugs.webkit.org/show_bug.cgi?id=29769 + + * inspector/InspectorController.cpp: + (WebCore::InspectorController::inspectedWindowScriptObjectCleared): + (WebCore::InspectorController::populateScriptObjects): + (WebCore::InspectorController::resetScriptObjects): + (WebCore::InspectorController::didCommitLoad): + * inspector/InspectorController.h: + * inspector/InspectorDOMAgent.cpp: + (WebCore::InspectorDOMAgent::setDocument): + * inspector/InspectorDOMAgent.h: + * loader/FrameLoader.cpp: + (WebCore::FrameLoader::dispatchWindowObjectAvailable): + * page/android/InspectorControllerAndroid.cpp: + (WebCore::InspectorController::inspectedWindowScriptObjectCleared): + +2009-09-26 Pavel Feldman + + Reviewed by Timothy Hatcher. + + Web Inspector: [REGRESSION] Double Clicking Resources Fails to Open in New Window + + https://bugs.webkit.org/show_bug.cgi?id=29762 + + * inspector/front-end/InjectedScript.js: + (InjectedScript.setStyleText): + (InjectedScript.openInInspectedWindow): + * inspector/front-end/InjectedScriptAccess.js: + * inspector/front-end/ResourcesPanel.js: + (WebInspector.ResourceSidebarTreeElement.prototype.ondblclick): + +2009-09-26 David Kilzer + + Part 2 of 2: DerivedSources.make broken for non-Mac targets + + Reviewed by Darin Adler. + + Fix ENABLE_ORIENTATION_EVENTS for non-Mac platforms. + + * DerivedSources.make: Moved Platform.h check for + ENABLE_ORIENTATION_EVENTS into Mac-only section and added + default of ENABLE_ORIENTATION_EVENTS = 0 to non-Mac section. + Added ifndef test to make it possible to override both + ENABLE_DASHBOARD_SUPPORT and ENABLE_ORIENTATION_EVENTS external + to the makefile. Moved addition of ENABLE_ORIENTATION_EVENTS to + ADDITIONAL_IDL_DEFINES to common section. + * GNUmakefile.am: Added support for ENABLE_ORIENTATION_EVENTS if + it is ever used. + * WebCore.pro: Ditto. + +2009-09-26 Kent Tamura + + Reviewed by David Kilzer. + + Move placeholder-related code to HTMLTextFormControlElement from + HTMLInputElement, WMLInputElement, InputElement, and + HTMLTextAreaElement. + https://bugs.webkit.org/show_bug.cgi?id=28703 + + * dom/InputElement.cpp: + (WebCore::InputElement::dispatchFocusEvent): + (WebCore::InputElement::dispatchBlurEvent): + (WebCore::InputElement::setValueFromRenderer): + * dom/InputElement.h: + * html/HTMLFormControlElement.cpp: + (WebCore::HTMLTextFormControlElement::HTMLTextFormControlElement): + (WebCore::HTMLTextFormControlElement::~HTMLTextFormControlElement): + (WebCore::HTMLTextFormControlElement::dispatchFocusEvent): + (WebCore::HTMLTextFormControlElement::dispatchBlurEvent): + (WebCore::HTMLTextFormControlElement::placeholderShouldBeVisible): + (WebCore::HTMLTextFormControlElement::updatePlaceholderVisibility): + * html/HTMLFormControlElement.h: + (WebCore::HTMLTextFormControlElement::handleFocusEvent): + (WebCore::HTMLTextFormControlElement::handleBlurEvent): + * html/HTMLInputElement.cpp: + (WebCore::HTMLInputElement::HTMLInputElement): + (WebCore::HTMLInputElement::handleFocusEvent): + (WebCore::HTMLInputElement::handleBlurEvent): + (WebCore::HTMLInputElement::parseMappedAttribute): + (WebCore::HTMLInputElement::createRenderer): + (WebCore::HTMLInputElement::setValue): + (WebCore::HTMLInputElement::setValueFromRenderer): + * html/HTMLInputElement.h: + (WebCore::HTMLInputElement::supportsPlaceholder): + (WebCore::HTMLInputElement::isEmptyValue): + * html/HTMLIsIndexElement.cpp: + (WebCore::HTMLIsIndexElement::parseMappedAttribute): + * html/HTMLTextAreaElement.cpp: + (WebCore::HTMLTextAreaElement::HTMLTextAreaElement): + (WebCore::HTMLTextAreaElement::createRenderer): + * html/HTMLTextAreaElement.h: + (WebCore::HTMLTextAreaElement::supportsPlaceholder): + (WebCore::HTMLTextAreaElement::isEmptyValue): + * rendering/RenderTextControl.cpp: + (WebCore::RenderTextControl::RenderTextControl): + * rendering/RenderTextControl.h: + * rendering/RenderTextControlMultiLine.cpp: + (WebCore::RenderTextControlMultiLine::RenderTextControlMultiLine): + * rendering/RenderTextControlMultiLine.h: + * rendering/RenderTextControlSingleLine.cpp: + (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine): + (WebCore::RenderTextControlSingleLine::updateFromElement): + * rendering/RenderTextControlSingleLine.h: + * wml/WMLInputElement.cpp: + (WebCore::WMLInputElement::setValue): + (WebCore::WMLInputElement::createRenderer): + * wml/WMLInputElement.h: + +2009-09-26 Shu Chang + + Reviewed by Alexey Proskuryakov. + + Optimize the code so only the text from start to end is scanned. + https://bugs.webkit.org/show_bug.cgi?id=29092 + + On a platform with webkit+Qt+Symbian, the parsing time for a 600K text + file improved from 400ms to 40ms (10x faster). + + * dom/Text.cpp: + (WebCore::Text::createWithLengthLimit): + +2009-09-26 Xiaomei Ji + + Reviewed by Eric Seidel. + + This Patch fixes [chromium] the drop-down is always left-aligned even + for RTL element. + https://bugs.webkit.org/show_bug.cgi?id=29612 + + For auto-complete, the items in drop-down should be right-aligned if + the directionality of field is RTL. + For is RTL. + + No automatic test is possible. Manual tests are added. + + * manual-tests/autofill_alignment.html: Added. + * manual-tests/select_alignment.html: Added. + * platform/chromium/PopupMenuChromium.cpp: + (WebCore::PopupListBox::paintRow): Adjust the starting x-axis of text to + be paint if it should be right-aligned. + +2009-09-25 Dan Bernstein + + Reviewed by Sam Weinig. + + REGRESSION (r48775) FontList.plist written by TOT WebKit causes Safari 4 + to crash on launch + https://bugs.webkit.org/show_bug.cgi?id=29759 + + * platform/graphics/win/FontDatabase.cpp: + (WebCore::writeFontDatabaseToPlist): Reverted to saving the CG font DB + property list at the root of FontList.plist, but with an additional + key for the last value of the Fonts registry key. + (WebCore::populateFontDatabase): Pass the FontList.plist in its entirety + to populatFontDatabaseFromPlist. + +2009-09-25 Kevin Ollivier + + Build fix. Adding missing header files. + + * bindings/js/JSNamedNodeMapCustom.cpp: + +2009-09-25 David Kilzer + + Part 1 of 2: DerivedSources.make broken for non-Mac targets + + Reviewed by Darin Adler. + + * DerivedSources.make: Move tests for ENABLE_CONTEXT_MENUS, + ENABLE_DRAG_SUPPORT and ENABLE_INSPECTOR into Mac-only section. + +2009-09-25 Adam Barth + + Reviewed by Darin Adler. + + Load blocks during unload should not affect targeted loads + https://bugs.webkit.org/show_bug.cgi?id=29747 + + Move the check of the unload state after checking for targeted links. + + Test: fast/loader/unload-hyperlink-targeted.html + + * loader/FrameLoader.cpp: + (WebCore::FrameLoader::loadURL): + +2009-09-25 Kenneth Russell + + Reviewed by Dimitri Glazkov. + + [Chromium] Add initial V8 bindings for WebGL + https://bugs.webkit.org/show_bug.cgi?id=29664 + + * WebCore.gypi: + * bindings/scripts/CodeGeneratorV8.pm: + * bindings/v8/DOMObjectsInclude.h: + * bindings/v8/DerivedSourcesAllInOne.cpp: + * bindings/v8/V8DOMWrapper.cpp: + (WebCore::V8DOMWrapper::getTemplate): + * bindings/v8/V8Index.cpp: + * bindings/v8/V8Index.h: + * bindings/v8/custom/V8CanvasArrayBufferCustom.cpp: Added. + (WebCore::CALLBACK_FUNC_DECL): + * bindings/v8/custom/V8CanvasArrayCustom.h: Added. + (WebCore::constructCanvasArray): + * bindings/v8/custom/V8CanvasByteArrayCustom.cpp: Added. + (WebCore::CALLBACK_FUNC_DECL): + (WebCore::INDEXED_PROPERTY_GETTER): + (WebCore::INDEXED_PROPERTY_SETTER): + * bindings/v8/custom/V8CanvasFloatArrayCustom.cpp: Added. + (WebCore::CALLBACK_FUNC_DECL): + (WebCore::INDEXED_PROPERTY_GETTER): + (WebCore::INDEXED_PROPERTY_SETTER): + * bindings/v8/custom/V8CanvasIntArrayCustom.cpp: Added. + (WebCore::CALLBACK_FUNC_DECL): + (WebCore::INDEXED_PROPERTY_GETTER): + (WebCore::INDEXED_PROPERTY_SETTER): + * bindings/v8/custom/V8CanvasRenderingContext3DCustom.cpp: Added. + (WebCore::jsArrayToFloatArray): + (WebCore::jsArrayToIntArray): + (WebCore::CALLBACK_FUNC_DECL): + (WebCore::): + (WebCore::vertexAttribAndUniformHelperf): + (WebCore::uniformHelperi): + (WebCore::uniformMatrixHelper): + * bindings/v8/custom/V8CanvasShortArrayCustom.cpp: Added. + (WebCore::CALLBACK_FUNC_DECL): + (WebCore::INDEXED_PROPERTY_GETTER): + (WebCore::INDEXED_PROPERTY_SETTER): + * bindings/v8/custom/V8CanvasUnsignedByteArrayCustom.cpp: Added. + (WebCore::CALLBACK_FUNC_DECL): + (WebCore::INDEXED_PROPERTY_GETTER): + (WebCore::INDEXED_PROPERTY_SETTER): + * bindings/v8/custom/V8CanvasUnsignedIntArrayCustom.cpp: Added. + (WebCore::CALLBACK_FUNC_DECL): + (WebCore::INDEXED_PROPERTY_GETTER): + (WebCore::INDEXED_PROPERTY_SETTER): + * bindings/v8/custom/V8CanvasUnsignedShortArrayCustom.cpp: Added. + (WebCore::CALLBACK_FUNC_DECL): + (WebCore::INDEXED_PROPERTY_GETTER): + (WebCore::INDEXED_PROPERTY_SETTER): + * bindings/v8/custom/V8CustomBinding.h: + * bindings/v8/custom/V8DocumentCustom.cpp: + (WebCore::CALLBACK_FUNC_DECL): + * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp: + (WebCore::CALLBACK_FUNC_DECL): + * platform/graphics/GraphicsContext3D.h: + +2009-09-25 Jeremy Orlow + + This is breaking Chromium try bots, so I'm counting this as a build fix. + + Add more svn:ignore exceptions. On different platforms, these files are + generated with different case for WebCore. + + * WebCore.gyp: Changed property svn:ignore. + +2009-09-25 Alexey Proskuryakov + + Reverting r48767, as it broke Windows build in a non-trivial way. + + * bindings/js/JSAbstractWorkerCustom.cpp: + (WebCore::JSAbstractWorker::addEventListener): + (WebCore::JSAbstractWorker::removeEventListener): + * bindings/js/JSDOMApplicationCacheCustom.cpp: + (WebCore::JSDOMApplicationCache::addEventListener): + (WebCore::JSDOMApplicationCache::removeEventListener): + * bindings/js/JSDOMGlobalObject.cpp: + (WebCore::JSDOMGlobalObject::createJSAttributeEventListener): + * bindings/js/JSDOMWindowCustom.cpp: + (WebCore::JSDOMWindow::addEventListener): + (WebCore::JSDOMWindow::removeEventListener): + * bindings/js/JSEventListener.cpp: + (WebCore::JSEventListener::JSEventListener): + (WebCore::JSEventListener::jsFunction): + (WebCore::JSEventListener::markJSFunction): + (WebCore::JSEventListener::handleEvent): + (WebCore::JSEventListener::reportError): + * bindings/js/JSEventListener.h: + (WebCore::JSEventListener::create): + * bindings/js/JSEventSourceCustom.cpp: + (WebCore::JSEventSource::addEventListener): + (WebCore::JSEventSource::removeEventListener): + * bindings/js/JSLazyEventListener.cpp: + (WebCore::JSLazyEventListener::JSLazyEventListener): + (WebCore::JSLazyEventListener::jsFunction): + (WebCore::JSLazyEventListener::parseCode): + * bindings/js/JSLazyEventListener.h: + (WebCore::JSLazyEventListener::create): + * bindings/js/JSMessagePortCustom.cpp: + (WebCore::JSMessagePort::addEventListener): + (WebCore::JSMessagePort::removeEventListener): + * bindings/js/JSNodeCustom.cpp: + (WebCore::JSNode::addEventListener): + (WebCore::JSNode::removeEventListener): + * bindings/js/JSSVGElementInstanceCustom.cpp: + (WebCore::JSSVGElementInstance::addEventListener): + (WebCore::JSSVGElementInstance::removeEventListener): + * bindings/js/JSWorkerContextCustom.cpp: + (WebCore::JSWorkerContext::addEventListener): + (WebCore::JSWorkerContext::removeEventListener): + * bindings/js/JSXMLHttpRequestCustom.cpp: + (WebCore::JSXMLHttpRequest::addEventListener): + (WebCore::JSXMLHttpRequest::removeEventListener): + * bindings/js/JSXMLHttpRequestUploadCustom.cpp: + (WebCore::JSXMLHttpRequestUpload::addEventListener): + (WebCore::JSXMLHttpRequestUpload::removeEventListener): + * bindings/js/ScriptEventListener.cpp: + (WebCore::createAttributeEventListener): + * bindings/objc/ObjCEventListener.h: + * bindings/objc/ObjCEventListener.mm: + (WebCore::ObjCEventListener::handleEvent): + * bindings/scripts/CodeGeneratorJS.pm: + * dom/EventListener.h: + (WebCore::EventListener::reportError): + (WebCore::EventListener::jsFunction): + * dom/EventTarget.cpp: + (WebCore::EventTarget::fireEventListeners): + * inspector/InspectorDOMAgent.cpp: + (WebCore::InspectorDOMAgent::handleEvent): + * inspector/InspectorDOMAgent.h: + * inspector/InspectorDOMStorageResource.cpp: + (WebCore::InspectorDOMStorageResource::handleEvent): + * inspector/InspectorDOMStorageResource.h: + * loader/ImageDocument.cpp: + (WebCore::ImageEventListener::handleEvent): + * svg/animation/SVGSMILElement.cpp: + (WebCore::ConditionEventListener::handleEvent): + * workers/WorkerContext.cpp: + (WebCore::WorkerContext::reportException): + +2009-09-24 Tony Chang + + Reviewed by David Levin. + + Add a gyp variable to allow building a debug webcore without debug + symbols. This allows for faster compile, link, and gdb times. + + https://bugs.webkit.org/show_bug.cgi?id=29721 + + No new tests, build config change. + + * WebCore.gyp/WebCore.gyp: + +2009-09-25 Darin Fisher + + Reviewed by Dimitri Glazkov. + + Declare RegisteredEventListener as a class instead of a struct. + This fixes a warning in the Chromium build. + + * dom/RegisteredEventListener.h: + +2009-09-25 Dan Bernstein + + Reviewed by Jon Honeycutt. + + WebCore part of + 2 byte characters are displayed as garbaged + garbled/gibberish text (off-by-one) + + When the Windows Fonts directory contains more than one font file for a + given font name, which of the fonts gets assigned to the name in the + Core Graphics font database was determined arbitrarily and did not + always match the font GDI used for the same font name. The mismatch + caused character-to-glyph mapping to use one font and glyph rendering to + use another. + + The fix is to update the Core Graphics font database from the registry + entries (that reflect the name-to-font mapping that GDI uses) after + populating it with the result of scanning the Fonts directory. As a + consequence, the directory needs to be scanned at startup every time the + registry key changes, so the last value of the registry key is kept + in the property list on disk so that it could be compared to the current + value on startup. + + * platform/graphics/win/FontDatabase.cpp: + (WebCore::populateFontDatabaseFromPlist): Now takes a property list as + a parameter and avoids round-tripping through XML by calling + wkAddFontsFromPlist() instead of wkAddFontsFromPlistRepresentation(). + (WebCore::fontFilenamesFromRegistryKey): + (WebCore::cgFontDBKey): + (WebCore::writeFontDatabaseToPlist): Now takes the CG font DB property + list and a property list with the font filenames from the registry and + writes a dictionary with those property lists as values. + (WebCore::fontFilenamesFromRegistry): Added. Returns an array with the + values in the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts + registry key. + (WebCore::populateFontDatabase): Changed to read the contents of the + Fonts registry key and compare it with the last-saved value from the + property list, and to call wkAddFontsFromRegistry() after populating the + CG font DB from the file system. Uses wkCreateFontsPlist() instead of + wkCreateFontsPlistRepresentation() to avoid round-tripping through XML. + +2009-09-25 Geoffrey Garen + + Reviewed by Darin Adler. + + Inlined some object creation code, including lexicalGlobalObject access + https://bugs.webkit.org/show_bug.cgi?id=29750 + + * bindings/js/JSInspectorBackendCustom.cpp: + (WebCore::JSInspectorBackend::currentCallFrame): + * inspector/JavaScriptDebugServer.cpp: + (WebCore::JavaScriptDebugServer::hasBreakpoint): Updated for JavaScriptCore + API changes. + +2009-09-25 Dave Hyatt + + Reviewed by Anders Carlsson. + + https://bugs.webkit.org/show_bug.cgi?id=24399 + Make @import work in user stylesheets. The first bug was that the URL wasn't being set on the + user sheets themselves, so relative @import URLs couldn't resolve properly. The second bug + was that the loads would be denied. This is fixed by using the requestUserCSSStyleSheet method + instead of the normal request method. In order to know when to do this, CSSStyleSheets now have + a propagated boolean, m_isUserStyleSheet, that lets them know if they are user stylesheets or not. + + * css/CSSImportRule.cpp: + (WebCore::CSSImportRule::insertedIntoParent): + * css/CSSStyleSheet.cpp: + (WebCore::CSSStyleSheet::CSSStyleSheet): + * css/CSSStyleSheet.h: + (WebCore::CSSStyleSheet::setIsUserStyleSheet): + (WebCore::CSSStyleSheet::isUserStyleSheet): + * dom/Document.cpp: + (WebCore::Document::pageUserSheet): + (WebCore::Document::pageGroupUserSheets): + +2009-09-25 Simon Fraser + + Reviewed by Darin Adler. + + Crash with hardware accelerated rotation of a PDF image in a data URL + + + PDF images don't return a color space from CGImageGetColorSpace(), + so we need to null-check the return value before use. + + Test: compositing/color-matching/pdf-image-match.html + + * platform/graphics/mac/GraphicsLayerCA.mm: + (WebCore::GraphicsLayerCA::setContentsToImage): + +2009-09-25 Darin Adler + + Reviewed by Geoffrey Garen. + + Null-deref when first access to an Attr node is after its Element is destroyed + https://bugs.webkit.org/show_bug.cgi?id=29748 + + Test: fast/dom/Attr/access-after-element-destruction.html + + * bindings/js/JSAttrCustom.cpp: + (WebCore::JSAttr::markChildren): Added. Keeps the ownerElement alive as + long as the Attr is alive. + + * bindings/js/JSNamedNodeMapCustom.cpp: + (WebCore::JSNamedNodeMap::markChildren): Added. Keeps the Element alive as + long as the NamedNodeMap is alive. + + * dom/Attr.idl: Added CustomMarkFunction attribute. + + * dom/NamedAttrMap.cpp: + (WebCore::NamedNodeMap::getAttributeItem): Tweaked formatting. + (WebCore::NamedNodeMap::detachFromElement): Call clearAttributes so we don't + have attributes hanging around that might need an Attr node created; that way + we won't crash with a null-dereference trying to deal with one of them. This + can't happen when working with JavaScript since the Element will be kept + alive due to the change above. + (WebCore::NamedNodeMap::addAttribute): Fix function name in comment. + (WebCore::NamedNodeMap::removeAttribute): Removed unneeded "+ 1" and added + missing braces. + + * dom/NamedAttrMap.h: Made the element function public so it can be used by + the JavaScript binding to keep the Element alive. + + * dom/NamedNodeMap.idl: Added CustomMarkFunction attribute. + +2009-09-24 Alexey Proskuryakov + + Reviewed by Darin Adler and Sam Weinig. + + Onclick not fired for an element copied with cloneContents() or cloneNode() + https://bugs.webkit.org/show_bug.cgi?id=25130 + + The change here is that JS event listeners don't keep a reference to a global object from + where they were created, and instead take it as a parameter when parsing source code. Also, + the listener creation won't fail just because it happens for an element in a frameless + document. + Thus, moving nodes between documents no longer results in having incorrect registered + lazy event listeners on them. + + Tests: fast/events/attribute-listener-cloned-from-frameless-doc-context-2.html + fast/events/attribute-listener-cloned-from-frameless-doc-context.html + fast/events/attribute-listener-cloned-from-frameless-doc.xhtml + fast/events/attribute-listener-extracted-from-frameless-doc-context-2.html + fast/events/attribute-listener-extracted-from-frameless-doc-context.html + + * bindings/js/JSEventListener.cpp: + (WebCore::JSEventListener::JSEventListener): Don't take a reference to JSDOMGlobalObject. + (WebCore::JSEventListener::jsFunction): Take ScriptExecutionContext as a parameter for + getting to JSDOMGlobalObject. It's not used in base class, but is in JSLazyEventListner. + (WebCore::JSEventListener::markJSFunction): Don't mark the global object. + (WebCore::JSEventListener::handleEvent): Get global object from ScriptExecutionContext. + (WebCore::JSEventListener::reportError): Ditto. + + * bindings/js/JSEventListener.h: (WebCore::JSEventListener::create): Don't keep a reference + to JSDOMGlobalObject. + + * bindings/js/JSLazyEventListener.cpp: (WebCore::JSLazyEventListener::parseCode): Listener + creation was split between this function and ScriptEventListener; moved it here, as JS + global object can be different now. + + * bindings/js/JSLazyEventListener.h: (WebCore::JSLazyEventListener::create): Keep source URL, + which can not be determined at parsing time. + + * bindings/js/ScriptEventListener.cpp: (WebCore::createAttributeEventListener): Moved code + for listener creation to JSLazyEventListener. XSSAuditor code remains here, because tests + expect that errors are logged at document parsing time, and because I don't know what other + side effects moving it vould have. + + * dom/EventListener.h: handleEvent() and reportError() now take ScriptExecutionContext, + because JSC needs a global context here. + + * bindings/js/JSAbstractWorkerCustom.cpp: + (WebCore::JSAbstractWorker::addEventListener): + (WebCore::JSAbstractWorker::removeEventListener): + * bindings/js/JSDOMApplicationCacheCustom.cpp: + (WebCore::JSDOMApplicationCache::addEventListener): + (WebCore::JSDOMApplicationCache::removeEventListener): + * bindings/js/JSDOMGlobalObject.cpp: + (WebCore::JSDOMGlobalObject::createJSAttributeEventListener): + * bindings/js/JSDOMWindowCustom.cpp: + (WebCore::JSDOMWindow::addEventListener): + (WebCore::JSDOMWindow::removeEventListener): + * bindings/js/JSEventSourceCustom.cpp: + (WebCore::JSEventSource::addEventListener): + (WebCore::JSEventSource::removeEventListener): + * bindings/js/JSMessagePortCustom.cpp: + (WebCore::JSMessagePort::addEventListener): + (WebCore::JSMessagePort::removeEventListener): + * bindings/js/JSNodeCustom.cpp: + (WebCore::JSNode::addEventListener): + (WebCore::JSNode::removeEventListener): + * bindings/js/JSSVGElementInstanceCustom.cpp: + (WebCore::JSSVGElementInstance::addEventListener): + (WebCore::JSSVGElementInstance::removeEventListener): + * bindings/js/JSWorkerContextCustom.cpp: + (WebCore::JSWorkerContext::addEventListener): + (WebCore::JSWorkerContext::removeEventListener): + * bindings/js/JSXMLHttpRequestCustom.cpp: + (WebCore::JSXMLHttpRequest::addEventListener): + (WebCore::JSXMLHttpRequest::removeEventListener): + * bindings/js/JSXMLHttpRequestUploadCustom.cpp: + (WebCore::JSXMLHttpRequestUpload::addEventListener): + (WebCore::JSXMLHttpRequestUpload::removeEventListener): + * bindings/objc/ObjCEventListener.h: + * bindings/objc/ObjCEventListener.mm: + (WebCore::ObjCEventListener::handleEvent): + * bindings/scripts/CodeGeneratorJS.pm: + * dom/EventTarget.cpp: + (WebCore::EventTarget::fireEventListeners): + * inspector/InspectorDOMAgent.cpp: + (WebCore::InspectorDOMAgent::handleEvent): + * inspector/InspectorDOMAgent.h: + * inspector/InspectorDOMStorageResource.cpp: + (WebCore::InspectorDOMStorageResource::handleEvent): + * inspector/InspectorDOMStorageResource.h: + * loader/ImageDocument.cpp: + (WebCore::ImageEventListener::handleEvent): + * svg/animation/SVGSMILElement.cpp: + (WebCore::ConditionEventListener::handleEvent): + * workers/WorkerContext.cpp: + (WebCore::WorkerContext::reportException): + Don't pass global object to JSEventListener::create(), which no longer needs it. + Note that some of these functions still have an early return for null global object, which + can probably be removed in a later patch. + Pass ScriptExecutionContext to EventListener methods that now need it. + +2009-09-25 Enrica Casucci + + Reviewed by Darin Adler, Dan Bernstein, Adele Peterson, and others. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=29740 + Gmail: After changing a foreground text color, pressing return doesn't apply background to new line + + Change the way style is preserved when inserting a new paragraph. + The original code handled insertion at the beginning and at the end of a paragraph as special + cases. The newly created paragraph contained a set of nodes generated starting from the + computed style of the insertion node. This approach has two problems: + 1. if the insertion node has a non opaque background color and one of the parent element did have + a solid background color the new paragraph did not have the element with the solid color in the tree. + 2. in some circumstances it generated more markup than the original paragraph had (a span with bold, italic, + background color and some font attribute was being reproduced as span + bold + italic + font as separate tags. + The new approach is to recreate in the new paragraph the same hierarchy of nodes found in the + paragraph where the insertion point is. + + Test: editing/inserting/insert-bg-font.html + + * editing/InsertParagraphSeparatorCommand.cpp: + (WebCore::InsertParagraphSeparatorCommand::getAncestorsInsideBlock): retrieves the list of all the ancestors + between the insert node and the outer block. + (WebCore::InsertParagraphSeparatorCommand::cloneHierarchyUnderNewBlock): uses the list of ancestors to recreate + in the new paragraph the same element hierarchy present in the starting paragraph. + (WebCore::InsertParagraphSeparatorCommand::doApply): changed the code to handle the general case of insertion + in the middle of the paragraph to use the new methods. Changed the handling of the insertion at the beginning and + at the end of the paragraph to use the new methods instead of applying the calculated style. + * editing/InsertParagraphSeparatorCommand.h: added methods getAncestorsInsideBlock and cloneHierarchyUnderNewBlock. + +2009-09-25 Patrick Mueller + + Reviewed by Timothy Hatcher. + + Content-type parameters not taken into account when building form-data + https://bugs.webkit.org/show_bug.cgi?id=28970 + + existing manual test case extended with new tests + + * English.lproj/localizedStrings.js: + * inspector/front-end/ResourceView.js: + (WebInspector.ResourceView.prototype._refreshFormData): + (WebInspector.ResourceView.prototype._refreshParms): + * manual-tests/inspector/display-form-data.html: + +2009-09-25 Yuan Song + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=14566 + + Raise SECURITY_ERR exception if an attempt is made to change document.domain to an invalid value. + + Test: fast/js/invalid-domain-change-throws-exception.html + + * dom/Document.cpp: + (WebCore::Document::setDomain): + * dom/Document.h: + * dom/Document.idl: + +2009-09-25 Adam Barth + + Reviewed by Dimitri Glazkov. + + [V8] Teach ScheduledAction::execute about isolated worlds + https://bugs.webkit.org/show_bug.cgi?id=27703 + + When setTimeout is called with a string argument in an isolated + world, we now compile the string in the isolated world. + + Last time we tried this change, we got a lot of crashes. This + time we're using a fresh local handle as our context to avoid + trouble if the peristent handle gets disposed before we leave + the context. + + Test: fast/dom/timer-clear-interval-in-handler-and-generate-error.html + + * bindings/v8/ScheduledAction.cpp: + (WebCore::ScheduledAction::execute): + +2009-09-25 Paul Godavari + + Reviewed by Darin Fisher. + + Fix a regression in Mac Chromium popup menus, where the user's + selection was ignored and the popup became unresponsive. + https://bugs.webkit.org/show_bug.cgi?id=29726 + + The fix is to notify the popup's client that the popup was hidden, + even if the popup has no parent. + + * platform/chromium/PopupMenuChromium.cpp: + (WebCore::PopupListBox::hidePopup): + +2009-09-25 Alexander Pavlov + + Reviewed by Dan Bernstein. + + Enable Pasteboard::writePlainText for Chromium and fix code style nits. + https://bugs.webkit.org/show_bug.cgi?id=29734 + + * platform/chromium/PasteboardChromium.cpp: + (WebCore::Pasteboard::writePlainText): + * platform/gtk/PasteboardGtk.cpp: + (WebCore::Pasteboard::writePlainText): + (WebCore::Pasteboard::writeURL): + * platform/mac/PasteboardMac.mm: + (WebCore::Pasteboard::writeSelection): + (WebCore::Pasteboard::writePlainText): + (WebCore::Pasteboard::writeURL): + * platform/qt/PasteboardQt.cpp: + (WebCore::Pasteboard::writePlainText): + +2009-09-25 Yongjun Zhang + + Reviewed by Ariya Hidayat. + + https://bugs.webkit.org/show_bug.cgi?id=28876 + [Qt] reduce peak memory consumption of text decoding. + + Chop large input buffer into small buffers to reduce peak memory + during decoding. + + * platform/text/qt/TextCodecQt.cpp: + (WebCore::TextCodecQt::decode): + +2009-09-24 Jon Honeycutt + + Add a mechanism for automatically halting plug-ins. + + Reviewed by Oliver Hunt and Alice Liu. + + * GNUmakefile.am: + + * WebCore.base.exp: + Update export of Page constructor. + + * WebCore.gypi: + + * WebCore.pro: + + * WebCore.vcproj/WebCore.vcproj: + Add PluginHalter.{h,cpp}, PluginHalterClient.h, and + HaltablePlugin.h. + + * WebCore.xcodeproj/project.pbxproj: + Add files to Mac project. + + * loader/EmptyClients.h: + Added an empty PluginHalterClient. + (WebCore::EmptyPluginHalterClient::shouldHaltPlugin): + Return false. + + * page/PluginHalter.cpp: Added. + (WebCore::PluginHalter::PluginHalter): + (WebCore::PluginHalter::didStartPlugin): + Add the object to the plug-in set. If this is the only item in the set, + set m_oldestStartTime to this object's time, and start the timer. + (WebCore::PluginHalter::didStopPlugin): + Remove the plug-in from the set. + (WebCore::PluginHalter::timerFired): + Find the cut-off time as the current time minus the allowed run time; + plug-ins older than this may be halted. Iterate over the plug-ins. Find + the object with the oldest start time that is too young to be halted; + we'll use its start time to set the timer's next fire time. For all + plug-ins that are candidates to be halted, call the + PluginHalterClient's shouldHaltPlugin(). If this function returns true, + call the plug-in's halt() function. Remove these objects from the set + of tracked plug-ins. Call startTimerIfNecessary() to restart the timer. + (WebCore::PluginHalter::startTimerIfNecessary): + If the timer is set to fire, or the set of tracked plug-ins is empty, + return early. Set the timer to fire after the oldest plug-in has run + for the allowed run time. + + * page/PluginHalter.h: Added. + (WebCore::PluginHalter::setPluginAllowedRunTime): + + * page/PluginHalterClient.h: Added. + (WebCore::PluginHalterClient::~PluginHalterClient): + + * page/Page.cpp: + (WebCore::Page::Page): + Initialize m_pluginHalterClient. Call pluginHalterEnabledStateChanged() + to create the PluginHalter if necessary. + (WebCore::Page::pluginHalterEnabledStateChanged): + If plug-in halting is enabled, create the PluginHalter. If it is + disabled, clear it. + (WebCore::Page::pluginAllowedRunTimeChanged): + If there is a plug-in halter, call its setPluginAllowedRunTime(). + (WebCore::Page::didStartPlugin): + If there is a plug-in halter, call its didStartPlugin(). + (WebCore::Page::didStopPlugin): + If there is a plug-in halter, call its didStopPlugin(). + + * page/Page.h: + Add a parameter to the Page constructor for the PluginHalterClient. + Added declarations for didStartPlugin() and didStopPlugin(), which are + called when HaltablePlugins are added to or removed from the page. Adds + pluginAllowedRunTimeChanged() and pluginHalterEnabledStateChanged() to + notify the Page when these settings are changed. Added members to hold + the PluginHalter and the PluginHalterClient. + + * page/Settings.cpp: + (WebCore::Settings::Settings): + (WebCore::Settings::setPluginHalterEnabled): + If the enabled state has changed, call the Page's + pluginHalterEnabledStateChanged(). + (WebCore::Settings::setPluginAllowedRunTime): + Call the Page's pluginAllowedRunTimeChanged(). + + * page/Settings.h: + (WebCore::Settings::pluginHalterEnabled): + (WebCore::Settings::pluginAllowedRunTime): + + * page/HaltablePlugin.h: Added. Defines an interface for plug-ins that + can be automatically halted. + (WebCore::HaltablePlugin::~HaltablePlugin): + + * svg/graphics/SVGImage.cpp: + (WebCore::SVGImage::dataChanged): + Pass a dummy PluginHalterClient. + +2009-09-24 Simon Fraser + + Reviewed by Dan Bernstein. + + REGRESSION: webkit-transform scale no longer works properly in nightly build + https://bugs.webkit.org/show_bug.cgi?id=29730 + + When the initial or final state of a scale animation does not specify a transform, + use a default scale of 1, rather than zero. + + Test: compositing/transitions/scale-transition-no-start.html + + * platform/graphics/mac/GraphicsLayerCA.mm: + (WebCore::getTransformFunctionValue): + +2009-09-24 John Gregg + + Reviewed by Eric Seidel. + + isEnabled switch for notifications (experimental) in Page Settings + https://bugs.webkit.org/show_bug.cgi?id=28930 + + Adds a run-time flag in Settings object that controls whether + to expose desktop notifications. + + No new test, but test code also modified to set this preference. + + * page/DOMWindow.cpp: + (WebCore::DOMWindow::webkitNotifications): check preference before returning notifications object + * page/Settings.cpp: + (WebCore::Settings::Settings): + (WebCore::Settings::setExperimentalNotificationsEnabled): + * page/Settings.h: + (WebCore::Settings::experimentalNotificationsEnabled): + +2009-09-24 Dan Bernstein + + Reviewed by Sam Weinig. + + Fix Crash while trying to + calculate the horizontal position of image + + Test: fast/inline-block/relative-positioned-rtl-crash.html + + * rendering/RenderBox.cpp: + (WebCore::RenderBox::calcAbsoluteHorizontalReplaced): Corrected an + isInline() test to isRenderInline(). This is similar to r41259. + +2009-09-24 Jessie Berlin + + Reviewed by Timothy Hatcher. + + Fix expanding profile call stacks being broken after sorting. + https://bugs.webkit.org/show_bug.cgi?id=26423 + + * inspector/front-end/ProfileDataGridTree.js: + (WebInspector.ProfileDataGridNode.prototype.sort): + Set shouldRefreshChildren to true on collapsed nodes with children so that expanding it + causes the children to be placed in the right positions. + +2009-09-24 Geoffrey Garen + + Reviewed by Stephanie Lewis. + + Fixed sudden termination console spew due to too many calls to + enableSuddenTermination. + + 10A410: Safari logging enableSuddenTermination errors + + * page/DOMWindow.cpp: + (WebCore::removeUnloadEventListener): + (WebCore::removeAllUnloadEventListeners): + (WebCore::removeBeforeUnloadEventListener): + (WebCore::removeAllBeforeUnloadEventListeners): Only + enableSuddenTermination if the set of listeners is empty *and* this + window was in the set. Otherwise, a no-op will cause us to enableSuddenTermination. + +2009-09-24 Carol Szabo + + Reviewed by Alexey Proskuryakov. + + WebKit returns "" instead of null when getting + inexistent, forbidden or invalidly named headers. + https://bugs.webkit.org/show_bug.cgi?id=29140 + + * xml/XMLHttpRequest.cpp: + (WebCore::XMLHttpRequest::getResponseHeader): + Changed to return null as it should according to the spec. + +2009-09-24 Jeremy Orlow + + Reviewed by Dimitri Glazkov. + + Add GYP generated files to svn:ignore + https://bugs.webkit.org/show_bug.cgi?id=29724 + + Adding the following files to the svn:ignore list (all in the + WebCore/WebCore.gyp directory) + + WebCore.xcodeproj + WebCore.sln + WebCore.vcproj + WebCore_Debug.rules + WebCore_Release.rules + WebCore_Release - no tcmalloc.rules + WebCore_Purify.rules + WebCore.mk + WebCore_Debug_rules.mk + WebCore_Release_rules.mk + WebCore_Release - no tcmalloc_rules.mk + WebCore_Purify_rules.mk + WebCore.scons + WebCore_main.scons + + * WebCore.gyp: Changed property svn:ignore. + +2009-09-24 Gustavo Noronha Silva + + Unreviewed. Mac build fix. + + * page/EventHandler.cpp: + (WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal): + remove unused parameter from function signature; + +2009-09-24 Gustavo Noronha Silva + + Reviewed by Oliver Hunt. + + Implement correct horizontal scrollbar behavior for GTK+ also on + styled scrollbars. + + https://bugs.webkit.org/show_bug.cgi?id=29348 + [Gtk] Scrollwheel on horizontal scrollbars should slide horizontally + + Test: platform/gtk/scrollbars/overflow-scrollbar-horizontal-wheel-scroll.html + + * page/EventHandler.cpp: + (WebCore::EventHandler::handleWheelEvent): on GTK+, when using the + wheel with the pointer on the horizontal scrollbar, scroll + horizontally; + * platform/PlatformWheelEvent.h: + * platform/gtk/WheelEventGtk.cpp: + (WebCore::PlatformWheelEvent::swapOrientation): allow adding a + vertical scroll to the horizontal one; + +2009-09-24 Jeremy Orlow + + Reviewed by Eric Seidel. + + StorageNamespace::storageArea() should take in a PassRefPtr + https://bugs.webkit.org/show_bug.cgi?id=29290 + + Modified StorageNamespace::storageArea() to take in a PassRefPtr + per http://webkit.org/coding/RefPtr.html + + No behavior change, so no tests. + + * storage/StorageNamespace.h: + * storage/StorageNamespaceImpl.cpp: + (WebCore::StorageNamespaceImpl::storageArea): + * storage/StorageNamespaceImpl.h: + +2009-09-24 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added back enable/disableSuddenTermination() functionality I accidentally + removed in my last patch. + + * page/DOMWindow.cpp: + (WebCore::addUnloadEventListener): + (WebCore::removeUnloadEventListener): + (WebCore::removeAllUnloadEventListeners): + (WebCore::addBeforeUnloadEventListener): + (WebCore::removeBeforeUnloadEventListener): + (WebCore::removeAllBeforeUnloadEventListeners): + (WebCore::DOMWindow::dispatchAllPendingUnloadEvents): + (WebCore::DOMWindow::~DOMWindow): + (WebCore::DOMWindow::addEventListener): + (WebCore::DOMWindow::removeEventListener): + (WebCore::DOMWindow::removeAllEventListeners): + +2009-09-24 Sam Weinig + + Reviewed by Steve Falkenburg and Mark Rowe. + + Don't pass -F to GCC on non-mac platforms since it is an darwin only. + + * DerivedSources.make: + +2009-09-24 Sam Weinig + + Fix windows build. + + * dom/Element.idl: + +2009-09-23 Stephen White + + Reviewed by Eric Seidel. + + Revert the relevant parts of r47925, and implement an alternate + fix (localize the coordinate check to GraphicsContext::clipPath()). + This fixes http://crbug.com/21174. + + Covered by LayoutTests/svg/dynamic-updates/SVGClipPathElement-dom-clipPathUnits-attr.html. + + * platform/graphics/skia/GraphicsContextSkia.cpp: + (WebCore::GraphicsContext::clipPath): + * platform/graphics/skia/PlatformContextSkia.cpp: + (PlatformContextSkia::currentPathInLocalCoordinates): + +2009-09-24 Brady Eidson + + Reviewed by Sam Weinig. + + Merge changes from Mozilla's FTP directory parser. + and https://bugs.webkit.org/show_bug.cgi?id=29294 + + FTP layout tests not possible at this time. + https://bugs.webkit.org/show_bug.cgi?id=29719 tracks making them possible. + + * loader/FTPDirectoryParser.cpp: + (WebCore::ParsingFailed): + (WebCore::parseOneFTPLine): + +2009-09-24 Philippe Normand + + Reviewed by Gustavo Noronha. + + [GTK] re-enable some media tests + https://bugs.webkit.org/show_bug.cgi?id=29716 + + make canPlayType() return "probably" if mime-type is known + and codecs string is not empty. If codecs is empty return + "maybe". + + * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: + (WebCore::MediaPlayerPrivate::supportsType): + +2009-09-24 Sam Weinig + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=29703 + Add a function to element to check whether it matches a CSS selector + + Implement Element.webkitMatchesSelector. + + * css/CSSSelectorList.cpp: + (WebCore::forEachTagSelector): + (WebCore::forEachSelector): + (WebCore::SelectorNeedsNamespaceResolutionFunctor::operator()): + (WebCore::CSSSelectorList::selectorsNeedNamespaceResolution): + * css/CSSSelectorList.h: + Moved code to iterate the CSSSelectorList and determine if any + selectors need namespace resolution from a static function in + Node.cpp to CSSSelectorList so that it can be used by webkitMatchesSelector + as well as querySelector/querySelectorAll. + + * dom/Element.cpp: + (WebCore::Element::webkitMatchesSelector): + * dom/Element.h: + * dom/Element.idl: + Implement the new function. Handles exceptional cases identically to + querySelector/querySelectorAll. + + * dom/Node.cpp: + (WebCore::Node::querySelector): + (WebCore::Node::querySelectorAll): + Moved selectorsNeedNamespaceResolution to CSSSelectorList from here. + +2009-09-24 Vitaly Repeshko + + Reviewed by Dimitri Glazkov. + + [V8] Fixed bindings build after http://trac.webkit.org/changeset/48701 + https://bugs.webkit.org/show_bug.cgi?id=29713 + + Got rid of isWindowEvent in function signatures: + * bindings/v8/V8AbstractEventListener.cpp: + (WebCore::V8AbstractEventListener::invokeEventHandler): + (WebCore::V8AbstractEventListener::handleEvent): + (WebCore::V8AbstractEventListener::getReceiverObject): + * bindings/v8/V8AbstractEventListener.h: + * bindings/v8/V8LazyEventListener.cpp: + (WebCore::V8LazyEventListener::callListenerFunction): + * bindings/v8/V8LazyEventListener.h: + * bindings/v8/V8WorkerContextEventListener.cpp: + (WebCore::V8WorkerContextEventListener::handleEvent): + (WebCore::V8WorkerContextEventListener::callListenerFunction): + (WebCore::V8WorkerContextEventListener::getReceiverObject): + * bindings/v8/V8WorkerContextEventListener.h: + * bindings/v8/custom/V8CustomEventListener.cpp: + (WebCore::V8EventListener::callListenerFunction): + * bindings/v8/custom/V8CustomEventListener.h: + + Switched to EventTarget methods of adding/removing listeners: + * bindings/v8/custom/V8DOMApplicationCacheCustom.cpp: + (WebCore::toEventID): + (WebCore::ACCESSOR_SETTER): + + * dom/EventTarget.h: Some functions were incorrectly marked + as JSC-specific. + +2009-09-24 Pavel Feldman + + Reviewed by Timothy Hatcher. + + Web Inspector: Color-code watch expression errors with red. + + https://bugs.webkit.org/show_bug.cgi?id=29707 + + * inspector/front-end/WatchExpressionsSidebarPane.js: + (WebInspector.WatchExpressionsSection.prototype.update): + (WebInspector.WatchExpressionTreeElement.prototype.update): + * inspector/front-end/inspector.css: + +2009-09-24 Pavel Feldman + + Reviewed by Timothy Hatcher. + + Web Inspector: Fix formatting for messages derived from resource warnings, + couple of drive-by formatting fixes. + + https://bugs.webkit.org/show_bug.cgi?id=29705 + + * inspector/InspectorFrontend.cpp: + (WebCore::InspectorFrontend::addMessageToConsole): + * inspector/front-end/ConsoleView.js: + * inspector/front-end/InjectedScript.js: + (InjectedScript._evaluateAndWrap): + * inspector/front-end/WatchExpressionsSidebarPane.js: + (WebInspector.WatchExpressionsSection.prototype.update): + +2009-09-22 Pavel Feldman + + Reviewed by Timothy Hatcher. + + WebInspector: Implement InspectorController::copyNode(id). + + https://bugs.webkit.org/show_bug.cgi?id=28357 + + * inspector/InspectorBackend.cpp: + (WebCore::InspectorBackend::copyNode): + * inspector/InspectorBackend.h: + * inspector/InspectorBackend.idl: + * inspector/front-end/ElementsPanel.js: + (WebInspector.ElementsPanel.prototype.handleCopyEvent): + +2009-09-24 Oliver Hunt + + Reviewed by NOBODY(rollout) + + Roll out r48712 as it is incorrect. + + Overriding getPropertyNames is incorrect. + + * bridge/runtime_array.cpp: + * bridge/runtime_array.h: + +2009-09-24 Xan Lopez + + Revert r48697, since it broke key handling notification to GTK+. + + * platform/gtk/KeyEventGtk.cpp: + (WebCore::keyIdentifierForGdkKeyCode): + (WebCore::singleCharacterString): + +2009-09-24 Philippe Normand + + Reviewed by Xan Lopez. + + [GTK] GStreamer MediaPlayer is unable to correctly querry duration + https://bugs.webkit.org/show_bug.cgi?id=24639 + + check duration returned by gst_element_query_duration() only + when using GStreamer < 0.10.23. + + * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: + (WebCore::MediaPlayerPrivate::duration): + +2009-09-24 Benjamin Poulain + + Reviewed by Eric Seidel. + + The indices of RuntimeArray should be enumerated like for a regular array. + https://bugs.webkit.org/show_bug.cgi?id=29005 + + * bridge/runtime_array.cpp: + (JSC::RuntimeArray::getPropertyNames): + * bridge/runtime_array.h: + +2009-09-23 Alexander Pavlov + + Reviewed by Eric Seidel. + + Introduce Pasteboard::writePlaintext(const String&) so that copying + of the inspected elements HTML will be possible in WebInspector. + https://bugs.webkit.org/show_bug.cgi?id=29634 + + * platform/Pasteboard.h: + * platform/android/TemporaryLinkStubs.cpp: + (Pasteboard::writePlainText): + * platform/chromium/ChromiumBridge.h: + * platform/chromium/PasteboardChromium.cpp: + (WebCore::Pasteboard::writePlainText): + * platform/gtk/PasteboardGtk.cpp: + (WebCore::Pasteboard::writePlainText): + * platform/haiku/PasteboardHaiku.cpp: + (WebCore::Pasteboard::writePlainText): + * platform/mac/PasteboardMac.mm: + (WebCore::Pasteboard::writePlainText): + * platform/qt/PasteboardQt.cpp: + (WebCore::Pasteboard::writePlainText): + * platform/win/PasteboardWin.cpp: + (WebCore::Pasteboard::writeSelection): + (WebCore::Pasteboard::writePlainText): + * platform/wince/PasteboardWince.cpp: + (WebCore::Pasteboard::writePlainText): + * platform/wx/PasteboardWx.cpp: + (WebCore::Pasteboard::writeSelection): + (WebCore::Pasteboard::writePlainText): + (WebCore::Pasteboard::writeURL): + 2009-09-24 Oswald Buddenhagen Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/WebCore.gypi b/src/3rdparty/webkit/WebCore/WebCore.gypi index 758d99d..e91076b 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.gypi +++ b/src/3rdparty/webkit/WebCore/WebCore.gypi @@ -76,11 +76,27 @@ 'dom/WebKitAnimationEvent.idl', 'dom/WebKitTransitionEvent.idl', 'dom/WheelEvent.idl', + 'html/canvas/CanvasArray.idl', + 'html/canvas/CanvasArrayBuffer.idl', + 'html/canvas/CanvasBuffer.idl', + 'html/canvas/CanvasByteArray.idl', + 'html/canvas/CanvasFloatArray.idl', + 'html/canvas/CanvasFramebuffer.idl', 'html/canvas/CanvasGradient.idl', + 'html/canvas/CanvasIntArray.idl', 'html/canvas/CanvasPattern.idl', 'html/canvas/CanvasPixelArray.idl', + 'html/canvas/CanvasProgram.idl', + 'html/canvas/CanvasRenderbuffer.idl', 'html/canvas/CanvasRenderingContext.idl', 'html/canvas/CanvasRenderingContext2D.idl', + 'html/canvas/CanvasRenderingContext3D.idl', + 'html/canvas/CanvasShader.idl', + 'html/canvas/CanvasShortArray.idl', + 'html/canvas/CanvasUnsignedByteArray.idl', + 'html/canvas/CanvasUnsignedIntArray.idl', + 'html/canvas/CanvasUnsignedShortArray.idl', + 'html/canvas/CanvasTexture.idl', 'html/DataGridColumn.idl', 'html/DataGridColumnList.idl', 'html/File.idl', @@ -607,7 +623,17 @@ 'bindings/v8/custom/V8AbstractWorkerCustom.cpp', 'bindings/v8/custom/V8AttrCustom.cpp', 'bindings/v8/custom/V8CanvasPixelArrayCustom.cpp', + 'bindings/v8/custom/V8CanvasArrayCustom.h', + 'bindings/v8/custom/V8CanvasArrayBufferCustom.cpp', + 'bindings/v8/custom/V8CanvasByteArrayCustom.cpp', + 'bindings/v8/custom/V8CanvasIntArrayCustom.cpp', + 'bindings/v8/custom/V8CanvasFloatArrayCustom.cpp', + 'bindings/v8/custom/V8CanvasShortArrayCustom.cpp', + 'bindings/v8/custom/V8CanvasUnsignedByteArrayCustom.cpp', + 'bindings/v8/custom/V8CanvasUnsignedIntArrayCustom.cpp', + 'bindings/v8/custom/V8CanvasUnsignedShortArrayCustom.cpp', 'bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp', + 'bindings/v8/custom/V8CanvasRenderingContext3DCustom.cpp', 'bindings/v8/custom/V8ClientRectListCustom.cpp', 'bindings/v8/custom/V8ClipboardCustom.cpp', 'bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp', @@ -1221,18 +1247,52 @@ 'history/HistoryItem.h', 'history/PageCache.cpp', 'history/PageCache.h', + 'html/canvas/CanvasArray.cpp', + 'html/canvas/CanvasArray.h', + 'html/canvas/CanvasArrayBuffer.cpp', + 'html/canvas/CanvasArrayBuffer.h', + 'html/canvas/CanvasBuffer.cpp', + 'html/canvas/CanvasBuffer.h', + 'html/canvas/CanvasByteArray.cpp', + 'html/canvas/CanvasByteArray.h', + 'html/canvas/CanvasFloatArray.cpp', + 'html/canvas/CanvasFloatArray.h', + 'html/canvas/CanvasFramebuffer.cpp', + 'html/canvas/CanvasFramebuffer.h', 'html/canvas/CanvasGradient.cpp', 'html/canvas/CanvasGradient.h', + 'html/canvas/CanvasIntArray.cpp', + 'html/canvas/CanvasIntArray.h', + 'html/canvas/CanvasObject.cpp', + 'html/canvas/CanvasObject.h', 'html/canvas/CanvasPattern.cpp', 'html/canvas/CanvasPattern.h', 'html/canvas/CanvasPixelArray.cpp', 'html/canvas/CanvasPixelArray.h', + 'html/canvas/CanvasProgram.cpp', + 'html/canvas/CanvasProgram.h', + 'html/canvas/CanvasRenderbuffer.cpp', + 'html/canvas/CanvasRenderbuffer.h', 'html/canvas/CanvasRenderingContext.cpp', 'html/canvas/CanvasRenderingContext.h', 'html/canvas/CanvasRenderingContext2D.cpp', 'html/canvas/CanvasRenderingContext2D.h', + 'html/canvas/CanvasRenderingContext3D.cpp', + 'html/canvas/CanvasRenderingContext3D.h', + 'html/canvas/CanvasShader.cpp', + 'html/canvas/CanvasShader.h', + 'html/canvas/CanvasShortArray.cpp', + 'html/canvas/CanvasShortArray.h', 'html/canvas/CanvasStyle.cpp', 'html/canvas/CanvasStyle.h', + 'html/canvas/CanvasTexture.cpp', + 'html/canvas/CanvasTexture.h', + 'html/canvas/CanvasUnsignedByteArray.cpp', + 'html/canvas/CanvasUnsignedByteArray.h', + 'html/canvas/CanvasUnsignedIntArray.cpp', + 'html/canvas/CanvasUnsignedIntArray.h', + 'html/canvas/CanvasUnsignedShortArray.cpp', + 'html/canvas/CanvasUnsignedShortArray.h', 'html/CollectionCache.cpp', 'html/CollectionCache.h', 'html/CollectionType.h', @@ -1667,6 +1727,7 @@ 'page/Geolocation.cpp', 'page/Geolocation.h', 'page/Geoposition.h', + 'page/HaltablePlugin.h', 'page/History.cpp', 'page/History.h', 'page/Location.cpp', @@ -1685,6 +1746,9 @@ 'page/PageGroup.h', 'page/PageGroupLoadDeferrer.cpp', 'page/PageGroupLoadDeferrer.h', + 'page/PluginHalter.cpp', + 'page/PluginHalter.h', + 'page/PluginHalterClient.h', 'page/PositionCallback.h', 'page/PositionError.h', 'page/PositionErrorCallback.h', @@ -2081,6 +2145,7 @@ 'platform/graphics/Gradient.h', 'platform/graphics/GraphicsContext.cpp', 'platform/graphics/GraphicsContext.h', + 'platform/graphics/GraphicsContext3D.h', 'platform/graphics/GraphicsContextPrivate.h', 'platform/graphics/GraphicsLayer.cpp', 'platform/graphics/GraphicsLayer.h', diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index de3717d..540abad 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -113,6 +113,7 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) { !contains(DEFINES, ENABLE_DOM_STORAGE=.): DEFINES += ENABLE_DOM_STORAGE=1 !contains(DEFINES, ENABLE_ICONDATABASE=.): DEFINES += ENABLE_ICONDATABASE=1 !contains(DEFINES, ENABLE_CHANNEL_MESSAGING=.): DEFINES += ENABLE_CHANNEL_MESSAGING=1 +!contains(DEFINES, ENABLE_ORIENTATION_EVENTS=.): DEFINES += ENABLE_ORIENTATION_EVENTS=0 # turn on SQLITE support if any of the dependent features are turned on !contains(DEFINES, ENABLE_SQLITE=.) { @@ -1137,6 +1138,7 @@ SOURCES += \ page/Page.cpp \ page/PageGroup.cpp \ page/PageGroupLoadDeferrer.cpp \ + page/PluginHalter.cpp \ page/PrintContext.cpp \ page/SecurityOrigin.cpp \ page/Screen.cpp \ @@ -1811,6 +1813,7 @@ HEADERS += \ page/FrameView.h \ page/Geolocation.h \ page/Geoposition.h \ + page/HaltablePlugin.h \ page/History.h \ page/Location.h \ page/MouseEventWithHitTestResults.h \ @@ -1819,6 +1822,8 @@ HEADERS += \ page/PageGroup.h \ page/PageGroupLoadDeferrer.h \ page/Page.h \ + page/PluginHalter.h \ + page/PluginHalterClient.h \ page/PrintContext.h \ page/Screen.h \ page/SecurityOrigin.h \ @@ -2482,6 +2487,10 @@ contains(DEFINES, ENABLE_CHANNEL_MESSAGING=1) { FEATURE_DEFINES_JAVASCRIPT += ENABLE_CHANNEL_MESSAGING=1 } +contains(DEFINES, ENABLE_ORIENTATION_EVENTS=1) { + FEATURE_DEFINES_JAVASCRIPT += ENABLE_ORIENTATION_EVENTS=1 +} + contains(DEFINES, ENABLE_DASHBOARD_SUPPORT=0) { DASHBOARDSUPPORTCSSPROPERTIES -= $$PWD/css/DashboardSupportCSSPropertyNames.in } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSAttrCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSAttrCustom.cpp index e217023..14457c4 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSAttrCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSAttrCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -59,4 +59,16 @@ void JSAttr::setValue(ExecState* exec, JSValue value) setDOMException(exec, ec); } +void JSAttr::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + // Mark the element so that this will work to access the attribute even if the last + // other reference goes away. + if (Element* element = impl()->ownerElement()) { + if (JSNode* wrapper = getCachedDOMNodeWrapper(element->document(), element)) + markStack.append(wrapper); + } +} + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp index c80441d..583d971 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp @@ -254,7 +254,7 @@ JSValue JSInspectorBackend::currentCallFrame(ExecState* exec, const ArgList&) return jsUndefined(); // FIXME: I am not sure if this is actually needed. Can we just use exec? - ExecState* globalExec = callFrame->scopeChain()->globalObject()->globalExec(); + ExecState* globalExec = callFrame->scopeChain()->globalObject->globalExec(); JSLock lock(SilenceAssertionsOnly); return JSInspectedObjectWrapper::wrap(globalExec, toJS(exec, callFrame)); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodeMapCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodeMapCustom.cpp index 7bd95b4..1974ab0 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodeMapCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodeMapCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,10 +27,9 @@ #include "JSNamedNodeMap.h" #include "JSNode.h" + +#include "Element.h" #include "NamedNodeMap.h" -#include "Node.h" -#include "PlatformString.h" -#include "JSDOMBinding.h" using namespace JSC; @@ -47,4 +46,16 @@ JSValue JSNamedNodeMap::nameGetter(ExecState* exec, const Identifier& propertyNa return toJS(exec, thisObj->impl()->getNamedItem(propertyName)); } +void JSNamedNodeMap::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + // Mark the element so that this will work to access the attribute even if the last + // other reference goes away. + if (Element* element = impl()->element()) { + if (JSNode* wrapper = getCachedDOMNodeWrapper(element->document(), element)) + markStack.append(wrapper); + } +} + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm index a18de49..1cbe8d2 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -1596,7 +1596,24 @@ sub IsRefPtrType { my $type = shift; return 1 if $type eq "Attr"; + return 1 if $type eq "CanvasArray"; + return 1 if $type eq "CanvasArrayBuffer"; + return 1 if $type eq "CanvasBooleanArray"; + return 1 if $type eq "CanvasByteArray"; + return 1 if $type eq "CanvasBuffer"; + return 1 if $type eq "CanvasFloatArray"; + return 1 if $type eq "CanvasFramebuffer"; return 1 if $type eq "CanvasGradient"; + return 1 if $type eq "CanvasIntArray"; + return 1 if $type eq "CanvasObject"; + return 1 if $type eq "CanvasProgram"; + return 1 if $type eq "CanvasRenderbuffer"; + return 1 if $type eq "CanvasShader"; + return 1 if $type eq "CanvasShortArray"; + return 1 if $type eq "CanvasTexture"; + return 1 if $type eq "CanvasUnsignedByteArray"; + return 1 if $type eq "CanvasUnsignedIntArray"; + return 1 if $type eq "CanvasUnsignedShortArray"; return 1 if $type eq "ClientRect"; return 1 if $type eq "ClientRectList"; return 1 if $type eq "CDATASection"; @@ -1725,6 +1742,19 @@ sub GetNativeType my %typeCanFailConversion = ( "AtomicString" => 0, "Attr" => 1, + "CanvasArray" => 0, + "CanvasBuffer" => 0, + "CanvasByteArray" => 0, + "CanvasFloatArray" => 0, + "CanvasFramebuffer" => 0, + "CanvasGradient" => 0, + "CanvasIntArray" => 0, + "CanvasPixelArray" => 0, + "CanvasProgram" => 0, + "CanvasRenderbuffer" => 0, + "CanvasShader" => 0, + "CanvasShortArray" => 0, + "CanvasTexture" => 0, "CompareHow" => 0, "DataGridColumn" => 0, "DOMString" => 0, @@ -1734,8 +1764,11 @@ my %typeCanFailConversion = ( "Event" => 0, "EventListener" => 0, "EventTarget" => 0, + "HTMLCanvasElement" => 0, "HTMLElement" => 0, + "HTMLImageElement" => 0, "HTMLOptionElement" => 0, + "HTMLVideoElement" => 0, "Node" => 0, "NodeFilter" => 0, "MessagePort" => 0, diff --git a/src/3rdparty/webkit/WebCore/css/CSSImportRule.cpp b/src/3rdparty/webkit/WebCore/css/CSSImportRule.cpp index 9dafba9..6e62f6d 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSImportRule.cpp +++ b/src/3rdparty/webkit/WebCore/css/CSSImportRule.cpp @@ -111,7 +111,10 @@ void CSSImportRule::insertedIntoParent() root = curr; } - m_cachedSheet = docLoader->requestCSSStyleSheet(absHref, parentSheet->charset()); + if (parentSheet->isUserStyleSheet()) + m_cachedSheet = docLoader->requestUserCSSStyleSheet(absHref, parentSheet->charset()); + else + m_cachedSheet = docLoader->requestCSSStyleSheet(absHref, parentSheet->charset()); if (m_cachedSheet) { // if the import rule is issued dynamically, the sheet may be // removed from the pending sheet count, so let the doc know diff --git a/src/3rdparty/webkit/WebCore/css/CSSSelectorList.cpp b/src/3rdparty/webkit/WebCore/css/CSSSelectorList.cpp index f12d64f..7f82ca4 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSSelectorList.cpp +++ b/src/3rdparty/webkit/WebCore/css/CSSSelectorList.cpp @@ -89,4 +89,51 @@ void CSSSelectorList::deleteSelectors() } } + +template +static bool forEachTagSelector(Functor& functor, CSSSelector* selector) +{ + ASSERT(selector); + + do { + if (functor(selector)) + return true; + if (CSSSelector* simpleSelector = selector->simpleSelector()) { + if (forEachTagSelector(functor, simpleSelector)) + return true; + } + } while ((selector = selector->tagHistory())); + + return false; +} + +template +static bool forEachSelector(Functor& functor, const CSSSelectorList* selectorList) +{ + for (CSSSelector* selector = selectorList->first(); selector; selector = CSSSelectorList::next(selector)) { + if (forEachTagSelector(functor, selector)) + return true; + } + + return false; +} + +class SelectorNeedsNamespaceResolutionFunctor { +public: + bool operator()(CSSSelector* selector) + { + if (selector->hasTag() && selector->m_tag.prefix() != nullAtom && selector->m_tag.prefix() != starAtom) + return true; + if (selector->hasAttribute() && selector->attribute().prefix() != nullAtom && selector->attribute().prefix() != starAtom) + return true; + return false; + } +}; + +bool CSSSelectorList::selectorsNeedNamespaceResolution() +{ + SelectorNeedsNamespaceResolutionFunctor functor; + return forEachSelector(functor, this); } + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/css/CSSSelectorList.h b/src/3rdparty/webkit/WebCore/css/CSSSelectorList.h index 3518139..9e40ef8 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSSelectorList.h +++ b/src/3rdparty/webkit/WebCore/css/CSSSelectorList.h @@ -31,25 +31,27 @@ namespace WebCore { - class CSSSelectorList : public Noncopyable { - public: - CSSSelectorList() : m_selectorArray(0) { } - ~CSSSelectorList(); - - void adopt(CSSSelectorList& list); - void adoptSelectorVector(Vector& selectorVector); - - CSSSelector* first() const { return m_selectorArray ? m_selectorArray : 0; } - static CSSSelector* next(CSSSelector* previous) { return previous->isLastInSelectorList() ? 0 : previous + 1; } - bool hasOneSelector() const { return m_selectorArray ? m_selectorArray->isLastInSelectorList() : false; } - - private: - void deleteSelectors(); - - // End of the array is indicated by m_isLastInSelectorList bit in the last item. - CSSSelector* m_selectorArray; - }; - -} - -#endif +class CSSSelectorList : public Noncopyable { +public: + CSSSelectorList() : m_selectorArray(0) { } + ~CSSSelectorList(); + + void adopt(CSSSelectorList& list); + void adoptSelectorVector(Vector& selectorVector); + + CSSSelector* first() const { return m_selectorArray ? m_selectorArray : 0; } + static CSSSelector* next(CSSSelector* previous) { return previous->isLastInSelectorList() ? 0 : previous + 1; } + bool hasOneSelector() const { return m_selectorArray ? m_selectorArray->isLastInSelectorList() : false; } + + bool selectorsNeedNamespaceResolution(); + +private: + void deleteSelectors(); + + // End of the array is indicated by m_isLastInSelectorList bit in the last item. + CSSSelector* m_selectorArray; +}; + +} // namespace WebCore + +#endif // CSSSelectorList_h diff --git a/src/3rdparty/webkit/WebCore/css/CSSStyleSheet.cpp b/src/3rdparty/webkit/WebCore/css/CSSStyleSheet.cpp index ce50af6..1579999 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSStyleSheet.cpp +++ b/src/3rdparty/webkit/WebCore/css/CSSStyleSheet.cpp @@ -40,20 +40,22 @@ CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, con , m_charset(charset) , m_loadCompleted(false) , m_strictParsing(!parentSheet || parentSheet->useStrictParsing()) + , m_isUserStyleSheet(parentSheet ? parentSheet->isUserStyleSheet() : false) { } -CSSStyleSheet::CSSStyleSheet(Node *parentNode, const String& href, const String& charset) +CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const String& charset) : StyleSheet(parentNode, href) , m_doc(parentNode->document()) , m_namespaces(0) , m_charset(charset) , m_loadCompleted(false) , m_strictParsing(false) + , m_isUserStyleSheet(false) { } -CSSStyleSheet::CSSStyleSheet(CSSRule *ownerRule, const String& href, const String& charset) +CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const String& charset) : StyleSheet(ownerRule, href) , m_namespaces(0) , m_charset(charset) @@ -62,6 +64,7 @@ CSSStyleSheet::CSSStyleSheet(CSSRule *ownerRule, const String& href, const Strin { CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0; m_doc = parentSheet ? parentSheet->doc() : 0; + m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false; } CSSStyleSheet::~CSSStyleSheet() diff --git a/src/3rdparty/webkit/WebCore/css/CSSStyleSheet.h b/src/3rdparty/webkit/WebCore/css/CSSStyleSheet.h index 8646ee9..f534104 100644 --- a/src/3rdparty/webkit/WebCore/css/CSSStyleSheet.h +++ b/src/3rdparty/webkit/WebCore/css/CSSStyleSheet.h @@ -93,6 +93,9 @@ public: void setStrictParsing(bool b) { m_strictParsing = b; } bool useStrictParsing() const { return m_strictParsing; } + void setIsUserStyleSheet(bool b) { m_isUserStyleSheet = b; } + bool isUserStyleSheet() const { return m_isUserStyleSheet; } + private: CSSStyleSheet(Node* ownerNode, const String& href, const String& charset); CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const String& charset); @@ -106,6 +109,7 @@ private: String m_charset; bool m_loadCompleted : 1; bool m_strictParsing : 1; + bool m_isUserStyleSheet : 1; }; } // namespace diff --git a/src/3rdparty/webkit/WebCore/dom/Attr.idl b/src/3rdparty/webkit/WebCore/dom/Attr.idl index 29f4be1..c01f34a 100644 --- a/src/3rdparty/webkit/WebCore/dom/Attr.idl +++ b/src/3rdparty/webkit/WebCore/dom/Attr.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2006 Samuel Weinig * * This library is free software; you can redistribute it and/or @@ -21,6 +21,7 @@ module core { interface [ + CustomMarkFunction, GenerateConstructor, GenerateNativeConverter, InterfaceUUID=EEE8E22B-22C3-4e50-95F4-5E0B8AAD8231, diff --git a/src/3rdparty/webkit/WebCore/dom/Document.cpp b/src/3rdparty/webkit/WebCore/dom/Document.cpp index 5422bf0..174c0ee 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Document.cpp @@ -1941,7 +1941,8 @@ CSSStyleSheet* Document::pageUserSheet() return 0; // Parse the sheet and cache it. - m_pageUserSheet = CSSStyleSheet::create(this); + m_pageUserSheet = CSSStyleSheet::create(this, settings()->userStyleSheetLocation()); + m_pageUserSheet->setIsUserStyleSheet(true); m_pageUserSheet->parseString(userSheetText, !inCompatMode()); return m_pageUserSheet.get(); } @@ -1973,7 +1974,8 @@ const Vector >* Document::pageGroupUserSheets() const const UserStyleSheetVector* sheets = it->second; for (unsigned i = 0; i < sheets->size(); ++i) { const UserStyleSheet* sheet = sheets->at(i).get(); - RefPtr parsedSheet = CSSStyleSheet::create(const_cast(this)); + RefPtr parsedSheet = CSSStyleSheet::create(const_cast(this), sheet->url()); + parsedSheet->setIsUserStyleSheet(true); parsedSheet->parseString(sheet->source(), !inCompatMode()); if (!m_pageGroupUserSheets) m_pageGroupUserSheets.set(new Vector >); @@ -3011,7 +3013,7 @@ String Document::domain() const return securityOrigin()->domain(); } -void Document::setDomain(const String& newDomain) +void Document::setDomain(const String& newDomain, ExceptionCode& ec) { // Both NS and IE specify that changing the domain is only allowed when // the new domain is a suffix of the old domain. @@ -3034,19 +3036,25 @@ void Document::setDomain(const String& newDomain) int oldLength = domain().length(); int newLength = newDomain.length(); // e.g. newDomain = webkit.org (10) and domain() = www.webkit.org (14) - if (newLength >= oldLength) + if (newLength >= oldLength) { + ec = SECURITY_ERR; return; + } String test = domain(); // Check that it's a subdomain, not e.g. "ebkit.org" - if (test[oldLength - newLength - 1] != '.') + if (test[oldLength - newLength - 1] != '.') { + ec = SECURITY_ERR; return; + } // Now test is "webkit.org" from domain() // and we check that it's the same thing as newDomain test.remove(0, oldLength - newLength); - if (test != newDomain) + if (test != newDomain) { + ec = SECURITY_ERR; return; + } securityOrigin()->setDomainFromDOM(newDomain); if (m_frame) diff --git a/src/3rdparty/webkit/WebCore/dom/Document.h b/src/3rdparty/webkit/WebCore/dom/Document.h index 454304b..2805562 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.h +++ b/src/3rdparty/webkit/WebCore/dom/Document.h @@ -672,7 +672,7 @@ public: String referrer() const; String domain() const; - void setDomain(const String& newDomain); + void setDomain(const String& newDomain, ExceptionCode&); String lastModified() const; diff --git a/src/3rdparty/webkit/WebCore/dom/Document.idl b/src/3rdparty/webkit/WebCore/dom/Document.idl index 34a9771..822f860 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.idl +++ b/src/3rdparty/webkit/WebCore/dom/Document.idl @@ -155,7 +155,8 @@ module core { attribute [ConvertNullToNullString] DOMString title; readonly attribute DOMString referrer; #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - attribute [ConvertNullToNullString] DOMString domain; + attribute [ConvertNullToNullString] DOMString domain + setter raises (DOMException); #else readonly attribute DOMString domain; #endif diff --git a/src/3rdparty/webkit/WebCore/dom/Element.cpp b/src/3rdparty/webkit/WebCore/dom/Element.cpp index f04723f..50ff033 100644 --- a/src/3rdparty/webkit/WebCore/dom/Element.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Element.cpp @@ -28,6 +28,8 @@ #include "AXObjectCache.h" #include "Attr.h" +#include "CSSParser.h" +#include "CSSSelectorList.h" #include "CSSStyleSelector.h" #include "CString.h" #include "ClientRect.h" @@ -280,42 +282,6 @@ static int adjustForLocalZoom(int value, RenderObject* renderer) return static_cast(value / zoomFactor); } -static int adjustForAbsoluteZoom(int value, RenderObject* renderer) -{ - float zoomFactor = renderer->style()->effectiveZoom(); - if (zoomFactor == 1) - return value; - // Needed because computeLengthInt truncates (rather than rounds) when scaling up. - if (zoomFactor > 1) - value++; - return static_cast(value / zoomFactor); -} - -static FloatPoint adjustFloatPointForAbsoluteZoom(const FloatPoint& point, RenderObject* renderer) -{ - // The result here is in floats, so we don't need the truncation hack from the integer version above. - float zoomFactor = renderer->style()->effectiveZoom(); - if (zoomFactor == 1) - return point; - return FloatPoint(point.x() / zoomFactor, point.y() / zoomFactor); -} - -static void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer) -{ - quad.setP1(adjustFloatPointForAbsoluteZoom(quad.p1(), renderer)); - quad.setP2(adjustFloatPointForAbsoluteZoom(quad.p2(), renderer)); - quad.setP3(adjustFloatPointForAbsoluteZoom(quad.p3(), renderer)); - quad.setP4(adjustFloatPointForAbsoluteZoom(quad.p4(), renderer)); -} - -static void adjustIntRectForAbsoluteZoom(IntRect& rect, RenderObject* renderer) -{ - rect.setX(adjustForAbsoluteZoom(rect.x(), renderer)); - rect.setY(adjustForAbsoluteZoom(rect.y(), renderer)); - rect.setWidth(adjustForAbsoluteZoom(rect.width(), renderer)); - rect.setHeight(adjustForAbsoluteZoom(rect.height(), renderer)); -} - int Element::offsetLeft() { document()->updateLayoutIgnorePendingStylesheets(); @@ -1406,6 +1372,39 @@ unsigned Element::childElementCount() const return count; } +bool Element::webkitMatchesSelector(const String& selector, ExceptionCode& ec) +{ + if (selector.isEmpty()) { + ec = SYNTAX_ERR; + return false; + } + + bool strictParsing = !document()->inCompatMode(); + CSSParser p(strictParsing); + + CSSSelectorList selectorList; + p.parseSelector(selector, document(), selectorList); + + if (!selectorList.first()) { + ec = SYNTAX_ERR; + return false; + } + + // Throw a NAMESPACE_ERR if the selector includes any namespace prefixes. + if (selectorList.selectorsNeedNamespaceResolution()) { + ec = NAMESPACE_ERR; + return false; + } + + CSSStyleSelector::SelectorChecker selectorChecker(document(), strictParsing); + for (CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) { + if (selectorChecker.checkSelector(selector, this)) + return true; + } + + return false; +} + KURL Element::getURLAttribute(const QualifiedName& name) const { #ifndef NDEBUG diff --git a/src/3rdparty/webkit/WebCore/dom/Element.h b/src/3rdparty/webkit/WebCore/dom/Element.h index 4ecf932..d27976a 100644 --- a/src/3rdparty/webkit/WebCore/dom/Element.h +++ b/src/3rdparty/webkit/WebCore/dom/Element.h @@ -231,6 +231,8 @@ public: Element* nextElementSibling() const; unsigned childElementCount() const; + bool webkitMatchesSelector(const String& selectors, ExceptionCode&); + virtual bool isFormControlElement() const { return false; } virtual bool isEnabledFormControl() const { return true; } virtual bool isReadOnlyFormControl() const { return false; } diff --git a/src/3rdparty/webkit/WebCore/dom/Element.idl b/src/3rdparty/webkit/WebCore/dom/Element.idl index cbb36d9..d90f819 100644 --- a/src/3rdparty/webkit/WebCore/dom/Element.idl +++ b/src/3rdparty/webkit/WebCore/dom/Element.idl @@ -111,6 +111,10 @@ module core { raises(DOMException); #if !defined(LANGUAGE_COM) || !LANGUAGE_COM + // WebKit extension, pending specification. + boolean webkitMatchesSelector(in DOMString selectors) + raises(DOMException); + // ElementTraversal API readonly attribute Element firstElementChild; readonly attribute Element lastElementChild; diff --git a/src/3rdparty/webkit/WebCore/dom/EventTarget.h b/src/3rdparty/webkit/WebCore/dom/EventTarget.h index 4499328..2d612e1 100644 --- a/src/3rdparty/webkit/WebCore/dom/EventTarget.h +++ b/src/3rdparty/webkit/WebCore/dom/EventTarget.h @@ -202,6 +202,7 @@ namespace WebCore { d->eventListenerMap.clear(); } +#endif inline bool EventTarget::isFiringEventListeners() { @@ -227,8 +228,6 @@ namespace WebCore { return d->eventListenerMap.contains(eventType); } -#endif - } // namespace WebCore #endif // EventTarget_h diff --git a/src/3rdparty/webkit/WebCore/dom/InputElement.cpp b/src/3rdparty/webkit/WebCore/dom/InputElement.cpp index 96e31f4..c29cb1c 100644 --- a/src/3rdparty/webkit/WebCore/dom/InputElement.cpp +++ b/src/3rdparty/webkit/WebCore/dom/InputElement.cpp @@ -56,8 +56,6 @@ void InputElement::dispatchFocusEvent(InputElement* inputElement, Element* eleme if (!inputElement->isTextField()) return; - updatePlaceholderVisibility(inputElement, element); - Document* document = element->document(); if (inputElement->isPasswordField() && document->frame()) document->setUseSecureKeyboardEntryWhenActive(true); @@ -73,29 +71,12 @@ void InputElement::dispatchBlurEvent(InputElement* inputElement, Element* elemen if (!frame) return; - updatePlaceholderVisibility(inputElement, element); - if (inputElement->isPasswordField()) document->setUseSecureKeyboardEntryWhenActive(false); frame->textFieldDidEndEditing(element); } -bool InputElement::placeholderShouldBeVisible(const InputElement* inputElement, const Element* element) -{ - return inputElement->value().isEmpty() - && element->document()->focusedNode() != element - && !inputElement->placeholder().isEmpty(); -} - -void InputElement::updatePlaceholderVisibility(InputElement* inputElement, Element* element, bool placeholderValueChanged) -{ - ASSERT(inputElement->isTextField()); - bool placeholderVisible = inputElement->placeholderShouldBeVisible(); - if (element->renderer()) - toRenderTextControlSingleLine(element->renderer())->updatePlaceholderVisibility(placeholderVisible, placeholderValueChanged); -} - void InputElement::updateFocusAppearance(InputElementData& data, InputElement* inputElement, Element* element, bool restorePreviousSelection) { ASSERT(inputElement->isTextField()); @@ -138,10 +119,7 @@ void InputElement::aboutToUnload(InputElement* inputElement, Element* element) void InputElement::setValueFromRenderer(InputElementData& data, InputElement* inputElement, Element* element, const String& value) { // Renderer and our event handler are responsible for sanitizing values. - ASSERT(value == inputElement->sanitizeValue(value) || inputElement->sanitizeValue(value).isEmpty()); - - if (inputElement->isTextField()) - updatePlaceholderVisibility(inputElement, element); + ASSERT_UNUSED(inputElement, value == inputElement->sanitizeValue(value) || inputElement->sanitizeValue(value).isEmpty()); // Workaround for bug where trailing \n is included in the result of textContent. // The assert macro above may also be simplified to: value == constrainValue(value) diff --git a/src/3rdparty/webkit/WebCore/dom/InputElement.h b/src/3rdparty/webkit/WebCore/dom/InputElement.h index 746e4f2..e0e7110 100644 --- a/src/3rdparty/webkit/WebCore/dom/InputElement.h +++ b/src/3rdparty/webkit/WebCore/dom/InputElement.h @@ -44,16 +44,12 @@ public: virtual bool isSearchField() const = 0; virtual bool isTextField() const = 0; - virtual bool placeholderShouldBeVisible() const = 0; virtual bool searchEventsShouldBeDispatched() const = 0; virtual int size() const = 0; virtual String value() const = 0; virtual void setValue(const String&) = 0; - virtual String placeholder() const = 0; - virtual void setPlaceholder(const String&) = 0; - virtual String sanitizeValue(const String&) const = 0; virtual void setValueFromRenderer(const String&) = 0; @@ -66,8 +62,6 @@ public: protected: static void dispatchFocusEvent(InputElement*, Element*); static void dispatchBlurEvent(InputElement*, Element*); - static bool placeholderShouldBeVisible(const InputElement*, const Element*); - static void updatePlaceholderVisibility(InputElement*, Element*, bool placeholderValueChanged = false); static void updateFocusAppearance(InputElementData&, InputElement*, Element*, bool restorePreviousSelection); static void updateSelectionRange(InputElement*, Element*, int start, int end); static void aboutToUnload(InputElement*, Element*); diff --git a/src/3rdparty/webkit/WebCore/dom/NamedAttrMap.cpp b/src/3rdparty/webkit/WebCore/dom/NamedAttrMap.cpp index fe631c8..d4ec598 100644 --- a/src/3rdparty/webkit/WebCore/dom/NamedAttrMap.cpp +++ b/src/3rdparty/webkit/WebCore/dom/NamedAttrMap.cpp @@ -178,10 +178,8 @@ Attribute* NamedNodeMap::getAttributeItem(const String& name, bool shouldIgnoreA { unsigned len = length(); for (unsigned i = 0; i < len; ++i) { - if (!m_attributes[i]->name().hasPrefix() && - m_attributes[i]->name().localName() == name) - return m_attributes[i].get(); - + if (!m_attributes[i]->name().hasPrefix() && m_attributes[i]->name().localName() == name) + return m_attributes[i].get(); if (shouldIgnoreAttributeCase ? equalIgnoringCase(m_attributes[i]->name().toString(), name) : name == m_attributes[i]->name().toString()) return m_attributes[i].get(); } @@ -206,10 +204,12 @@ void NamedNodeMap::clearAttributes() void NamedNodeMap::detachFromElement() { - // we allow a NamedNodeMap w/o an element in case someone still has a reference - // to if after the element gets deleted - but the map is now invalid + // This can't happen if the holder of the map is JavaScript, because we mark the + // element if the map is alive. So it has no impact on web page behavior. Because + // of that, we can simply clear all the attributes to avoid accessing stale + // pointers to do things like create Attr objects. m_element = 0; - detachAttributesFromElement(); + clearAttributes(); } void NamedNodeMap::setAttributes(const NamedNodeMap& other) @@ -251,7 +251,7 @@ void NamedNodeMap::addAttribute(PassRefPtr prpAttribute) attr->m_element = m_element; // Notify the element that the attribute has been added, and dispatch appropriate mutation events - // Note that element may be null here if we are called from insertAttr() during parsing + // Note that element may be null here if we are called from insertAttribute() during parsing if (m_element) { m_element->attributeChanged(attribute.get()); // Because of our updateStyleAttribute() style modification events are never sent at the right time, so don't bother sending them. @@ -265,12 +265,13 @@ void NamedNodeMap::addAttribute(PassRefPtr prpAttribute) void NamedNodeMap::removeAttribute(const QualifiedName& name) { unsigned len = length(); - unsigned index = len + 1; - for (unsigned i = 0; i < len; ++i) + unsigned index = len; + for (unsigned i = 0; i < len; ++i) { if (m_attributes[i]->name().matches(name)) { index = i; break; } + } if (index >= len) return; diff --git a/src/3rdparty/webkit/WebCore/dom/NamedAttrMap.h b/src/3rdparty/webkit/WebCore/dom/NamedAttrMap.h index 4fb96de..759900b 100644 --- a/src/3rdparty/webkit/WebCore/dom/NamedAttrMap.h +++ b/src/3rdparty/webkit/WebCore/dom/NamedAttrMap.h @@ -94,11 +94,11 @@ public: void addAttribute(PassRefPtr); void removeAttribute(const QualifiedName&); + Element* element() const { return m_element; } + protected: virtual void clearAttributes(); - Element* element() const { return m_element; } - private: void detachAttributesFromElement(); void detachFromElement(); diff --git a/src/3rdparty/webkit/WebCore/dom/NamedNodeMap.idl b/src/3rdparty/webkit/WebCore/dom/NamedNodeMap.idl index 3310ded..8166853 100644 --- a/src/3rdparty/webkit/WebCore/dom/NamedNodeMap.idl +++ b/src/3rdparty/webkit/WebCore/dom/NamedNodeMap.idl @@ -1,6 +1,6 @@ /* * Copyright (C) 2006 Samuel Weinig - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,6 +21,7 @@ module core { interface [ + CustomMarkFunction, GenerateConstructor, HasIndexGetter, HasNameGetter, diff --git a/src/3rdparty/webkit/WebCore/dom/Node.cpp b/src/3rdparty/webkit/WebCore/dom/Node.cpp index 2240dd8..c899f3d 100644 --- a/src/3rdparty/webkit/WebCore/dom/Node.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Node.cpp @@ -1626,52 +1626,6 @@ PassRefPtr Node::getElementsByClassName(const String& classNames) return ClassNodeList::create(this, classNames, result.first->second.get()); } -template -static bool forEachTagSelector(Functor& functor, CSSSelector* selector) -{ - ASSERT(selector); - - do { - if (functor(selector)) - return true; - if (CSSSelector* simpleSelector = selector->simpleSelector()) { - if (forEachTagSelector(functor, simpleSelector)) - return true; - } - } while ((selector = selector->tagHistory())); - - return false; -} - -template -static bool forEachSelector(Functor& functor, const CSSSelectorList& selectorList) -{ - for (CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) { - if (forEachTagSelector(functor, selector)) - return true; - } - - return false; -} - -class SelectorNeedsNamespaceResolutionFunctor { -public: - bool operator()(CSSSelector* selector) - { - if (selector->hasTag() && selector->m_tag.prefix() != nullAtom && selector->m_tag.prefix() != starAtom) - return true; - if (selector->hasAttribute() && selector->attribute().prefix() != nullAtom && selector->attribute().prefix() != starAtom) - return true; - return false; - } -}; - -static bool selectorNeedsNamespaceResolution(const CSSSelectorList& selectorList) -{ - SelectorNeedsNamespaceResolutionFunctor functor; - return forEachSelector(functor, selectorList); -} - PassRefPtr Node::querySelector(const String& selectors, ExceptionCode& ec) { if (selectors.isEmpty()) { @@ -1690,7 +1644,7 @@ PassRefPtr Node::querySelector(const String& selectors, ExceptionCode& } // throw a NAMESPACE_ERR if the selector includes any namespace prefixes. - if (selectorNeedsNamespaceResolution(querySelectorList)) { + if (querySelectorList.selectorsNeedNamespaceResolution()) { ec = NAMESPACE_ERR; return 0; } @@ -1738,7 +1692,7 @@ PassRefPtr Node::querySelectorAll(const String& selectors, ExceptionCo } // Throw a NAMESPACE_ERR if the selector includes any namespace prefixes. - if (selectorNeedsNamespaceResolution(querySelectorList)) { + if (querySelectorList.selectorsNeedNamespaceResolution()) { ec = NAMESPACE_ERR; return 0; } diff --git a/src/3rdparty/webkit/WebCore/dom/Range.cpp b/src/3rdparty/webkit/WebCore/dom/Range.cpp index 0503597..122130d 100644 --- a/src/3rdparty/webkit/WebCore/dom/Range.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Range.cpp @@ -3,7 +3,7 @@ * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) * (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -26,7 +26,10 @@ #include "RangeException.h" #include "CString.h" +#include "ClientRect.h" +#include "ClientRectList.h" #include "DocumentFragment.h" +#include "FrameView.h" #include "HTMLElement.h" #include "NodeWithIndex.h" #include "ProcessingInstruction.h" @@ -1821,4 +1824,89 @@ void Range::expand(const String& unit, ExceptionCode& ec) setEnd(end.deepEquivalent().containerNode(), end.deepEquivalent().computeOffsetInContainerNode(), ec); } +PassRefPtr Range::getClientRects() const +{ + if (!m_start.container()) + return 0; + + m_ownerDocument->updateLayoutIgnorePendingStylesheets(); + + Vector quads; + getBorderAndTextQuads(quads); + + return ClientRectList::create(quads); +} + +PassRefPtr Range::getBoundingClientRect() const +{ + if (!m_start.container()) + return 0; + + m_ownerDocument->updateLayoutIgnorePendingStylesheets(); + + Vector quads; + getBorderAndTextQuads(quads); + + if (quads.isEmpty()) + return ClientRect::create(); + + IntRect result; + for (size_t i = 0; i < quads.size(); ++i) + result.unite(quads[i].enclosingBoundingBox()); + + return ClientRect::create(result); +} + +static void adjustFloatQuadsForScrollAndAbsoluteZoom(Vector& quads, Document* document, RenderObject* renderer) +{ + FrameView* view = document->view(); + if (!view) + return; + + IntRect visibleContentRect = view->visibleContentRect(); + for (size_t i = 0; i < quads.size(); ++i) { + quads[i].move(-visibleContentRect.x(), -visibleContentRect.y()); + adjustFloatQuadForAbsoluteZoom(quads[i], renderer); + } +} + +void Range::getBorderAndTextQuads(Vector& quads) const +{ + Node* startContainer = m_start.container(); + Node* endContainer = m_end.container(); + Node* stopNode = pastLastNode(); + + HashSet nodeSet; + for (Node* node = firstNode(); node != stopNode; node = node->traverseNextNode()) { + if (node->isElementNode()) + nodeSet.add(node); + } + + for (Node* node = firstNode(); node != stopNode; node = node->traverseNextNode()) { + if (node->isElementNode()) { + if (!nodeSet.contains(node->parentNode())) { + if (RenderBoxModelObject* renderBoxModelObject = static_cast(node)->renderBoxModelObject()) { + Vector elementQuads; + renderBoxModelObject->absoluteQuads(elementQuads); + adjustFloatQuadsForScrollAndAbsoluteZoom(elementQuads, m_ownerDocument.get(), renderBoxModelObject); + + quads.append(elementQuads); + } + } + } else if (node->isTextNode()) { + if (RenderObject* renderer = static_cast(node)->renderer()) { + RenderText* renderText = toRenderText(renderer); + int startOffset = (node == startContainer) ? m_start.offset() : 0; + int endOffset = (node == endContainer) ? m_end.offset() : INT_MAX; + + Vector textQuads; + renderText->absoluteQuadsForRange(textQuads, startOffset, endOffset); + adjustFloatQuadsForScrollAndAbsoluteZoom(textQuads, m_ownerDocument.get(), renderText); + + quads.append(textQuads); + } + } + } } + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/Range.h b/src/3rdparty/webkit/WebCore/dom/Range.h index 3382c84..e2e282b 100644 --- a/src/3rdparty/webkit/WebCore/dom/Range.h +++ b/src/3rdparty/webkit/WebCore/dom/Range.h @@ -3,7 +3,7 @@ * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) * (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -25,12 +25,15 @@ #ifndef Range_h #define Range_h +#include "FloatQuad.h" #include "RangeBoundaryPoint.h" +#include #include -#include namespace WebCore { +class ClientRect; +class ClientRectList; class DocumentFragment; class NodeWithIndex; class Text; @@ -117,6 +120,9 @@ public: // for details. void expand(const String&, ExceptionCode&); + PassRefPtr getClientRects() const; + PassRefPtr getBoundingClientRect() const; + #ifndef NDEBUG void formatForDebugger(char* buffer, unsigned length) const; #endif @@ -135,6 +141,8 @@ private: enum ActionType { DELETE_CONTENTS, EXTRACT_CONTENTS, CLONE_CONTENTS }; PassRefPtr processContents(ActionType, ExceptionCode&); + void getBorderAndTextQuads(Vector&) const; + RefPtr m_ownerDocument; RangeBoundaryPoint m_start; RangeBoundaryPoint m_end; diff --git a/src/3rdparty/webkit/WebCore/dom/Range.idl b/src/3rdparty/webkit/WebCore/dom/Range.idl index 633bd90..9024e09 100644 --- a/src/3rdparty/webkit/WebCore/dom/Range.idl +++ b/src/3rdparty/webkit/WebCore/dom/Range.idl @@ -85,6 +85,13 @@ module ranges { void detach() raises(DOMException); +#if defined(LANGUAGE_JAVASCRIPT) || LANGUAGE_JAVASCRIPT + // CSSOM View Module API extensions + + ClientRectList getClientRects(); + ClientRect getBoundingClientRect(); +#endif + // extensions DocumentFragment createContextualFragment(in DOMString html) diff --git a/src/3rdparty/webkit/WebCore/dom/RegisteredEventListener.h b/src/3rdparty/webkit/WebCore/dom/RegisteredEventListener.h index 88d2279..c34a341 100644 --- a/src/3rdparty/webkit/WebCore/dom/RegisteredEventListener.h +++ b/src/3rdparty/webkit/WebCore/dom/RegisteredEventListener.h @@ -29,7 +29,8 @@ namespace WebCore { - struct RegisteredEventListener { + class RegisteredEventListener { + public: RegisteredEventListener(PassRefPtr listener, bool useCapture) : listener(listener) , useCapture(useCapture) diff --git a/src/3rdparty/webkit/WebCore/dom/Text.cpp b/src/3rdparty/webkit/WebCore/dom/Text.cpp index 00db1c1..1ce074a 100644 --- a/src/3rdparty/webkit/WebCore/dom/Text.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Text.cpp @@ -315,10 +315,15 @@ PassRefPtr Text::createWithLengthLimit(Document* document, const String& d unsigned end = start + min(charsLeft, maxChars); // Check we are not on an unbreakable boundary. - TextBreakIterator* it = characterBreakIterator(data.characters(), dataLength); - if (end < dataLength && !isTextBreak(it, end)) - end = textBreakPreceding(it, end); - + // Some text break iterator implementations work best if the passed buffer is as small as possible, + // see . + // We need at least two characters look-ahead to account for UTF-16 surrogates. + if (end < dataLength) { + TextBreakIterator* it = characterBreakIterator(data.characters() + start, (end + 2 > dataLength) ? dataLength - start : end - start + 2); + if (!isTextBreak(it, end - start)) + end = textBreakPreceding(it, end - start) + start; + } + // If we have maxChars of unbreakable characters the above could lead to // an infinite loop. // FIXME: It would be better to just have the old value of end before calling diff --git a/src/3rdparty/webkit/WebCore/editing/InsertParagraphSeparatorCommand.cpp b/src/3rdparty/webkit/WebCore/editing/InsertParagraphSeparatorCommand.cpp index 9823aba..695f46a 100644 --- a/src/3rdparty/webkit/WebCore/editing/InsertParagraphSeparatorCommand.cpp +++ b/src/3rdparty/webkit/WebCore/editing/InsertParagraphSeparatorCommand.cpp @@ -103,6 +103,30 @@ bool InsertParagraphSeparatorCommand::shouldUseDefaultParagraphElement(Node* enc enclosingBlock->hasTagName(h5Tag); } +void InsertParagraphSeparatorCommand::getAncestorsInsideBlock(const Node* insertionNode, Element* outerBlock, Vector& ancestors) +{ + ancestors.clear(); + + // Build up list of ancestors elements between the insertion node and the outer block. + if (insertionNode != outerBlock) { + for (Element* n = insertionNode->parentElement(); n && n != outerBlock; n = n->parentElement()) + ancestors.append(n); + } +} + +PassRefPtr InsertParagraphSeparatorCommand::cloneHierarchyUnderNewBlock(const Vector& ancestors, PassRefPtr blockToInsert) +{ + // Make clones of ancestors in between the start node and the start block. + RefPtr parent = blockToInsert; + for (size_t i = ancestors.size(); i != 0; --i) { + RefPtr child = ancestors[i - 1]->cloneElementWithoutChildren(); + appendNode(child, parent); + parent = child.release(); + } + + return parent.release(); +} + void InsertParagraphSeparatorCommand::doApply() { bool splitText = false; @@ -193,12 +217,18 @@ void InsertParagraphSeparatorCommand::doApply() insertNodeAfter(blockToInsert, startBlock); } - appendBlockPlaceholder(blockToInsert); - setEndingSelection(VisibleSelection(Position(blockToInsert.get(), 0), DOWNSTREAM)); - if (shouldApplyStyleAfterInsertion) - applyStyleAfterInsertion(startBlock); + // Recreate the same structure in the new paragraph. + + Vector ancestors; + getAncestorsInsideBlock(insertionPosition.node(), startBlock, ancestors); + RefPtr parent = cloneHierarchyUnderNewBlock(ancestors, blockToInsert); + + appendBlockPlaceholder(parent); + + setEndingSelection(VisibleSelection(Position(parent.get(), 0), DOWNSTREAM)); return; } + //--------------------------------------------------------------------- // Handle case when position is in the first visible position in its block, and @@ -217,9 +247,15 @@ void InsertParagraphSeparatorCommand::doApply() insertionPosition = insertionPosition.downstream(); insertNodeBefore(blockToInsert, refNode); - appendBlockPlaceholder(blockToInsert.get()); - setEndingSelection(VisibleSelection(Position(blockToInsert.get(), 0), DOWNSTREAM)); - applyStyleAfterInsertion(startBlock); + + // Recreate the same structure in the new paragraph. + + Vector ancestors; + getAncestorsInsideBlock(positionAvoidingSpecialElementBoundary(insertionPosition).node(), startBlock, ancestors); + + appendBlockPlaceholder(cloneHierarchyUnderNewBlock(ancestors, blockToInsert)); + + // In this case, we need to set the new ending selection. setEndingSelection(VisibleSelection(insertionPosition, DOWNSTREAM)); return; } @@ -248,10 +284,7 @@ void InsertParagraphSeparatorCommand::doApply() // Build up list of ancestors in between the start node and the start block. Vector ancestors; - if (insertionPosition.node() != startBlock) { - for (Element* n = insertionPosition.node()->parentElement(); n && n != startBlock; n = n->parentElement()) - ancestors.append(n); - } + getAncestorsInsideBlock(insertionPosition.node(), startBlock, ancestors); // Make sure we do not cause a rendered space to become unrendered. // FIXME: We need the affinity for pos, but pos.downstream() does not give it @@ -284,13 +317,8 @@ void InsertParagraphSeparatorCommand::doApply() updateLayout(); - // Make clones of ancestors in between the start node and the start block. - RefPtr parent = blockToInsert; - for (size_t i = ancestors.size(); i != 0; --i) { - RefPtr child = ancestors[i - 1]->cloneElementWithoutChildren(); - appendNode(child, parent); - parent = child.release(); - } + // Make clones of ancestors in between the start node and the outer block. + RefPtr parent = cloneHierarchyUnderNewBlock(ancestors, blockToInsert); // If the paragraph separator was inserted at the end of a paragraph, an empty line must be // created. All of the nodes, starting at visiblePos, are about to be added to the new paragraph diff --git a/src/3rdparty/webkit/WebCore/editing/InsertParagraphSeparatorCommand.h b/src/3rdparty/webkit/WebCore/editing/InsertParagraphSeparatorCommand.h index 01c08bf..23ee51c 100644 --- a/src/3rdparty/webkit/WebCore/editing/InsertParagraphSeparatorCommand.h +++ b/src/3rdparty/webkit/WebCore/editing/InsertParagraphSeparatorCommand.h @@ -44,6 +44,8 @@ private: void calculateStyleBeforeInsertion(const Position&); void applyStyleAfterInsertion(Node* originalEnclosingBlock); + void getAncestorsInsideBlock(const Node* insertionNode, Element* outerBlock, Vector& ancestors); + PassRefPtr cloneHierarchyUnderNewBlock(const Vector& ancestors, PassRefPtr blockToInsert); bool shouldUseDefaultParagraphElement(Node*) const; diff --git a/src/3rdparty/webkit/WebCore/generated/JSAttr.h b/src/3rdparty/webkit/WebCore/generated/JSAttr.h index e7fd69c..c6843ec 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSAttr.h +++ b/src/3rdparty/webkit/WebCore/generated/JSAttr.h @@ -44,6 +44,8 @@ public: return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType)); } + virtual void markChildren(JSC::MarkStack&); + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); // Custom attributes @@ -62,6 +64,10 @@ public: static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; + static PassRefPtr createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType)); + } JSAttrPrototype(PassRefPtr structure) : JSC::JSObject(structure) { } }; diff --git a/src/3rdparty/webkit/WebCore/generated/JSDocument.cpp b/src/3rdparty/webkit/WebCore/generated/JSDocument.cpp index 772be76..9820998 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDocument.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDocument.cpp @@ -1045,7 +1045,9 @@ void setJSDocumentTitle(ExecState* exec, JSObject* thisObject, JSValue value) void setJSDocumentDomain(ExecState* exec, JSObject* thisObject, JSValue value) { Document* imp = static_cast(static_cast(thisObject)->impl()); - imp->setDomain(valueToStringWithNullCheck(exec, value)); + ExceptionCode ec = 0; + imp->setDomain(valueToStringWithNullCheck(exec, value), ec); + setDOMException(exec, ec); } void setJSDocumentCookie(ExecState* exec, JSObject* thisObject, JSValue value) diff --git a/src/3rdparty/webkit/WebCore/generated/JSElement.cpp b/src/3rdparty/webkit/WebCore/generated/JSElement.cpp index f487532..c074e40 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSElement.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSElement.cpp @@ -171,7 +171,7 @@ bool JSElementConstructor::getOwnPropertyDescriptor(ExecState* exec, const Ident /* Hash table for prototype */ -static const HashTableValue JSElementPrototypeTableValues[28] = +static const HashTableValue JSElementPrototypeTableValues[29] = { { "getAttribute", DontDelete|Function, (intptr_t)jsElementPrototypeFunctionGetAttribute, (intptr_t)1 }, { "setAttribute", DontDelete|Function, (intptr_t)jsElementPrototypeFunctionSetAttribute, (intptr_t)2 }, @@ -198,6 +198,7 @@ static const HashTableValue JSElementPrototypeTableValues[28] = { "getElementsByClassName", DontDelete|Function, (intptr_t)jsElementPrototypeFunctionGetElementsByClassName, (intptr_t)1 }, { "querySelector", DontDelete|Function, (intptr_t)jsElementPrototypeFunctionQuerySelector, (intptr_t)1 }, { "querySelectorAll", DontDelete|Function, (intptr_t)jsElementPrototypeFunctionQuerySelectorAll, (intptr_t)1 }, + { "webkitMatchesSelector", DontDelete|Function, (intptr_t)jsElementPrototypeFunctionWebkitMatchesSelector, (intptr_t)1 }, { "getClientRects", DontDelete|Function, (intptr_t)jsElementPrototypeFunctionGetClientRects, (intptr_t)0 }, { "getBoundingClientRect", DontDelete|Function, (intptr_t)jsElementPrototypeFunctionGetBoundingClientRect, (intptr_t)0 }, { 0, 0, 0, 0 } @@ -1633,6 +1634,22 @@ JSValue JSC_HOST_CALL jsElementPrototypeFunctionQuerySelectorAll(ExecState* exec return result; } +JSValue JSC_HOST_CALL jsElementPrototypeFunctionWebkitMatchesSelector(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSElement::s_info)) + return throwError(exec, TypeError); + JSElement* castedThisObj = static_cast(asObject(thisValue)); + Element* imp = static_cast(castedThisObj->impl()); + ExceptionCode ec = 0; + const UString& selectors = args.at(0).toString(exec); + + + JSC::JSValue result = jsBoolean(imp->webkitMatchesSelector(selectors, ec)); + setDOMException(exec, ec); + return result; +} + JSValue JSC_HOST_CALL jsElementPrototypeFunctionGetClientRects(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); diff --git a/src/3rdparty/webkit/WebCore/generated/JSElement.h b/src/3rdparty/webkit/WebCore/generated/JSElement.h index 8d72032..770dc43 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSElement.h +++ b/src/3rdparty/webkit/WebCore/generated/JSElement.h @@ -116,6 +116,7 @@ JSC::JSValue JSC_HOST_CALL jsElementPrototypeFunctionScrollByPages(JSC::ExecStat JSC::JSValue JSC_HOST_CALL jsElementPrototypeFunctionGetElementsByClassName(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsElementPrototypeFunctionQuerySelector(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsElementPrototypeFunctionQuerySelectorAll(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsElementPrototypeFunctionWebkitMatchesSelector(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsElementPrototypeFunctionGetClientRects(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsElementPrototypeFunctionGetBoundingClientRect(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); // Attributes diff --git a/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.cpp b/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.cpp index 77b4b7c..7059003 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.cpp @@ -96,7 +96,7 @@ bool JSInspectorBackendConstructor::getOwnPropertyDescriptor(ExecState* exec, co /* Hash table for prototype */ -static const HashTableValue JSInspectorBackendPrototypeTableValues[69] = +static const HashTableValue JSInspectorBackendPrototypeTableValues[70] = { { "hideDOMNodeHighlight", DontDelete|Function, (intptr_t)jsInspectorBackendPrototypeFunctionHideDOMNodeHighlight, (intptr_t)0 }, { "highlightDOMNode", DontDelete|Function, (intptr_t)jsInspectorBackendPrototypeFunctionHighlightDOMNode, (intptr_t)1 }, @@ -156,6 +156,7 @@ static const HashTableValue JSInspectorBackendPrototypeTableValues[69] = { "setAttribute", DontDelete|Function, (intptr_t)jsInspectorBackendPrototypeFunctionSetAttribute, (intptr_t)4 }, { "removeAttribute", DontDelete|Function, (intptr_t)jsInspectorBackendPrototypeFunctionRemoveAttribute, (intptr_t)3 }, { "setTextNodeValue", DontDelete|Function, (intptr_t)jsInspectorBackendPrototypeFunctionSetTextNodeValue, (intptr_t)3 }, + { "copyNode", DontDelete|Function, (intptr_t)jsInspectorBackendPrototypeFunctionCopyNode, (intptr_t)1 }, { "nodeForId", DontDelete|Function, (intptr_t)jsInspectorBackendPrototypeFunctionNodeForId, (intptr_t)1 }, { "wrapObject", DontDelete|Function, (intptr_t)jsInspectorBackendPrototypeFunctionWrapObject, (intptr_t)1 }, { "unwrapObject", DontDelete|Function, (intptr_t)jsInspectorBackendPrototypeFunctionUnwrapObject, (intptr_t)1 }, @@ -955,6 +956,19 @@ JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionSetTextNodeValue(ExecSt return jsUndefined(); } +JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionCopyNode(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSInspectorBackend::s_info)) + return throwError(exec, TypeError); + JSInspectorBackend* castedThisObj = static_cast(asObject(thisValue)); + InspectorBackend* imp = static_cast(castedThisObj->impl()); + int nodeId = args.at(0).toInt32(exec); + + imp->copyNode(nodeId); + return jsUndefined(); +} + JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionNodeForId(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); diff --git a/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.h b/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.h index fec9031..37fd8b8 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.h +++ b/src/3rdparty/webkit/WebCore/generated/JSInspectorBackend.h @@ -148,6 +148,7 @@ JSC::JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionGetChildNodes(JSC: JSC::JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionSetAttribute(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionRemoveAttribute(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionSetTextNodeValue(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionCopyNode(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionNodeForId(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionWrapObject(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsInspectorBackendPrototypeFunctionUnwrapObject(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); diff --git a/src/3rdparty/webkit/WebCore/generated/JSNamedNodeMap.h b/src/3rdparty/webkit/WebCore/generated/JSNamedNodeMap.h index 3b73a2d..11b3101 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSNamedNodeMap.h +++ b/src/3rdparty/webkit/WebCore/generated/JSNamedNodeMap.h @@ -47,6 +47,8 @@ public: return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType)); } + virtual void markChildren(JSC::MarkStack&); + virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); NamedNodeMap* impl() const { return m_impl.get(); } @@ -72,7 +74,7 @@ public: virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); static PassRefPtr createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, JSC::HasDefaultMark)); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType)); } JSNamedNodeMapPrototype(PassRefPtr structure) : JSC::JSObject(structure) { } }; diff --git a/src/3rdparty/webkit/WebCore/generated/JSRange.cpp b/src/3rdparty/webkit/WebCore/generated/JSRange.cpp index 9968a29..8faa98f 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSRange.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSRange.cpp @@ -21,7 +21,11 @@ #include "config.h" #include "JSRange.h" +#include "ClientRect.h" +#include "ClientRectList.h" #include "DocumentFragment.h" +#include "JSClientRect.h" +#include "JSClientRectList.h" #include "JSDocumentFragment.h" #include "JSNode.h" #include "JSRange.h" @@ -114,7 +118,7 @@ bool JSRangeConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identif /* Hash table for prototype */ -static const HashTableValue JSRangePrototypeTableValues[33] = +static const HashTableValue JSRangePrototypeTableValues[35] = { { "START_TO_START", DontDelete|ReadOnly, (intptr_t)jsRangeSTART_TO_START, (intptr_t)0 }, { "START_TO_END", DontDelete|ReadOnly, (intptr_t)jsRangeSTART_TO_END, (intptr_t)0 }, @@ -142,6 +146,8 @@ static const HashTableValue JSRangePrototypeTableValues[33] = { "cloneRange", DontDelete|Function, (intptr_t)jsRangePrototypeFunctionCloneRange, (intptr_t)0 }, { "toString", DontDelete|Function, (intptr_t)jsRangePrototypeFunctionToString, (intptr_t)0 }, { "detach", DontDelete|Function, (intptr_t)jsRangePrototypeFunctionDetach, (intptr_t)0 }, + { "getClientRects", DontDelete|Function, (intptr_t)jsRangePrototypeFunctionGetClientRects, (intptr_t)0 }, + { "getBoundingClientRect", DontDelete|Function, (intptr_t)jsRangePrototypeFunctionGetBoundingClientRect, (intptr_t)0 }, { "createContextualFragment", DontDelete|Function, (intptr_t)jsRangePrototypeFunctionCreateContextualFragment, (intptr_t)1 }, { "intersectsNode", DontDelete|Function, (intptr_t)jsRangePrototypeFunctionIntersectsNode, (intptr_t)1 }, { "compareNode", DontDelete|Function, (intptr_t)jsRangePrototypeFunctionCompareNode, (intptr_t)1 }, @@ -155,7 +161,7 @@ static JSC_CONST_HASHTABLE HashTable JSRangePrototypeTable = #if ENABLE(PERFECT_HASH_SIZE) { 1023, JSRangePrototypeTableValues, 0 }; #else - { 72, 63, JSRangePrototypeTableValues, 0 }; + { 132, 127, JSRangePrototypeTableValues, 0 }; #endif const ClassInfo JSRangePrototype::s_info = { "RangePrototype", 0, &JSRangePrototypeTable, 0 }; @@ -545,6 +551,32 @@ JSValue JSC_HOST_CALL jsRangePrototypeFunctionDetach(ExecState* exec, JSObject*, return jsUndefined(); } +JSValue JSC_HOST_CALL jsRangePrototypeFunctionGetClientRects(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSRange::s_info)) + return throwError(exec, TypeError); + JSRange* castedThisObj = static_cast(asObject(thisValue)); + Range* imp = static_cast(castedThisObj->impl()); + + + JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->getClientRects())); + return result; +} + +JSValue JSC_HOST_CALL jsRangePrototypeFunctionGetBoundingClientRect(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSRange::s_info)) + return throwError(exec, TypeError); + JSRange* castedThisObj = static_cast(asObject(thisValue)); + Range* imp = static_cast(castedThisObj->impl()); + + + JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->getBoundingClientRect())); + return result; +} + JSValue JSC_HOST_CALL jsRangePrototypeFunctionCreateContextualFragment(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); diff --git a/src/3rdparty/webkit/WebCore/generated/JSRange.h b/src/3rdparty/webkit/WebCore/generated/JSRange.h index 1752888..6bd51e9 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSRange.h +++ b/src/3rdparty/webkit/WebCore/generated/JSRange.h @@ -91,6 +91,8 @@ JSC::JSValue JSC_HOST_CALL jsRangePrototypeFunctionSurroundContents(JSC::ExecSta JSC::JSValue JSC_HOST_CALL jsRangePrototypeFunctionCloneRange(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsRangePrototypeFunctionToString(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsRangePrototypeFunctionDetach(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsRangePrototypeFunctionGetClientRects(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsRangePrototypeFunctionGetBoundingClientRect(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsRangePrototypeFunctionCreateContextualFragment(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsRangePrototypeFunctionIntersectsNode(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsRangePrototypeFunctionCompareNode(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); diff --git a/src/3rdparty/webkit/WebCore/html/HTMLFormControlElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLFormControlElement.cpp index bc74ecf..8e66fe0 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLFormControlElement.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLFormControlElement.cpp @@ -39,6 +39,7 @@ #include "MappedAttribute.h" #include "Page.h" #include "RenderBox.h" +#include "RenderTextControl.h" #include "RenderTheme.h" #include "ValidityState.h" @@ -368,4 +369,43 @@ void HTMLFormControlElementWithState::finishParsingChildren() } } +HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* form) + : HTMLFormControlElementWithState(tagName, doc, form) +{ +} + +HTMLTextFormControlElement::~HTMLTextFormControlElement() +{ +} + +void HTMLTextFormControlElement::dispatchFocusEvent() +{ + if (supportsPlaceholder()) + updatePlaceholderVisibility(false); + handleFocusEvent(); + HTMLFormControlElementWithState::dispatchFocusEvent(); +} + +void HTMLTextFormControlElement::dispatchBlurEvent() +{ + if (supportsPlaceholder()) + updatePlaceholderVisibility(false); + handleBlurEvent(); + HTMLFormControlElementWithState::dispatchBlurEvent(); +} + +bool HTMLTextFormControlElement::placeholderShouldBeVisible() const +{ + return supportsPlaceholder() + && isEmptyValue() + && document()->focusedNode() != this + && !getAttribute(placeholderAttr).isEmpty(); +} + +void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderValueChanged) +{ + if (supportsPlaceholder() && renderer()) + toRenderTextControl(renderer())->updatePlaceholderVisibility(placeholderShouldBeVisible(), placeholderValueChanged); +} + } // namespace Webcore diff --git a/src/3rdparty/webkit/WebCore/html/HTMLFormControlElement.h b/src/3rdparty/webkit/WebCore/html/HTMLFormControlElement.h index ee7d772..7b3cfbd 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLFormControlElement.h +++ b/src/3rdparty/webkit/WebCore/html/HTMLFormControlElement.h @@ -143,6 +143,28 @@ protected: virtual void didMoveToNewOwnerDocument(); }; +class HTMLTextFormControlElement : public HTMLFormControlElementWithState { +public: + HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*); + virtual ~HTMLTextFormControlElement(); + virtual void dispatchFocusEvent(); + virtual void dispatchBlurEvent(); + +protected: + bool placeholderShouldBeVisible() const; + void updatePlaceholderVisibility(bool); + +private: + // A subclass should return true if placeholder processing is needed. + virtual bool supportsPlaceholder() const = 0; + // Returns true if user-editable value is empty. This is used to check placeholder visibility. + virtual bool isEmptyValue() const = 0; + // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent(). + virtual void handleFocusEvent() { } + // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent(). + virtual void handleBlurEvent() { } +}; + } //namespace #endif diff --git a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.cpp index 5ba780a..0aefe7f 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.cpp @@ -71,7 +71,7 @@ using namespace HTMLNames; const int maxSavedResults = 256; HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* f) - : HTMLFormControlElementWithState(tagName, doc, f) + : HTMLTextFormControlElement(tagName, doc, f) , m_xPos(0) , m_yPos(0) , m_maxResults(-1) @@ -257,20 +257,17 @@ bool HTMLInputElement::shouldUseInputMethod() const return m_type == TEXT || m_type == SEARCH || m_type == ISINDEX; } -void HTMLInputElement::dispatchFocusEvent() +void HTMLInputElement::handleFocusEvent() { InputElement::dispatchFocusEvent(this, this); if (isTextField()) m_autofilled = false; - - HTMLFormControlElementWithState::dispatchFocusEvent(); } -void HTMLInputElement::dispatchBlurEvent() +void HTMLInputElement::handleBlurEvent() { InputElement::dispatchBlurEvent(this, this); - HTMLFormControlElementWithState::dispatchBlurEvent(); } void HTMLInputElement::setType(const String& t) @@ -741,8 +738,7 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr) } setNeedsStyleRecalc(); } else if (attr->name() == placeholderAttr) { - if (isTextField()) - updatePlaceholderVisibility(); + updatePlaceholderVisibility(true); } else if (attr->name() == autosaveAttr || attr->name() == incrementalAttr || attr->name() == minAttr || @@ -814,7 +810,7 @@ RenderObject *HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle * case TELEPHONE: case TEXT: case URL: - return new (arena) RenderTextControlSingleLine(this); + return new (arena) RenderTextControlSingleLine(this, placeholderShouldBeVisible()); } ASSERT(false); return 0; @@ -1111,7 +1107,7 @@ void HTMLInputElement::setValue(const String& value) else { m_data.setValue(sanitizeValue(value)); if (isTextField()) { - InputElement::updatePlaceholderVisibility(this, this); + updatePlaceholderVisibility(false); if (inDocument()) document()->updateStyleIfNeeded(); } @@ -1151,6 +1147,7 @@ void HTMLInputElement::setValueFromRenderer(const String& value) { // File upload controls will always use setFileListFromRenderer. ASSERT(inputType() != FILE); + updatePlaceholderVisibility(false); InputElement::setValueFromRenderer(m_data, this, this, value); } @@ -1790,11 +1787,6 @@ bool HTMLInputElement::willValidate() const inputType() != BUTTON && inputType() != RESET; } -bool HTMLInputElement::placeholderShouldBeVisible() const -{ - return InputElement::placeholderShouldBeVisible(this, this); -} - bool HTMLInputElement::formStringToDouble(const String& src, double* out) { // See HTML5 2.4.4.3 `Real numbers.' diff --git a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h index 8f273cb..63d1634 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h +++ b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h @@ -37,7 +37,7 @@ class HTMLOptionElement; class KURL; class VisibleSelection; -class HTMLInputElement : public HTMLFormControlElementWithState, public InputElement { +class HTMLInputElement : public HTMLTextFormControlElement, public InputElement { public: enum InputType { TEXT, @@ -75,8 +75,6 @@ public: virtual bool isKeyboardFocusable(KeyboardEvent*) const; virtual bool isMouseFocusable() const; virtual bool isEnumeratable() const { return inputType() != IMAGE; } - virtual void dispatchFocusEvent(); - virtual void dispatchBlurEvent(); virtual void updateFocusAppearance(bool restorePreviousSelection); virtual void aboutToUnload(); virtual bool shouldUseInputMethod() const; @@ -230,8 +228,6 @@ public: virtual bool willValidate() const; - virtual bool placeholderShouldBeVisible() const; - // Converts the specified string to a floating number. // If the conversion fails, the return value is false. Take care that leading or trailing unnecessary characters make failures. This returns false for an empty string input. // The double* parameter may be 0. @@ -241,11 +237,6 @@ protected: virtual void willMoveToNewOwnerDocument(); virtual void didMoveToNewOwnerDocument(); - void updatePlaceholderVisibility() - { - InputElement::updatePlaceholderVisibility(this, this, true); - } - private: bool storesValueSeparateFromAttribute() const; @@ -253,6 +244,11 @@ private: void registerForActivationCallbackIfNeeded(); void unregisterForActivationCallbackIfNeeded(); + virtual bool supportsPlaceholder() const { return isTextField(); } + virtual bool isEmptyValue() const { return value().isEmpty(); } + virtual void handleFocusEvent(); + virtual void handleBlurEvent(); + virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); } virtual bool isRequiredFormControl() const; diff --git a/src/3rdparty/webkit/WebCore/html/HTMLIsIndexElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLIsIndexElement.cpp index bcfa623..31fafa6 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLIsIndexElement.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLIsIndexElement.cpp @@ -44,7 +44,7 @@ void HTMLIsIndexElement::parseMappedAttribute(MappedAttribute* attr) if (attr->name() == promptAttr) setValue(attr->value()); else if (attr->name() == placeholderAttr) - updatePlaceholderVisibility(); + updatePlaceholderVisibility(true); else // don't call HTMLInputElement::parseMappedAttribute here, as it would // accept attributes this element does not support diff --git a/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp index 3cf4852..f398fc2 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp @@ -63,7 +63,7 @@ static inline void notifyFormStateChanged(const HTMLTextAreaElement* element) } HTMLTextAreaElement::HTMLTextAreaElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form) - : HTMLFormControlElementWithState(tagName, document, form) + : HTMLTextFormControlElement(tagName, document, form) , m_rows(defaultRows) , m_cols(defaultCols) , m_wrap(SoftWrap) @@ -211,7 +211,7 @@ void HTMLTextAreaElement::parseMappedAttribute(MappedAttribute* attr) RenderObject* HTMLTextAreaElement::createRenderer(RenderArena* arena, RenderStyle*) { - return new (arena) RenderTextControlMultiLine(this); + return new (arena) RenderTextControlMultiLine(this, placeholderShouldBeVisible()); } bool HTMLTextAreaElement::appendFormData(FormDataList& encoding, bool) @@ -448,29 +448,4 @@ bool HTMLTextAreaElement::shouldUseInputMethod() const return true; } -bool HTMLTextAreaElement::placeholderShouldBeVisible() const -{ - return value().isEmpty() - && document()->focusedNode() != this - && !getAttribute(placeholderAttr).isEmpty(); -} - -void HTMLTextAreaElement::updatePlaceholderVisibility(bool placeholderValueChanged) -{ - if (renderer()) - toRenderTextControl(renderer())->updatePlaceholderVisibility(placeholderShouldBeVisible(), placeholderValueChanged); -} - -void HTMLTextAreaElement::dispatchFocusEvent() -{ - updatePlaceholderVisibility(false); - HTMLFormControlElementWithState::dispatchFocusEvent(); -} - -void HTMLTextAreaElement::dispatchBlurEvent() -{ - updatePlaceholderVisibility(false); - HTMLFormControlElementWithState::dispatchBlurEvent(); -} - } // namespace diff --git a/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.h b/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.h index fbf519d..ef96fc5 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.h +++ b/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.h @@ -31,7 +31,7 @@ namespace WebCore { class BeforeTextInsertedEvent; class VisibleSelection; -class HTMLTextAreaElement : public HTMLFormControlElementWithState { +class HTMLTextAreaElement : public HTMLTextFormControlElement { public: HTMLTextAreaElement(const QualifiedName&, Document*, HTMLFormElement* = 0); @@ -97,17 +97,15 @@ public: virtual bool shouldUseInputMethod() const; - bool placeholderShouldBeVisible() const; - private: enum WrapMethod { NoWrap, SoftWrap, HardWrap }; void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*) const; static String sanitizeUserInputValue(const String&, unsigned maxLength); void updateValue() const; - void updatePlaceholderVisibility(bool placeholderValueChanged); - virtual void dispatchFocusEvent(); - virtual void dispatchBlurEvent(); + + virtual bool supportsPlaceholder() const { return true; } + virtual bool isEmptyValue() const { return value().isEmpty(); } virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); } virtual bool isRequiredFormControl() const { return required(); } diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.cpp b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.cpp index c140b13..ad0c510 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.cpp @@ -45,6 +45,7 @@ #include "InspectorDOMAgent.h" #include "InspectorFrontend.h" #include "InspectorResource.h" +#include "Pasteboard.h" #include "ScriptFunctionCall.h" #if ENABLE(DOM_STORAGE) @@ -57,6 +58,8 @@ using namespace JSC; #endif +#include "markup.h" + #include #include @@ -446,6 +449,15 @@ void InspectorBackend::setTextNodeValue(long callId, long nodeId, const String& domAgent->setTextNodeValue(callId, nodeId, value); } +void InspectorBackend::copyNode(long nodeId) +{ + Node* node = nodeForId(nodeId); + if (!node) + return; + String markup = createMarkup(node); + Pasteboard::generalPasteboard()->writePlainText(markup); +} + void InspectorBackend::highlight(long nodeId) { if (Node* node = nodeForId(nodeId)) diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.h b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.h index 038ae14..739d28e 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.h +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.h @@ -138,6 +138,7 @@ public: void setAttribute(long callId, long elementId, const String& name, const String& value); void removeAttribute(long callId, long elementId, const String& name); void setTextNodeValue(long callId, long nodeId, const String& value); + void copyNode(long nodeId); // Generic code called from custom implementations. void highlight(long nodeId); diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.idl b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.idl index 395e7fd..d8ccf9f 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.idl +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.idl @@ -109,6 +109,7 @@ module core { void setAttribute(in long callId, in long elementId, in DOMString name, in DOMString value); void removeAttribute(in long callId, in long elementId, in DOMString name); void setTextNodeValue(in long callId, in long nodeId, in DOMString value); + void copyNode(in long nodeId); // Called from InjectedScript. [Custom] DOMObject nodeForId(in long nodeId); diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorController.cpp b/src/3rdparty/webkit/WebCore/inspector/InspectorController.cpp index 69a7e60..e65f21c 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorController.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorController.cpp @@ -503,6 +503,13 @@ void InspectorController::handleMousePressOnNode(Node* node) inspect(node); } +void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame) +{ + if (!enabled() || !m_frontend || frame != m_inspectedPage->mainFrame()) + return; + resetInjectedScript(); +} + void InspectorController::windowScriptObjectAvailable() { if (!m_page || !enabled()) @@ -644,9 +651,7 @@ void InspectorController::populateScriptObjects() if (!m_frontend) return; - // Initialize dom agent and reset injected script state first. - if (m_domAgent->setDocument(m_inspectedPage->mainFrame()->document())) - resetInjectedScript(); + m_domAgent->setDocument(m_inspectedPage->mainFrame()->document()); ResourcesMap::iterator resourcesEnd = m_resources.end(); for (ResourcesMap::iterator it = m_resources.begin(); it != resourcesEnd; ++it) @@ -694,6 +699,7 @@ void InspectorController::resetScriptObjects() m_timelineAgent->reset(); m_frontend->reset(); + m_domAgent->setDocument(0); } void InspectorController::pruneResources(ResourcesMap* resourceMap, DocumentLoader* loaderToKeep) @@ -758,10 +764,9 @@ void InspectorController::didCommitLoad(DocumentLoader* loader) // identifierForInitialRequest. m_mainResource = 0; } + if (windowVisible()) + m_domAgent->setDocument(m_inspectedPage->mainFrame()->document()); } - - if (m_domAgent && m_domAgent->setDocument(m_inspectedPage->mainFrame()->document())) - resetInjectedScript(); } for (Frame* frame = loader->frame(); frame; frame = frame->tree()->traverseNext(loader->frame())) @@ -1089,7 +1094,8 @@ void InspectorController::didOpenDatabase(Database* database, const String& doma m_databaseResources.add(resource); - if (m_frontend) + // Resources are only bound while visible. + if (m_frontend && windowVisible()) resource->bind(m_frontend.get()); } #endif @@ -1109,7 +1115,9 @@ void InspectorController::didUseDOMStorage(StorageArea* storageArea, bool isLoca RefPtr resource = InspectorDOMStorageResource::create(domStorage.get(), isLocalStorage, frame); m_domStorageResources.add(resource); - if (m_frontend) + + // Resources are only bound while visible. + if (m_frontend && windowVisible()) resource->bind(m_frontend.get()); } diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorController.h b/src/3rdparty/webkit/WebCore/inspector/InspectorController.h index 20295aa..ff7a516 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorController.h +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorController.h @@ -196,6 +196,7 @@ public: void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); void handleMousePressOnNode(Node*); + void inspectedWindowScriptObjectCleared(Frame*); void windowScriptObjectAvailable(); void setFrontendProxyObject(ScriptState* state, ScriptObject webInspectorObj, ScriptObject injectedScriptObj = ScriptObject()); diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorDOMAgent.cpp b/src/3rdparty/webkit/WebCore/inspector/InspectorDOMAgent.cpp index 4a4902d..d893796 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorDOMAgent.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorDOMAgent.cpp @@ -70,10 +70,10 @@ InspectorDOMAgent::~InspectorDOMAgent() setDocument(0); } -bool InspectorDOMAgent::setDocument(Document* doc) +void InspectorDOMAgent::setDocument(Document* doc) { if (doc == mainFrameDocument()) - return false; + return; discardBindings(); ListHashSet > copy = m_documents; @@ -88,7 +88,6 @@ bool InspectorDOMAgent::setDocument(Document* doc) pushDocumentToFrontend(); } } - return true; } void InspectorDOMAgent::releaseDanglingNodes() diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorDOMAgent.h b/src/3rdparty/webkit/WebCore/inspector/InspectorDOMAgent.h index bd539a5..c430c57 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorDOMAgent.h +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorDOMAgent.h @@ -75,7 +75,7 @@ namespace WebCore { void getCookies(long callId); // Methods called from the InspectorController. - bool setDocument(Document* document); + void setDocument(Document* document); void releaseDanglingNodes(); Node* nodeForId(long nodeId); diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorDOMStorageResource.cpp b/src/3rdparty/webkit/WebCore/inspector/InspectorDOMStorageResource.cpp index 99a2dba..7ed0d7f 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorDOMStorageResource.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorDOMStorageResource.cpp @@ -79,7 +79,9 @@ void InspectorDOMStorageResource::bind(InspectorFrontend* frontend) void InspectorDOMStorageResource::unbind() { - ASSERT(m_frontend); + if (!m_frontend) + return; // Already unbound. + if (m_reportingChangesToFrontend) { m_frame->domWindow()->removeEventListener(eventNames().storageEvent, this, true); m_reportingChangesToFrontend = false; diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorFrontend.cpp b/src/3rdparty/webkit/WebCore/inspector/InspectorFrontend.cpp index 3bdfa97..c9793cb 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorFrontend.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorFrontend.cpp @@ -83,13 +83,8 @@ void InspectorFrontend::addMessageToConsole(const ScriptObject& messageObj, cons } else if (!wrappedArguments.isEmpty()) { for (unsigned i = 0; i < wrappedArguments.size(); ++i) function->appendArgument(m_inspectorController->wrapObject(wrappedArguments[i])); - } else { - // FIXME: avoid manual wrapping here. - ScriptObject textWrapper = ScriptObject::createNew(m_scriptState); - textWrapper.set("type", "string"); - textWrapper.set("description", message); - function->appendArgument(textWrapper); - } + } else + function->appendArgument(message); function->call(); } diff --git a/src/3rdparty/webkit/WebCore/inspector/JavaScriptDebugServer.cpp b/src/3rdparty/webkit/WebCore/inspector/JavaScriptDebugServer.cpp index 6657120..e460ae8 100644 --- a/src/3rdparty/webkit/WebCore/inspector/JavaScriptDebugServer.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/JavaScriptDebugServer.cpp @@ -235,7 +235,7 @@ bool JavaScriptDebugServer::hasBreakpoint(intptr_t sourceID, unsigned lineNumber // An erroneous condition counts as "false". return false; } - return result.toBoolean(m_currentCallFrame->scopeChain()->globalObject()->globalExec()); + return result.toBoolean(m_currentCallFrame->scopeChain()->globalObject->globalExec()); } void JavaScriptDebugServer::clearBreakpoints() diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ConsoleView.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ConsoleView.js index 575b13a..4f50ecc 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ConsoleView.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ConsoleView.js @@ -608,7 +608,7 @@ WebInspector.ConsoleMessage.prototype = { this.formattedMessage = span; break; case WebInspector.ConsoleMessage.MessageType.Object: - this.formattedMessage = this._format([WebInspector.ObjectProxy.wrapPrimitiveValue("%O"), args[0]]); + this.formattedMessage = this._format(["%O", args[0]]); break; default: this.formattedMessage = this._format(args); @@ -631,6 +631,13 @@ WebInspector.ConsoleMessage.prototype = { if (!parameters.length) return formattedResult; + // Formatting code below assumes that parameters are all wrappers whereas frontend console + // API allows passing arbitrary values as messages (strings, numberts, etc.). Wrap them here. + for (var i = 0; i < parameters.length; ++i) { + if (typeof parameters[i] !== "object" && typeof parameters[i] !== "function") + parameters[i] = WebInspector.ObjectProxy.wrapPrimitiveValue(parameters[i]); + } + function formatForConsole(obj) { return WebInspector.console._format(obj); diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js index 49a1188..928da52 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js @@ -987,27 +987,9 @@ WebInspector.ElementsPanel.prototype = { // Don't prevent the normal copy if the user has a selection. if (!window.getSelection().isCollapsed) return; - - switch (this.focusedDOMNode.nodeType) { - case Node.ELEMENT_NODE: - // TODO: Introduce InspectorController.copyEvent that pushes appropriate markup into the clipboard. - var data = null; - break; - - case Node.COMMENT_NODE: - var data = ""; - break; - - default: - case Node.TEXT_NODE: - var data = this.focusedDOMNode.nodeValue; - } - event.clipboardData.clearData(); event.preventDefault(); - - if (data) - event.clipboardData.setData("text/plain", data); + InspectorController.copyNode(this.focusedDOMNode.id); }, rightSidebarResizerDragStart: function(event) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScript.js b/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScript.js index 726c7cc..87293b8 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScript.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScript.js @@ -44,6 +44,10 @@ InjectedScript.reset(); InjectedScript.dispatch = function(methodName, args) { var result = InjectedScript[methodName].apply(InjectedScript, JSON.parse(args)); + if (typeof result === "undefined") { + InjectedScript._window().console.error("Web Inspector error: InjectedScript.%s returns undefined", methodName); + result = null; + } return JSON.stringify(result); } @@ -150,6 +154,7 @@ InjectedScript.applyStyleText = function(styleId, styleText, propertyName) InjectedScript.setStyleText = function(style, cssText) { style.cssText = cssText; + return true; } InjectedScript.toggleStyleEnabled = function(styleId, propertyName, disabled) @@ -536,11 +541,11 @@ InjectedScript._evaluateAndWrap = function(evalFunction, object, expression) result.value = InspectorController.wrapObject(InjectedScript._evaluateOn(evalFunction, object, expression)); // Handle error that might have happened while describing result. if (result.value.errorText) { - result.value = InspectorController.wrapObject(result.value.errorText); + result.value = result.value.errorText; result.isException = true; } } catch (e) { - result.value = InspectorController.wrapObject(e.toString()); + result.value = e.toString(); result.isException = true; } return result; @@ -812,7 +817,10 @@ InjectedScript.searchCanceled = function() InjectedScript.openInInspectedWindow = function(url) { - InjectedScript._window().open(url); + // Don't call window.open on wrapper - popup blocker mutes it. + // URIs should have no double quotes. + InjectedScript._window().eval("window.open(\"" + url + "\")"); + return true; } InjectedScript.getCallFrames = function() @@ -1100,10 +1108,6 @@ Object.describe = function(obj, abbreviated) return objectText; case "regexp": return String(obj).replace(/([\\\/])/g, "\\$1").replace(/\\(\/[gim]*)$/, "$1").substring(1); - case "boolean": - case "number": - case "null": - return obj; default: return String(obj); } diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScriptAccess.js b/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScriptAccess.js index da85d03..67312f7 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScriptAccess.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScriptAccess.js @@ -51,6 +51,9 @@ InjectedScriptAccess._installHandler = function(methodName) }; } +// InjectedScriptAccess message forwarding puts some constraints on the way methods are imlpemented and called: +// - Make sure corresponding methods in InjectedScript return non-null and non-undefined values, +// - Make sure last parameter of all the InjectedSriptAccess.* calls is a callback function. InjectedScriptAccess._installHandler("getStyles"); InjectedScriptAccess._installHandler("getComputedStyle"); InjectedScriptAccess._installHandler("getInlineStyle"); diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ProfileDataGridTree.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ProfileDataGridTree.js index 356f57d..3fb0e00 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ProfileDataGridTree.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ProfileDataGridTree.js @@ -153,8 +153,11 @@ WebInspector.ProfileDataGridNode.prototype = { // If the grid node is collapsed, then don't sort children (save operation for later). // If the grid node has the same sorting as previously, then there is no point in sorting it again. - if (!force && !gridNode.expanded || gridNode.lastComparator === comparator) + if (!force && !gridNode.expanded || gridNode.lastComparator === comparator) { + if (gridNode.children.length) + gridNode.shouldRefreshChildren = true; continue; + } gridNode.lastComparator = comparator; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourceView.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourceView.js index d915055..4fcc956 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourceView.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourceView.js @@ -178,7 +178,7 @@ WebInspector.ResourceView.prototype = { var isFormEncoded = false; var requestContentType = this._getHeaderValue(this.resource.requestHeaders, "Content-Type"); - if (requestContentType == "application/x-www-form-urlencoded") + if (requestContentType.match(/^application\/x-www-form-urlencoded\s*(;.*)?$/i)) isFormEncoded = true; if (isFormEncoded) { @@ -217,14 +217,27 @@ WebInspector.ResourceView.prototype = { for (var i = 0; i < parms.length; ++i) { var key = parms[i][0]; - var val = parms[i][1]; - - if (val.indexOf("%") >= 0) - if (this._decodeRequestParameters) - val = decodeURIComponent(val).replace(/\+/g, " "); + var value = parms[i][1]; + + var errorDecoding = false; + if (this._decodeRequestParameters) { + if (value.indexOf("%") >= 0) { + try { + value = decodeURIComponent(value); + } catch(e) { + errorDecoding = true; + } + } + + value = value.replace(/\+/g, " "); + } + + valueEscaped = value.escapeHTML(); + if (errorDecoding) + valueEscaped += " " + WebInspector.UIString("(unable to decode value)").escapeHTML() + ""; var title = "
" + key.escapeHTML() + ":
"; - title += "
" + val.escapeHTML() + "
"; + title += "
" + valueEscaped + "
"; var parmTreeElement = new TreeElement(title, null, false); parmTreeElement.selectable = false; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js index 680f66c..2c96974 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js @@ -1209,7 +1209,7 @@ WebInspector.ResourceSidebarTreeElement.prototype = { ondblclick: function(treeElement, event) { - InjectedScriptAccess.openInInspectedWindow(this.resource.url); + InjectedScriptAccess.openInInspectedWindow(this.resource.url, function() {}); }, get mainTitle() diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js b/src/3rdparty/webkit/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js index b568939..d6d1d61 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js @@ -84,18 +84,23 @@ WebInspector.WatchExpressionsSection.prototype = { { function appendResult(expression, watchIndex, result, exception) { - // The null check catches some other cases, like null itself, and NaN - if ((typeof result !== "object") || (result == null)) - result = new WebInspector.ObjectProxy(null, [], 0, String(result), false); + if (exception) { + // Exception results are not wrappers, but text messages. + result = WebInspector.ObjectProxy.wrapPrimitiveValue(result); + } else if (result.type === "string") { + // Evaluation result is intentionally not abbreviated. However, we'd like to distinguish between null and "null" + result.description = "\"" + result.description + "\""; + } var property = new WebInspector.ObjectPropertyProxy(expression, result); property.watchIndex = watchIndex; + property.isException = exception; // For newly added, empty expressions, set description to "", // since otherwise you get DOMWindow if (property.name === WebInspector.WatchExpressionsSection.NewWatchExpression) property.value.description = ""; - + // To clarify what's going on here: // In the outer function, we calculate the number of properties // that we're going to be updating, and set that in the @@ -218,6 +223,9 @@ WebInspector.WatchExpressionTreeElement.prototype = { { WebInspector.ObjectPropertyTreeElement.prototype.update.call(this); + if (this.property.isException) + this.valueElement.addStyleClass("watch-expressions-error-level"); + var deleteButton = document.createElement("input"); deleteButton.type = "button"; deleteButton.title = WebInspector.UIString("Delete watch expression."); diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/WebKit.qrc b/src/3rdparty/webkit/WebCore/inspector/front-end/WebKit.qrc index b4dff4e..0c50bb7 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/WebKit.qrc +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/WebKit.qrc @@ -92,6 +92,7 @@ Images/enableSolidButtonGlyph.png Images/errorIcon.png Images/errorMediumIcon.png + Images/errorRedDot.png Images/excludeButtonGlyph.png Images/focusButtonGlyph.png Images/forward.png @@ -153,6 +154,7 @@ Images/statusbarResizerHorizontal.png Images/statusbarResizerVertical.png Images/storageIcon.png + Images/successGreenDot.png Images/timelineHollowPillBlue.png Images/timelineHollowPillGray.png Images/timelineHollowPillGreen.png @@ -184,6 +186,7 @@ Images/userInputResultIcon.png Images/warningIcon.png Images/warningMediumIcon.png + Images/warningOrangeDot.png Images/warningsErrors.png diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css index 2ae4aac..4513886 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css @@ -1409,6 +1409,10 @@ li.editing .swatch, li.editing .enabled-button, li.editing-sub-part .delete-but display: none; } +.watch-expressions-error-level { + color: red; +} + .section .properties li.editing-sub-part { padding: 3px 6px 8px 18px; margin: -3px -6px -8px -6px; diff --git a/src/3rdparty/webkit/WebCore/loader/EmptyClients.h b/src/3rdparty/webkit/WebCore/loader/EmptyClients.h index 41b6ebc..14d36f1 100644 --- a/src/3rdparty/webkit/WebCore/loader/EmptyClients.h +++ b/src/3rdparty/webkit/WebCore/loader/EmptyClients.h @@ -39,6 +39,7 @@ #include "FormState.h" #include "FrameLoaderClient.h" #include "InspectorClient.h" +#include "PluginHalterClient.h" #include "ResourceError.h" #include "SharedBuffer.h" @@ -483,6 +484,12 @@ public: virtual void inspectorWindowObjectCleared() { } }; +class EmptyPluginHalterClient : public PluginHalterClient +{ +public: + virtual bool shouldHaltPlugin(Node*) const { return false; } +}; + } #endif // EmptyClients_h diff --git a/src/3rdparty/webkit/WebCore/loader/FTPDirectoryParser.cpp b/src/3rdparty/webkit/WebCore/loader/FTPDirectoryParser.cpp index 6573fb6..40bd714 100644 --- a/src/3rdparty/webkit/WebCore/loader/FTPDirectoryParser.cpp +++ b/src/3rdparty/webkit/WebCore/loader/FTPDirectoryParser.cpp @@ -57,6 +57,13 @@ static struct tm *gmtimeQt(const time_t *const timep, struct tm *result) #endif #endif +static inline FTPEntryType ParsingFailed(ListState& state) +{ + if (state.parsedOne || state.listStyle) /* junk if we fail to parse */ + return FTPJunkEntry; /* this time but had previously parsed sucessfully */ + return FTPMiscEntry; /* its part of a comment or error message */ +} + FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& result) { result.clear(); @@ -126,6 +133,9 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res } } + if (!numtoks) + return ParsingFailed(state); + linelen_sans_wsp = &(tokens[numtoks-1][toklen[numtoks-1]]) - tokens[0]; if (numtoks == (sizeof(tokens)/sizeof(tokens[0])) ) { @@ -356,11 +366,16 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res pos++; p++; } - if (lstyle && pos < (toklen[0]-1) && *p == ']') + if (lstyle && pos < (toklen[0]-1)) { + /* ']' was found and there is at least one character after it */ + ASSERT(*p == ']'); pos++; p++; tokmarker = pos; /* length of leading "[DIR1.DIR2.etc]" */ + } else { + /* not a CMU style listing */ + lstyle = 0; } } while (lstyle && pos < toklen[0] && *p != ';') @@ -387,7 +402,7 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res pos -= tokmarker; /* => fnlength sans "[DIR1.DIR2.etc]" */ p = &(tokens[0][tokmarker]); /* offset of basename */ - if (!lstyle || pos > 80) /* VMS filenames can't be longer than that */ + if (!lstyle || pos == 0 || pos > 80) /* VMS filenames can't be longer than that */ { lstyle = 0; } @@ -780,7 +795,7 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res state.parsedOne = true; state.listStyle = lstyle; - p = &(line[linelen_sans_wsp]); /* line end sans wsp */ + p = &(line[linelen]); /* line end */ result.caseSensitive = true; result.filename = tokens[3]; result.filenameLength = p - tokens[3]; @@ -788,29 +803,46 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res if (*tokens[2] != '<') /* not or */ { + // try to handle correctly spaces at the beginning of the filename + // filesize (token[2]) must end at offset 38 + if (tokens[2] + toklen[2] - line == 38) { + result.filename = &(line[39]); + result.filenameLength = p - result.filename; + } result.type = FTPFileEntry; pos = toklen[2]; result.fileSize = String(tokens[2], pos); } - else if ((tokens[2][1]) != 'D') /* not */ - { - result.type = FTPJunkEntry; /* unknown until junc for sure */ - if (result.filenameLength > 4) + else { + // try to handle correctly spaces at the beginning of the filename + // token[2] must begin at offset 24, the length is 5 or 10 + // token[3] must begin at offset 39 or higher + if (tokens[2] - line == 24 && (toklen[2] == 5 || toklen[2] == 10) && + tokens[3] - line >= 39) { + result.filename = &(line[39]); + result.filenameLength = p - result.filename; + } + + if ((tokens[2][1]) != 'D') /* not */ { - p = result.filename; - for (pos = result.filenameLength - 4; pos > 0; pos--) + result.type = FTPJunkEntry; /* unknown until junc for sure */ + if (result.filenameLength > 4) { - if (p[0] == ' ' && p[3] == ' ' && p[2] == '>' && - (p[1] == '=' || p[1] == '-')) + p = result.filename; + for (pos = result.filenameLength - 4; pos > 0; pos--) { - result.type = FTPLinkEntry; - result.filenameLength = p - result.filename; - result.linkname = p + 4; - result.linknameLength = &(line[linelen_sans_wsp]) - - result.linkname; - break; + if (p[0] == ' ' && p[3] == ' ' && p[2] == '>' && + (p[1] == '=' || p[1] == '-')) + { + result.type = FTPLinkEntry; + result.filenameLength = p - result.filename; + result.linkname = p + 4; + result.linknameLength = &(line[linelen]) + - result.linkname; + break; + } + p++; } - p++; } } } @@ -821,8 +853,13 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res result.modifiedTime.tm_mon--; result.modifiedTime.tm_mday = atoi(tokens[0]+3); result.modifiedTime.tm_year = atoi(tokens[0]+6); + /* if year has only two digits then assume that + 00-79 is 2000-2079 + 80-99 is 1980-1999 */ if (result.modifiedTime.tm_year < 80) - result.modifiedTime.tm_year += 100; + result.modifiedTime.tm_year += 2000; + else if (result.modifiedTime.tm_year < 100) + result.modifiedTime.tm_year += 1900; } result.modifiedTime.tm_hour = atoi(tokens[1]+0); @@ -974,6 +1011,8 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res * "drwxr-xr-x 2 0 0 512 May 28 22:17 etc" */ + bool isOldHellsoft = false; + if (numtoks >= 6) { /* there are two perm formats (Hellsoft/NetWare and *IX strmode(3)). @@ -999,6 +1038,8 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res { /* rest is FMA[S] or AFM[S] */ lstyle = 'U'; /* very likely one of the NetWare servers */ + if (toklen[0] == 10) + isOldHellsoft = true; } } } @@ -1063,7 +1104,7 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res /* check that size is numeric */ p = tokens[tokmarker]; - for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++) + for (unsigned int i = 0; lstyle && i < toklen[tokmarker]; ++i) { if (!isASCIIDigit(*p++)) lstyle = 0; @@ -1072,11 +1113,11 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res { month_num = 0; p = tokens[tokmarker+1]; - for (pos = 0;pos < (12*3); pos+=3) + for (unsigned int i = 0; i < (12*3); i+=3) { - if (p[0] == month_names[pos+0] && - p[1] == month_names[pos+1] && - p[2] == month_names[pos+2]) + if (p[0] == month_names[i+0] && + p[1] == month_names[i+1] && + p[2] == month_names[i+2]) break; month_num++; } @@ -1084,8 +1125,8 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res lstyle = 0; } } /* relative position test */ - } /* while (pos+5) < numtoks */ - } /* if (numtoks >= 4) */ + } /* for (pos = (numtoks-5); !lstyle && pos > 1; pos--) */ + } /* if (lstyle == 'U') */ if (lstyle == 'U') { @@ -1144,24 +1185,49 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res } /* time/year */ - result.filename = tokens[tokmarker+4]; - result.filenameLength = (&(line[linelen_sans_wsp])) + // there is exacly 1 space between filename and previous token in all + // outputs except old Hellsoft + if (!isOldHellsoft) + result.filename = tokens[tokmarker+3] + toklen[tokmarker+3] + 1; + else + result.filename = tokens[tokmarker+4]; + + result.filenameLength = (&(line[linelen])) - (result.filename); if (result.type == FTPLinkEntry && result.filenameLength > 4) { - p = result.filename + 1; - for (pos = 1; pos < (result.filenameLength - 4); pos++) + /* First try to use result.fe_size to find " -> " sequence. + This can give proper result for cases like "aaa -> bbb -> ccc". */ + unsigned int fileSize = result.fileSize.toUInt(); + + if (result.filenameLength > (fileSize + 4) && + strncmp(result.filename + result.filenameLength - fileSize - 4, " -> ", 4) == 0) + { + result.linkname = result.filename + (result.filenameLength - fileSize); + result.linknameLength = (&(line[linelen])) - (result.linkname); + result.filenameLength -= fileSize + 4; + } + else { - if (*p == ' ' && p[1] == '-' && p[2] == '>' && p[3] == ' ') + /* Search for sequence " -> " from the end for case when there are + more occurrences. F.e. if ftpd returns "a -> b -> c" assume + "a -> b" as a name. Powerusers can remove unnecessary parts + manually but there is no way to follow the link when some + essential part is missing. */ + p = result.filename + (result.filenameLength - 5); + for (pos = (result.filenameLength - 5); pos > 0; pos--) { - result.linkname = p + 4; - result.linknameLength = (&(line[linelen_sans_wsp])) - - (result.linkname); - result.filenameLength = pos; - break; + if (strncmp(p, " -> ", 4) == 0) + { + result.linkname = p + 4; + result.linknameLength = (&(line[linelen])) + - (result.linkname); + result.filenameLength = pos; + break; + } + p--; } - p++; } } @@ -1618,9 +1684,7 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res } /* if (linelen > 0) */ - if (state.parsedOne || state.listStyle) /* junk if we fail to parse */ - return FTPJunkEntry; /* this time but had previously parsed sucessfully */ - return FTPMiscEntry; /* its part of a comment or error message */ + return ParsingFailed(state); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp b/src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp index 807edef..57cf85a 100644 --- a/src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp +++ b/src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp @@ -2312,9 +2312,6 @@ void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHis void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType newLoadType, PassRefPtr event, PassRefPtr prpFormState) { - if (m_unloadEventBeingDispatched) - return; - RefPtr formState = prpFormState; bool isFormSubmission = formState; @@ -2337,6 +2334,9 @@ void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const Stri return; } + if (m_unloadEventBeingDispatched) + return; + NavigationAction action(newURL, newLoadType, isFormSubmission, event); if (!targetFrame && !frameName.isEmpty()) { @@ -5193,6 +5193,8 @@ void FrameLoader::dispatchWindowObjectAvailable() #if ENABLE(INSPECTOR) if (Page* page = m_frame->page()) { + if (InspectorController* inspector = page->inspectorController()) + inspector->inspectedWindowScriptObjectCleared(m_frame); if (InspectorController* inspector = page->parentInspectorController()) inspector->windowScriptObjectAvailable(); } diff --git a/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp b/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp index 809d541..5ac4049 100644 --- a/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp +++ b/src/3rdparty/webkit/WebCore/page/DOMWindow.cpp @@ -34,6 +34,8 @@ #include "CString.h" #include "Chrome.h" #include "Console.h" +#include "Database.h" +#include "DOMApplicationCache.h" #include "DOMSelection.h" #include "DOMTimer.h" #include "PageTransitionEvent.h" @@ -55,6 +57,7 @@ #include "Media.h" #include "MessageEvent.h" #include "Navigator.h" +#include "NotificationCenter.h" #include "Page.h" #include "PageGroup.h" #include "PlatformScreen.h" @@ -62,29 +65,14 @@ #include "Screen.h" #include "SecurityOrigin.h" #include "Settings.h" +#include "Storage.h" +#include "StorageArea.h" +#include "StorageNamespace.h" #include "SuddenTermination.h" #include "WebKitPoint.h" #include #include -#if ENABLE(DATABASE) -#include "Database.h" -#endif - -#if ENABLE(DOM_STORAGE) -#include "Storage.h" -#include "StorageArea.h" -#include "StorageNamespace.h" -#endif - -#if ENABLE(OFFLINE_WEB_APPLICATIONS) -#include "DOMApplicationCache.h" -#endif - -#if ENABLE(NOTIFICATIONS) -#include "NotificationCenter.h" -#endif - using std::min; using std::max; @@ -137,6 +125,66 @@ static DOMWindowSet& windowsWithBeforeUnloadEventListeners() return windowsWithBeforeUnloadEventListeners; } +static void addUnloadEventListener(DOMWindow* domWindow) +{ + DOMWindowSet& set = windowsWithUnloadEventListeners(); + if (set.isEmpty()) + disableSuddenTermination(); + set.add(domWindow); +} + +static void removeUnloadEventListener(DOMWindow* domWindow) +{ + DOMWindowSet& set = windowsWithUnloadEventListeners(); + DOMWindowSet::iterator it = set.find(domWindow); + if (it == set.end()) + return; + set.remove(it); + if (set.isEmpty()) + enableSuddenTermination(); +} + +static void removeAllUnloadEventListeners(DOMWindow* domWindow) +{ + DOMWindowSet& set = windowsWithUnloadEventListeners(); + DOMWindowSet::iterator it = set.find(domWindow); + if (it == set.end()) + return; + set.removeAll(it); + if (set.isEmpty()) + enableSuddenTermination(); +} + +static void addBeforeUnloadEventListener(DOMWindow* domWindow) +{ + DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); + if (set.isEmpty()) + disableSuddenTermination(); + set.add(domWindow); +} + +static void removeBeforeUnloadEventListener(DOMWindow* domWindow) +{ + DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); + DOMWindowSet::iterator it = set.find(domWindow); + if (it == set.end()) + return; + set.remove(it); + if (set.isEmpty()) + enableSuddenTermination(); +} + +static void removeAllBeforeUnloadEventListeners(DOMWindow* domWindow) +{ + DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); + DOMWindowSet::iterator it = set.find(domWindow); + if (it == set.end()) + return; + set.removeAll(it); + if (set.isEmpty()) + enableSuddenTermination(); +} + static bool allowsBeforeUnloadListeners(DOMWindow* window) { ASSERT_ARG(window, window); @@ -193,7 +241,7 @@ unsigned DOMWindow::pendingUnloadEventListeners() const void DOMWindow::dispatchAllPendingUnloadEvents() { - DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); + DOMWindowSet& set = windowsWithUnloadEventListeners(); if (set.isEmpty()) return; @@ -328,8 +376,8 @@ DOMWindow::~DOMWindow() if (m_frame) m_frame->clearFormerDOMWindow(this); - windowsWithUnloadEventListeners().clear(this); - windowsWithBeforeUnloadEventListeners().clear(this); + removeAllUnloadEventListeners(this); + removeAllBeforeUnloadEventListeners(this); } ScriptExecutionContext* DOMWindow::scriptExecutionContext() const @@ -552,15 +600,12 @@ Storage* DOMWindow::localStorage() const if (!page->settings()->localStorageEnabled()) return 0; - StorageNamespace* localStorage = page->group().localStorage(); - RefPtr storageArea = localStorage ? localStorage->storageArea(document->securityOrigin()) : 0; - if (storageArea) { + RefPtr storageArea = page->group().localStorage()->storageArea(document->securityOrigin()); #if ENABLE(INSPECTOR) - page->inspectorController()->didUseDOMStorage(storageArea.get(), true, m_frame); + page->inspectorController()->didUseDOMStorage(storageArea.get(), true, m_frame); #endif - m_localStorage = Storage::create(m_frame, storageArea.release()); - } + m_localStorage = Storage::create(m_frame, storageArea.release()); return m_localStorage.get(); } #endif @@ -579,6 +624,9 @@ NotificationCenter* DOMWindow::webkitNotifications() const if (!page) return 0; + if (!page->settings()->experimentalNotificationsEnabled()) + return 0; + NotificationPresenter* provider = page->chrome()->notificationPresenter(); if (provider) m_notifications = NotificationCenter::create(document, provider); @@ -1215,9 +1263,9 @@ bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtraddListenerTypeIfNeeded(eventType); if (eventType == eventNames().unloadEvent) - windowsWithUnloadEventListeners().add(this); + addUnloadEventListener(this); else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this)) - windowsWithBeforeUnloadEventListeners().add(this); + addBeforeUnloadEventListener(this); return true; } @@ -1228,9 +1276,9 @@ bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener return false; if (eventType == eventNames().unloadEvent) - windowsWithUnloadEventListeners().remove(this); + removeUnloadEventListener(this); else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this)) - windowsWithBeforeUnloadEventListeners().remove(this); + removeBeforeUnloadEventListener(this); return true; } @@ -1266,8 +1314,8 @@ void DOMWindow::removeAllEventListeners() { EventTarget::removeAllEventListeners(); - windowsWithUnloadEventListeners().clear(this); - windowsWithBeforeUnloadEventListeners().clear(this); + removeAllUnloadEventListeners(this); + removeAllBeforeUnloadEventListeners(this); } void DOMWindow::captureEvents() diff --git a/src/3rdparty/webkit/WebCore/page/EventHandler.cpp b/src/3rdparty/webkit/WebCore/page/EventHandler.cpp index 8d519ef..3772d65 100644 --- a/src/3rdparty/webkit/WebCore/page/EventHandler.cpp +++ b/src/3rdparty/webkit/WebCore/page/EventHandler.cpp @@ -1758,6 +1758,13 @@ bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe return swallowEvent; } +#if !PLATFORM(GTK) +bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&) const +{ + return false; +} +#endif + bool EventHandler::handleWheelEvent(PlatformWheelEvent& e) { Document* doc = m_frame->document(); @@ -1777,11 +1784,12 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e) bool isOverWidget; bool didSetLatchedNode = false; + HitTestRequest request(HitTestRequest::ReadOnly); + HitTestResult result(vPoint); + doc->renderView()->layer()->hitTest(request, result); + if (m_useLatchedWheelEventNode) { if (!m_latchedWheelEventNode) { - HitTestRequest request(HitTestRequest::ReadOnly); - HitTestResult result(vPoint); - doc->renderView()->layer()->hitTest(request, result); m_latchedWheelEventNode = result.innerNode(); m_widgetIsLatched = result.isOverWidget(); didSetLatchedNode = true; @@ -1795,13 +1803,13 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e) if (m_previousWheelScrolledNode) m_previousWheelScrolledNode = 0; - HitTestRequest request(HitTestRequest::ReadOnly); - HitTestResult result(vPoint); - doc->renderView()->layer()->hitTest(request, result); node = result.innerNode(); isOverWidget = result.isOverWidget(); } + if (shouldTurnVerticalTicksIntoHorizontal(result)) + e.turnVerticalTicksIntoHorizontal(); + if (node) { // Figure out which view to send the event to. RenderObject* target = node->renderer(); diff --git a/src/3rdparty/webkit/WebCore/page/EventHandler.h b/src/3rdparty/webkit/WebCore/page/EventHandler.h index 7066252..e1a02db 100644 --- a/src/3rdparty/webkit/WebCore/page/EventHandler.h +++ b/src/3rdparty/webkit/WebCore/page/EventHandler.h @@ -125,6 +125,8 @@ public: bool shouldDragAutoNode(Node*, const IntPoint&) const; // -webkit-user-drag == auto #endif + bool shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&) const; + bool tabsToLinks(KeyboardEvent*) const; bool tabsToAllControls(KeyboardEvent*) const; diff --git a/src/3rdparty/webkit/WebCore/page/HaltablePlugin.h b/src/3rdparty/webkit/WebCore/page/HaltablePlugin.h new file mode 100644 index 0000000..a5fe0f4 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/page/HaltablePlugin.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HaltablePlugin_h +#define HaltablePlugin_h + +namespace WebCore { + +class Node; + +class HaltablePlugin { +public: + virtual ~HaltablePlugin() { } + + virtual void halt() = 0; + virtual void restart() = 0; + virtual Node* node() const = 0; +}; + +} // namespace WebCore + +#endif // HaltablePlugin_h diff --git a/src/3rdparty/webkit/WebCore/page/Page.cpp b/src/3rdparty/webkit/WebCore/page/Page.cpp index 182d22c..2d0c91c 100644 --- a/src/3rdparty/webkit/WebCore/page/Page.cpp +++ b/src/3rdparty/webkit/WebCore/page/Page.cpp @@ -49,6 +49,7 @@ #include "NetworkStateNotifier.h" #include "PageGroup.h" #include "PluginData.h" +#include "PluginHalter.h" #include "ProgressTracker.h" #include "RenderWidget.h" #include "RenderTheme.h" @@ -99,7 +100,7 @@ static void networkStateChanged() frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false)); } -Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient, InspectorClient* inspectorClient) +Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient, InspectorClient* inspectorClient, PluginHalterClient* pluginHalterClient) : m_chrome(new Chrome(this, chromeClient)) , m_dragCaretController(new SelectionController(0, true)) #if ENABLE(DRAG_SUPPORT) @@ -135,6 +136,7 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi , m_customHTMLTokenizerTimeDelay(-1) , m_customHTMLTokenizerChunkSize(-1) , m_canStartPlugins(true) + , m_pluginHalterClient(pluginHalterClient) { #if !ENABLE(CONTEXT_MENUS) UNUSED_PARAM(contextMenuClient); @@ -154,6 +156,8 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi ASSERT(!allPages->contains(this)); allPages->add(this); + pluginHalterEnabledStateChanged(); + #if ENABLE(JAVASCRIPT_DEBUGGER) JavaScriptDebugServer::shared().pageCreated(this); #endif @@ -679,4 +683,32 @@ InspectorTimelineAgent* Page::inspectorTimelineAgent() const } #endif +void Page::pluginHalterEnabledStateChanged() +{ + if (m_settings->pluginHalterEnabled()) { + ASSERT(!m_pluginHalter); + m_pluginHalter.set(new PluginHalter(m_pluginHalterClient)); + m_pluginHalter->setPluginAllowedRunTime(m_settings->pluginAllowedRunTime()); + } else + m_pluginHalter = 0; +} + +void Page::pluginAllowedRunTimeChanged() +{ + if (m_pluginHalter) + m_pluginHalter->setPluginAllowedRunTime(m_settings->pluginAllowedRunTime()); +} + +void Page::didStartPlugin(HaltablePlugin* obj) +{ + if (m_pluginHalter) + m_pluginHalter->didStartPlugin(obj); +} + +void Page::didStopPlugin(HaltablePlugin* obj) +{ + if (m_pluginHalter) + m_pluginHalter->didStopPlugin(obj); +} + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/page/Page.h b/src/3rdparty/webkit/WebCore/page/Page.h index d3f7ddb..602d99b 100644 --- a/src/3rdparty/webkit/WebCore/page/Page.h +++ b/src/3rdparty/webkit/WebCore/page/Page.h @@ -54,12 +54,15 @@ namespace WebCore { class EditorClient; class FocusController; class Frame; + class HaltablePlugin; class InspectorClient; class InspectorController; class InspectorTimelineAgent; class Node; class PageGroup; class PluginData; + class PluginHalter; + class PluginHalterClient; class PluginView; class ProgressTracker; class RenderTheme; @@ -82,7 +85,7 @@ namespace WebCore { public: static void setNeedsReapplyStyles(); - Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*); + Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*, PluginHalterClient*); ~Page(); RenderTheme* theme() const { return m_theme.get(); }; @@ -181,6 +184,11 @@ namespace WebCore { void userStyleSheetLocationChanged(); const String& userStyleSheet() const; + void didStartPlugin(HaltablePlugin*); + void didStopPlugin(HaltablePlugin*); + void pluginAllowedRunTimeChanged(); + void pluginHalterEnabledStateChanged(); + static void setDebuggerForAllPages(JSC::Debugger*); void setDebugger(JSC::Debugger*); JSC::Debugger* debugger() const { return m_debugger; } @@ -284,6 +292,9 @@ namespace WebCore { bool m_canStartPlugins; HashSet m_unstartedPlugins; + OwnPtr m_pluginHalter; + PluginHalterClient* m_pluginHalterClient; + #if ENABLE(DOM_STORAGE) RefPtr m_sessionStorage; #endif diff --git a/src/3rdparty/webkit/WebCore/page/PluginHalter.cpp b/src/3rdparty/webkit/WebCore/page/PluginHalter.cpp new file mode 100644 index 0000000..8025337 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/page/PluginHalter.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "PluginHalter.h" + +#include "HaltablePlugin.h" +#include "PluginHalterClient.h" +#include +#include + +using namespace std; + +namespace WebCore { + +PluginHalter::PluginHalter(PluginHalterClient* client) + : m_client(client) + , m_timer(this, &PluginHalter::timerFired) + , m_pluginAllowedRunTime(numeric_limits::max()) +{ + ASSERT_ARG(client, client); +} + +void PluginHalter::didStartPlugin(HaltablePlugin* obj) +{ + ASSERT_ARG(obj, obj); + ASSERT_ARG(obj, !m_plugins.contains(obj)); + + double currentTime = WTF::currentTime(); + + m_plugins.add(obj, currentTime); + + if (m_plugins.size() == 1) + m_oldestStartTime = currentTime; + + startTimerIfNecessary(); +} + +void PluginHalter::didStopPlugin(HaltablePlugin* obj) +{ + m_plugins.remove(obj); +} + +void PluginHalter::timerFired(Timer*) +{ + if (m_plugins.isEmpty()) + return; + + Vector plugins; + copyKeysToVector(m_plugins, plugins); + + // Plug-ins older than this are candidates to be halted. + double pluginCutOffTime = WTF::currentTime() - m_pluginAllowedRunTime; + + m_oldestStartTime = numeric_limits::max(); + + for (size_t i = 0; i < plugins.size(); ++i) { + double thisStartTime = m_plugins.get(plugins[i]); + if (thisStartTime > pluginCutOffTime) { + // This plug-in is too young to be halted. We find the oldest + // plug-in that is not old enough to be halted and use it to set + // the timer's next fire time. + if (thisStartTime < m_oldestStartTime) + m_oldestStartTime = thisStartTime; + continue; + } + + if (m_client->shouldHaltPlugin(plugins[i]->node())) + plugins[i]->halt(); + + m_plugins.remove(plugins[i]); + } + + startTimerIfNecessary(); +} + +void PluginHalter::startTimerIfNecessary() +{ + if (m_timer.isActive()) + return; + + if (m_plugins.isEmpty()) + return; + + double nextFireInterval = static_cast(m_pluginAllowedRunTime) - (currentTime() - m_oldestStartTime); + m_timer.startOneShot(nextFireInterval < 0 ? 0 : nextFireInterval); +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/page/PluginHalter.h b/src/3rdparty/webkit/WebCore/page/PluginHalter.h new file mode 100644 index 0000000..26f5101 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/page/PluginHalter.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PluginHalter_h +#define PluginHalter_h + +#include "Timer.h" +#include + +namespace WebCore { + +class HaltablePlugin; +class PluginHalterClient; + +class PluginHalter { +public: + PluginHalter(PluginHalterClient*); + + void didStartPlugin(HaltablePlugin*); + void didStopPlugin(HaltablePlugin*); + + void setPluginAllowedRunTime(unsigned runTime) { m_pluginAllowedRunTime = runTime; } + +private: + void timerFired(Timer*); + void startTimerIfNecessary(); + + PluginHalterClient* m_client; + Timer m_timer; + unsigned m_pluginAllowedRunTime; + double m_oldestStartTime; + HashMap m_plugins; +}; + +} // namespace WebCore + +#endif // PluginHalter_h diff --git a/src/3rdparty/webkit/WebCore/page/PluginHalterClient.h b/src/3rdparty/webkit/WebCore/page/PluginHalterClient.h new file mode 100644 index 0000000..7ea460a --- /dev/null +++ b/src/3rdparty/webkit/WebCore/page/PluginHalterClient.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PluginHalterClient_h +#define PluginHalterClient_h + +namespace WebCore { + +class Node; + +class PluginHalterClient { +public: + virtual ~PluginHalterClient() { } + + virtual bool shouldHaltPlugin(Node*) const = 0; +}; + +} // namespace WebCore + +#endif // PluginHalterClient_h diff --git a/src/3rdparty/webkit/WebCore/page/Settings.cpp b/src/3rdparty/webkit/WebCore/page/Settings.cpp index da36fee..708d595 100644 --- a/src/3rdparty/webkit/WebCore/page/Settings.cpp +++ b/src/3rdparty/webkit/WebCore/page/Settings.cpp @@ -61,6 +61,7 @@ Settings::Settings(Page* page) , m_defaultFontSize(0) , m_defaultFixedFontSize(0) , m_maximumDecodedImageSize(numeric_limits::max()) + , m_pluginAllowedRunTime(numeric_limits::max()) , m_isJavaEnabled(false) , m_loadsImagesAutomatically(false) , m_privateBrowsingEnabled(false) @@ -114,6 +115,8 @@ Settings::Settings(Page* page) , m_downloadableBinaryFontsEnabled(true) , m_xssAuditorEnabled(false) , m_acceleratedCompositingEnabled(true) + , m_experimentalNotificationsEnabled(false) + , m_pluginHalterEnabled(false) { // A Frame may not have been created yet, so we initialize the AtomicString // hash before trying to use it. @@ -497,6 +500,27 @@ void Settings::setAcceleratedCompositingEnabled(bool enabled) setNeedsReapplyStylesInAllFrames(m_page); } +void Settings::setExperimentalNotificationsEnabled(bool enabled) +{ + m_experimentalNotificationsEnabled = enabled; +} + +void Settings::setPluginHalterEnabled(bool enabled) +{ + if (m_pluginHalterEnabled == enabled) + return; + + m_pluginHalterEnabled = enabled; + + m_page->pluginHalterEnabledStateChanged(); +} + +void Settings::setPluginAllowedRunTime(unsigned runTime) +{ + m_pluginAllowedRunTime = runTime; + m_page->pluginAllowedRunTimeChanged(); +} + #if PLATFORM(WIN) || (PLATFORM(WIN_OS) && PLATFORM(WX)) void Settings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers) { diff --git a/src/3rdparty/webkit/WebCore/page/Settings.h b/src/3rdparty/webkit/WebCore/page/Settings.h index 7900c91..b3daf19 100644 --- a/src/3rdparty/webkit/WebCore/page/Settings.h +++ b/src/3rdparty/webkit/WebCore/page/Settings.h @@ -253,11 +253,20 @@ namespace WebCore { void setAcceleratedCompositingEnabled(bool); bool acceleratedCompositingEnabled() const { return m_acceleratedCompositingEnabled; } + void setExperimentalNotificationsEnabled(bool); + bool experimentalNotificationsEnabled() const { return m_experimentalNotificationsEnabled; } + #if PLATFORM(WIN) || (PLATFORM(WIN_OS) && PLATFORM(WX)) static void setShouldUseHighResolutionTimers(bool); static bool shouldUseHighResolutionTimers() { return gShouldUseHighResolutionTimers; } #endif + void setPluginHalterEnabled(bool); + bool pluginHalterEnabled() const { return m_pluginHalterEnabled; } + + void setPluginAllowedRunTime(unsigned); + unsigned pluginAllowedRunTime() const { return m_pluginAllowedRunTime; } + private: Page* m_page; @@ -278,6 +287,7 @@ namespace WebCore { int m_defaultFontSize; int m_defaultFixedFontSize; size_t m_maximumDecodedImageSize; + unsigned m_pluginAllowedRunTime; bool m_isJavaEnabled : 1; bool m_loadsImagesAutomatically : 1; bool m_privateBrowsingEnabled : 1; @@ -322,6 +332,8 @@ namespace WebCore { bool m_downloadableBinaryFontsEnabled : 1; bool m_xssAuditorEnabled : 1; bool m_acceleratedCompositingEnabled : 1; + bool m_experimentalNotificationsEnabled : 1; + bool m_pluginHalterEnabled : 1; #if USE(SAFARI_THEME) static bool gShouldPaintNativeControls; diff --git a/src/3rdparty/webkit/WebCore/page/android/InspectorControllerAndroid.cpp b/src/3rdparty/webkit/WebCore/page/android/InspectorControllerAndroid.cpp index 3ba64e9..978bc25 100644 --- a/src/3rdparty/webkit/WebCore/page/android/InspectorControllerAndroid.cpp +++ b/src/3rdparty/webkit/WebCore/page/android/InspectorControllerAndroid.cpp @@ -90,6 +90,7 @@ void InspectorController::addProfile(PassRefPtr, unsigned int, con void InspectorController::inspectedPageDestroyed() {} void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, JSC::UString& sourceString) {} +void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame) {} void InspectorController::startGroup(MessageSource source, JSC::ExecState* exec, const JSC::ArgList& arguments, unsigned lineNumber, const String& sourceURL) {} void InspectorController::endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL) {} void InspectorController::startTiming(const JSC::UString& title) {} diff --git a/src/3rdparty/webkit/WebCore/platform/Pasteboard.h b/src/3rdparty/webkit/WebCore/platform/Pasteboard.h index cd6a3b5..188b962 100644 --- a/src/3rdparty/webkit/WebCore/platform/Pasteboard.h +++ b/src/3rdparty/webkit/WebCore/platform/Pasteboard.h @@ -86,6 +86,7 @@ public: static Pasteboard* generalPasteboard(); void writeSelection(Range*, bool canSmartCopyOrDelete, Frame*); + void writePlainText(const String&); void writeURL(const KURL&, const String&, Frame* = 0); void writeImage(Node*, const KURL&, const String& title); #if PLATFORM(MAC) diff --git a/src/3rdparty/webkit/WebCore/platform/PlatformWheelEvent.h b/src/3rdparty/webkit/WebCore/platform/PlatformWheelEvent.h index 537deac..9a4a0cb 100644 --- a/src/3rdparty/webkit/WebCore/platform/PlatformWheelEvent.h +++ b/src/3rdparty/webkit/WebCore/platform/PlatformWheelEvent.h @@ -93,6 +93,15 @@ namespace WebCore { void accept() { m_isAccepted = true; } void ignore() { m_isAccepted = false; } + void turnVerticalTicksIntoHorizontal() + { + m_deltaX = m_deltaY; + m_deltaY = 0; + + m_wheelTicksX = m_wheelTicksY; + m_wheelTicksY = 0; + } + #if PLATFORM(GTK) PlatformWheelEvent(GdkEventScroll*); #endif diff --git a/src/3rdparty/webkit/WebCore/platform/android/TemporaryLinkStubs.cpp b/src/3rdparty/webkit/WebCore/platform/android/TemporaryLinkStubs.cpp index b68a74c..c0b57a6 100644 --- a/src/3rdparty/webkit/WebCore/platform/android/TemporaryLinkStubs.cpp +++ b/src/3rdparty/webkit/WebCore/platform/android/TemporaryLinkStubs.cpp @@ -175,6 +175,11 @@ void Pasteboard::writeSelection(Range*, bool, Frame*) notImplemented(); } +void Pasteboard::writePlainText(const String&) +{ + notImplemented(); +} + void Pasteboard::writeURL(const KURL&, const String&, Frame*) { notImplemented(); diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/GraphicsContext3D.h b/src/3rdparty/webkit/WebCore/platform/graphics/GraphicsContext3D.h index cbbf2b4..edda215 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/GraphicsContext3D.h +++ b/src/3rdparty/webkit/WebCore/platform/graphics/GraphicsContext3D.h @@ -62,6 +62,11 @@ namespace WebCore { class ImageData; class WebKitCSSMatrix; + // FIXME: ideally this would be used on all platforms. +#if PLATFORM(SKIA) + class GraphicsContext3DInternal; +#endif + class GraphicsContext3D : Noncopyable { public: enum ShaderType { FRAGMENT_SHADER, VERTEX_SHADER }; @@ -308,10 +313,6 @@ namespace WebCore { private: int m_currentWidth, m_currentHeight; -#if PLATFORM(SKIA) -#include "GraphicsContext3DSkia.h" -#endif - #if PLATFORM(MAC) Vector > m_vertexArray; @@ -320,6 +321,12 @@ namespace WebCore { GLuint m_fbo; GLuint m_depthBuffer; #endif + + // FIXME: ideally this would be used on all platforms. +#if PLATFORM(SKIA) + friend class GraphicsContext3DInternal; + OwnPtr m_internal; +#endif }; } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/platform/mac/PasteboardMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/PasteboardMac.mm index e21f549..f048791 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/PasteboardMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/PasteboardMac.mm @@ -135,8 +135,8 @@ static NSAttributedString *stripAttachmentCharacters(NSAttributedString *string) void Pasteboard::writeSelection(NSPasteboard* pasteboard, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) { - if (WebArchivePboardType == nil) - Pasteboard::generalPasteboard(); //Initialises pasteboard types + if (!WebArchivePboardType) + Pasteboard::generalPasteboard(); // Initialises pasteboard types ASSERT(selectedRange); NSAttributedString *attributedString = [[[NSAttributedString alloc] _initWithDOMRange:kit(selectedRange)] autorelease]; @@ -203,12 +203,24 @@ void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Pasteboard::writeSelection(m_pasteboard.get(), selectedRange, canSmartCopyOrDelete, frame); } +void Pasteboard::writePlainText(const String& text) +{ + if (!WebArchivePboardType) + Pasteboard::generalPasteboard(); // Initialises pasteboard types + + NSArray *types = [NSArray arrayWithObject:NSStringPboardType]; + NSPasteboard *pasteboard = m_pasteboard.get(); + [pasteboard declareTypes:types owner:nil]; + + [pasteboard setString:text forType:NSStringPboardType]; +} + void Pasteboard::writeURL(NSPasteboard* pasteboard, NSArray* types, const KURL& url, const String& titleStr, Frame* frame) { - if (WebArchivePboardType == nil) - Pasteboard::generalPasteboard(); //Initialises pasteboard types + if (!WebArchivePboardType) + Pasteboard::generalPasteboard(); // Initialises pasteboard types - if (types == nil) { + if (!types) { types = writableTypesForURL(); [pasteboard declareTypes:types owner:nil]; } diff --git a/src/3rdparty/webkit/WebCore/platform/qt/PasteboardQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/PasteboardQt.cpp index 969de62..209a573 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/PasteboardQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/PasteboardQt.cpp @@ -119,6 +119,18 @@ PassRefPtr Pasteboard::documentFragment(Frame* frame, PassRefP return 0; } +void Pasteboard::writePlainText(const String& text) +{ +#ifndef QT_NO_CLIPBOARD + QMimeData* md = new QMimeData; + QString qtext = text; + qtext.replace(QChar(0xa0), QLatin1Char(' ')); + md->setText(qtext); + QApplication::clipboard()->setMimeData(md, m_selectionMode ? + QClipboard::Selection : QClipboard::Clipboard); +#endif +} + void Pasteboard::writeURL(const KURL& _url, const String&, Frame*) { ASSERT(!_url.isEmpty()); diff --git a/src/3rdparty/webkit/WebCore/platform/text/qt/TextCodecQt.cpp b/src/3rdparty/webkit/WebCore/platform/text/qt/TextCodecQt.cpp index c6c02cf..e351522 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/qt/TextCodecQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/text/qt/TextCodecQt.cpp @@ -94,7 +94,26 @@ TextCodecQt::~TextCodecQt() String TextCodecQt::decode(const char* bytes, size_t length, bool flush, bool /*stopOnError*/, bool& sawError) { - QString unicode = m_codec->toUnicode(bytes, length, &m_state); + // We chop input buffer to smaller buffers to avoid excessive memory consumption + // when the input buffer is big. This helps reduce peak memory consumption in + // mobile devices where system RAM is limited. +#if PLATFORM(SYMBIAN) + static const int MaxInputChunkSize = 32 * 1024; +#else + static const int MaxInputChunkSize = 1024 * 1024; +#endif + const char* buf = bytes; + const char* end = buf + length; + String unicode; + + while (buf < end) { + int size = end - buf; + size = qMin(size, MaxInputChunkSize); + QString decoded = m_codec->toUnicode(buf, size, &m_state); + unicode.append(decoded); + buf += size; + } + sawError = m_state.invalidChars != 0; if (flush) { diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp index cea226e..dd58ed1 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp @@ -2456,7 +2456,7 @@ void RenderBox::calcAbsoluteHorizontalReplaced() // positioned, inline containing block because right now, it is using the xPos // of the first line box when really it should use the last line box. When // this is fixed elsewhere, this block should be removed. - if (containerBlock->isInline() && containerBlock->style()->direction() == RTL) { + if (containerBlock->isRenderInline() && containerBlock->style()->direction() == RTL) { const RenderInline* flow = toRenderInline(containerBlock); InlineFlowBox* firstLine = flow->firstLineBox(); InlineFlowBox* lastLine = flow->lastLineBox(); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderObject.h b/src/3rdparty/webkit/WebCore/rendering/RenderObject.h index e5a0c16..34f2b8b 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderObject.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderObject.h @@ -985,6 +985,42 @@ inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRenderi #endif } +inline int adjustForAbsoluteZoom(int value, RenderObject* renderer) +{ + float zoomFactor = renderer->style()->effectiveZoom(); + if (zoomFactor == 1) + return value; + // Needed because computeLengthInt truncates (rather than rounds) when scaling up. + if (zoomFactor > 1) + value++; + return static_cast(value / zoomFactor); +} + +inline void adjustIntRectForAbsoluteZoom(IntRect& rect, RenderObject* renderer) +{ + rect.setX(adjustForAbsoluteZoom(rect.x(), renderer)); + rect.setY(adjustForAbsoluteZoom(rect.y(), renderer)); + rect.setWidth(adjustForAbsoluteZoom(rect.width(), renderer)); + rect.setHeight(adjustForAbsoluteZoom(rect.height(), renderer)); +} + +inline FloatPoint adjustFloatPointForAbsoluteZoom(const FloatPoint& point, RenderObject* renderer) +{ + // The result here is in floats, so we don't need the truncation hack from the integer version above. + float zoomFactor = renderer->style()->effectiveZoom(); + if (zoomFactor == 1) + return point; + return FloatPoint(point.x() / zoomFactor, point.y() / zoomFactor); +} + +inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer) +{ + quad.setP1(adjustFloatPointForAbsoluteZoom(quad.p1(), renderer)); + quad.setP2(adjustFloatPointForAbsoluteZoom(quad.p2(), renderer)); + quad.setP3(adjustFloatPointForAbsoluteZoom(quad.p3(), renderer)); + quad.setP4(adjustFloatPointForAbsoluteZoom(quad.p4(), renderer)); +} + } // namespace WebCore #ifndef NDEBUG diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTextControl.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderTextControl.cpp index cd90854..f430399 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTextControl.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTextControl.cpp @@ -67,9 +67,9 @@ static Color disabledTextColor(const Color& textColor, const Color& backgroundCo return disabledColor; } -RenderTextControl::RenderTextControl(Node* node) +RenderTextControl::RenderTextControl(Node* node, bool placeholderVisible) : RenderBlock(node) - , m_placeholderVisible(false) + , m_placeholderVisible(placeholderVisible) , m_edited(false) , m_userEdited(false) { diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTextControl.h b/src/3rdparty/webkit/WebCore/rendering/RenderTextControl.h index 3212a1b..cdd8716 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTextControl.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTextControl.h @@ -59,7 +59,7 @@ public: void updatePlaceholderVisibility(bool, bool); protected: - RenderTextControl(Node*); + RenderTextControl(Node*, bool); int scrollbarThickness() const; void adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle* textBlockStyle) const; diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.cpp index 3f0d041..8478432 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.cpp @@ -31,10 +31,9 @@ namespace WebCore { -RenderTextControlMultiLine::RenderTextControlMultiLine(Node* node) - : RenderTextControl(node) +RenderTextControlMultiLine::RenderTextControlMultiLine(Node* node, bool placeholderVisible) + : RenderTextControl(node, placeholderVisible) { - m_placeholderVisible = static_cast(node)->placeholderShouldBeVisible(); } RenderTextControlMultiLine::~RenderTextControlMultiLine() diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.h b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.h index 333cfa8..3371a8f 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlMultiLine.h @@ -28,7 +28,7 @@ namespace WebCore { class RenderTextControlMultiLine : public RenderTextControl { public: - RenderTextControlMultiLine(Node*); + RenderTextControlMultiLine(Node*, bool); virtual ~RenderTextControlMultiLine(); void forwardEvent(Event*); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.cpp index 794be17..8d8ba97 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.cpp @@ -48,14 +48,13 @@ namespace WebCore { using namespace HTMLNames; -RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node) - : RenderTextControl(node) +RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node, bool placeholderVisible) + : RenderTextControl(node, placeholderVisible) , m_searchPopupIsVisible(false) , m_shouldDrawCapsLockIndicator(false) , m_searchEventTimer(this, &RenderTextControlSingleLine::searchEventTimerFired) , m_searchPopup(0) { - m_placeholderVisible = inputElement()->placeholderShouldBeVisible(); } RenderTextControlSingleLine::~RenderTextControlSingleLine() @@ -460,7 +459,7 @@ void RenderTextControlSingleLine::updateFromElement() if (m_placeholderVisible) { ExceptionCode ec = 0; - innerTextElement()->setInnerText(inputElement()->placeholder(), ec); + innerTextElement()->setInnerText(static_cast(node())->getAttribute(placeholderAttr), ec); ASSERT(!ec); } else setInnerTextValue(inputElement()->value()); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.h b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.h index 817efb2..4a17918 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderTextControlSingleLine.h @@ -36,7 +36,7 @@ class TextControlInnerElement; class RenderTextControlSingleLine : public RenderTextControl, private PopupMenuClient { public: - RenderTextControlSingleLine(Node*); + RenderTextControlSingleLine(Node*, bool); virtual ~RenderTextControlSingleLine(); bool placeholderIsVisible() const { return m_placeholderVisible; } diff --git a/src/3rdparty/webkit/WebCore/storage/StorageAreaImpl.cpp b/src/3rdparty/webkit/WebCore/storage/StorageAreaImpl.cpp index 0d69216..66447d3 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageAreaImpl.cpp +++ b/src/3rdparty/webkit/WebCore/storage/StorageAreaImpl.cpp @@ -47,6 +47,11 @@ StorageAreaImpl::~StorageAreaImpl() { } +PassRefPtr StorageAreaImpl::create(StorageType storageType, PassRefPtr origin, PassRefPtr syncManager) +{ + return adoptRef(new StorageAreaImpl(storageType, origin, syncManager)); +} + StorageAreaImpl::StorageAreaImpl(StorageType storageType, PassRefPtr origin, PassRefPtr syncManager) : m_storageType(storageType) , m_securityOrigin(origin) diff --git a/src/3rdparty/webkit/WebCore/storage/StorageAreaImpl.h b/src/3rdparty/webkit/WebCore/storage/StorageAreaImpl.h index b98482b..a7cc9f6 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageAreaImpl.h +++ b/src/3rdparty/webkit/WebCore/storage/StorageAreaImpl.h @@ -30,6 +30,7 @@ #include "StorageArea.h" +#include #include namespace WebCore { @@ -40,7 +41,7 @@ namespace WebCore { class StorageAreaImpl : public StorageArea { public: - StorageAreaImpl(StorageType, PassRefPtr, PassRefPtr); + static PassRefPtr create(StorageType, PassRefPtr, PassRefPtr); virtual ~StorageAreaImpl(); // The HTML5 DOM Storage API (and contains) @@ -60,6 +61,7 @@ namespace WebCore { SecurityOrigin* securityOrigin(); private: + StorageAreaImpl(StorageType, PassRefPtr, PassRefPtr); StorageAreaImpl(StorageAreaImpl*); void blockUntilImportComplete() const; diff --git a/src/3rdparty/webkit/WebCore/storage/StorageNamespace.h b/src/3rdparty/webkit/WebCore/storage/StorageNamespace.h index 825581f..6866746 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageNamespace.h +++ b/src/3rdparty/webkit/WebCore/storage/StorageNamespace.h @@ -45,7 +45,7 @@ namespace WebCore { static PassRefPtr sessionStorageNamespace(); virtual ~StorageNamespace() { } - virtual PassRefPtr storageArea(SecurityOrigin*) = 0; + virtual PassRefPtr storageArea(PassRefPtr) = 0; virtual PassRefPtr copy() = 0; virtual void close() = 0; virtual void unlock() = 0; diff --git a/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp b/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp index 5ac22cf..d5af31f 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp +++ b/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp @@ -99,17 +99,18 @@ PassRefPtr StorageNamespaceImpl::copy() return adoptRef(newNamespace); } -PassRefPtr StorageNamespaceImpl::storageArea(SecurityOrigin* origin) +PassRefPtr StorageNamespaceImpl::storageArea(PassRefPtr prpOrigin) { ASSERT(isMainThread()); ASSERT(!m_isShutdown); + RefPtr origin = prpOrigin; RefPtr storageArea; if (storageArea = m_storageAreaMap.get(origin)) return storageArea.release(); - storageArea = adoptRef(new StorageAreaImpl(m_storageType, origin, m_syncManager)); - m_storageAreaMap.set(origin, storageArea); + storageArea = StorageAreaImpl::create(m_storageType, origin, m_syncManager); + m_storageAreaMap.set(origin.release(), storageArea); return storageArea.release(); } diff --git a/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.h b/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.h index d3ef37f..05a12ad 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.h +++ b/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.h @@ -46,7 +46,7 @@ namespace WebCore { static PassRefPtr sessionStorageNamespace(); virtual ~StorageNamespaceImpl(); - virtual PassRefPtr storageArea(SecurityOrigin*); + virtual PassRefPtr storageArea(PassRefPtr); virtual PassRefPtr copy(); virtual void close(); virtual void unlock(); diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp index e301c86..bb68b82 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp @@ -239,13 +239,14 @@ bool SVGImage::dataChanged(bool allDataReceived) static DragClient* dummyDragClient = 0; #endif static InspectorClient* dummyInspectorClient = new EmptyInspectorClient; + static PluginHalterClient* dummyPluginHalterClient = new EmptyPluginHalterClient; m_chromeClient.set(new SVGImageChromeClient(this)); // FIXME: If this SVG ends up loading itself, we might leak the world. // THe comment said that the Cache code does not know about CachedImages // holding Frames and won't know to break the cycle. But - m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient)); + m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient, dummyPluginHalterClient)); m_page->settings()->setJavaScriptEnabled(false); m_page->settings()->setPluginsEnabled(false); diff --git a/src/3rdparty/webkit/WebCore/wml/WMLInputElement.cpp b/src/3rdparty/webkit/WebCore/wml/WMLInputElement.cpp index 2dbdaf0..b027bf0 100644 --- a/src/3rdparty/webkit/WebCore/wml/WMLInputElement.cpp +++ b/src/3rdparty/webkit/WebCore/wml/WMLInputElement.cpp @@ -134,7 +134,6 @@ String WMLInputElement::value() const void WMLInputElement::setValue(const String& value) { - InputElement::updatePlaceholderVisibility(this, this); setFormControlValueMatchesRenderer(false); m_data.setValue(constrainValue(value)); if (inDocument()) @@ -221,7 +220,7 @@ void WMLInputElement::copyNonAttributeProperties(const Element* source) RenderObject* WMLInputElement::createRenderer(RenderArena* arena, RenderStyle*) { - return new (arena) RenderTextControlSingleLine(this); + return new (arena) RenderTextControlSingleLine(this, false); } void WMLInputElement::detach() @@ -318,11 +317,6 @@ void WMLInputElement::documentDidBecomeActive() reset(); } -bool WMLInputElement::placeholderShouldBeVisible() const -{ - return InputElement::placeholderShouldBeVisible(this, this); -} - void WMLInputElement::willMoveToNewOwnerDocument() { // Always unregister for cache callbacks when leaving a document, even if we would otherwise like to be registered diff --git a/src/3rdparty/webkit/WebCore/wml/WMLInputElement.h b/src/3rdparty/webkit/WebCore/wml/WMLInputElement.h index 7eb2455..98ea13a 100644 --- a/src/3rdparty/webkit/WebCore/wml/WMLInputElement.h +++ b/src/3rdparty/webkit/WebCore/wml/WMLInputElement.h @@ -58,8 +58,6 @@ public: virtual const AtomicString& formControlName() const; virtual String value() const; virtual void setValue(const String&); - virtual String placeholder() const { return String(); } - virtual void setPlaceholder(const String&) { } virtual void setValueFromRenderer(const String&); virtual bool saveFormControlState(String& value) const; @@ -82,7 +80,6 @@ public: virtual String sanitizeValue(const String& proposedValue) const { return constrainValue(proposedValue); } virtual void documentDidBecomeActive(); - virtual bool placeholderShouldBeVisible() const; virtual void willMoveToNewOwnerDocument(); virtual void didMoveToNewOwnerDocument(); diff --git a/src/3rdparty/webkit/WebCore/xml/XMLHttpRequest.cpp b/src/3rdparty/webkit/WebCore/xml/XMLHttpRequest.cpp index 798ae00..ca48d8d 100644 --- a/src/3rdparty/webkit/WebCore/xml/XMLHttpRequest.cpp +++ b/src/3rdparty/webkit/WebCore/xml/XMLHttpRequest.cpp @@ -709,23 +709,19 @@ String XMLHttpRequest::getResponseHeader(const AtomicString& name, ExceptionCode { if (m_state < HEADERS_RECEIVED) { ec = INVALID_STATE_ERR; - return ""; + return String(); } - if (!isValidToken(name)) - return ""; - // See comment in getAllResponseHeaders above. if (isSetCookieHeader(name) && !scriptExecutionContext()->securityOrigin()->canLoadLocalResources()) { reportUnsafeUsage(scriptExecutionContext(), "Refused to get unsafe header \"" + name + "\""); - return ""; + return String(); } if (!m_sameOriginRequest && !isOnAccessControlResponseHeaderWhitelist(name)) { reportUnsafeUsage(scriptExecutionContext(), "Refused to get unsafe header \"" + name + "\""); - return ""; + return String(); } - return m_response.httpHeaderField(name); } diff --git a/src/3rdparty/webkit/WebKit/ChangeLog b/src/3rdparty/webkit/WebKit/ChangeLog index b317193..7d55d82 100644 --- a/src/3rdparty/webkit/WebKit/ChangeLog +++ b/src/3rdparty/webkit/WebKit/ChangeLog @@ -1,3 +1,14 @@ +2009-09-26 David Kilzer + + Part 2 of 2: DerivedSources.make broken for non-Mac targets + + Reviewed by Darin Adler. + + Fix ENABLE_ORIENTATION_EVENTS for non-Mac platforms. + + * chromium/features.gypi: Added 'ENABLE_ORIENTATION_EVENTS=0' to + disable this feature by default. + 2009-09-22 Yaar Schnitman Reviewed by David Levin. diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp index ff086f6..939d881 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp @@ -95,16 +95,6 @@ public: It is possible to replace the contents of child elements using setPlainText() and setInnerXml(). To replace the element itself and its contents, use setOuterXml(). - - In the JavaScript DOM interfaces, elements can have additional functions - depending on their type. For example, an HTML form element can be triggered - to submit the entire form to the web server using the submit() function. A - list of these special functions can be obtained in QWebElement using - functions(); they can be invoked using callFunction(). - - Similarly, element specific properties can be obtained using - scriptableProperties() and read or written using scriptableProperty() or - setScriptableProperty(). */ /*! @@ -473,6 +463,33 @@ bool QWebElement::hasAttributes() const } /*! + Returns true if the element has keyboard input focus; otherwise, returns false + + \sa setFocus() +*/ +bool QWebElement::hasFocus() const +{ + if (!m_element) + return false; + if (m_element->document()) + return m_element == m_element->document()->focusedNode(); + return false; +} + +/*! + Gives keyboard input focus to this element + + \sa hasFocus() +*/ +void QWebElement::setFocus() +{ + if (!m_element) + return; + if (m_element->document() && m_element->isFocusable()) + m_element->document()->setFocusedNode(m_element); +} + +/*! Returns the geometry of this element, relative to its containing frame. \sa tagName() @@ -673,41 +690,10 @@ static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValu } -static bool setupScriptObject(WebCore::Element* element, ScriptObject& object, ScriptState*& state, ScriptController*& scriptController) -{ - if (!element) - return false; - - Document* document = element->document(); - if (!document) - return false; - - Frame* frame = document->frame(); - if (!frame) - return false; - - scriptController = frame->script(); - - state = scriptController->globalObject()->globalExec(); - - JSC::JSValue thisValue = toJS(state, element); - if (!thisValue) - return false; - - JSC::JSObject* thisObject = thisValue.toObject(state); - if (!thisObject) - return false; - - object = ScriptObject(state, thisObject); - return true; -} - /*! Executes \a scriptSource with this element as \c this object. - - \sa callFunction() */ -QVariant QWebElement::evaluateScript(const QString& scriptSource) +QVariant QWebElement::evaluateJavaScript(const QString& scriptSource) { if (scriptSource.isEmpty()) return QVariant(); @@ -734,256 +720,25 @@ QVariant QWebElement::evaluateScript(const QString& scriptSource) } /*! - Calls the function with the given \a name and \a arguments. - - The underlying DOM element that QWebElement wraps may have dedicated - functions, depending on its type. For example, a form element can have the - \c submit function, that would submit the form to the destination specified - in the HTML. - - \sa functions() -*/ -QVariant QWebElement::callFunction(const QString &name, const QVariantList &arguments) -{ - ScriptState* state = 0; - ScriptObject thisObject; - ScriptController* scriptController = 0; - - if (!setupScriptObject(m_element, thisObject, state, scriptController)) - return QVariant(); - - ScriptFunctionCall functionCall(state, thisObject, name); - - for (QVariantList::ConstIterator it = arguments.constBegin(), end = arguments.constEnd(); - it != end; ++it) - functionCall.appendArgument(JSC::Bindings::convertQVariantToValue(state, scriptController->bindingRootObject(), *it)); - - bool hadException = false; - ScriptValue result = functionCall.call(hadException); - if (hadException) - return QVariant(); - - int distance = 0; - return JSC::Bindings::convertValueToQVariant(state, result.jsValue(), QMetaType::Void, &distance); -} - -/*! - Returns a list of function names this element supports. - - The function names returned are the same functions callable from the DOM - element's JavaScript binding. - - \sa callFunction() -*/ -QStringList QWebElement::functions() const -{ - ScriptState* state = 0; - ScriptObject thisObject; - ScriptController* scriptController = 0; - - if (!setupScriptObject(m_element, thisObject, state, scriptController)) - return QStringList(); - - JSC::JSObject* object = thisObject.jsObject(); - if (!object) - return QStringList(); - - QStringList names; - - // Enumerate the contents of the object - JSC::PropertyNameArray properties(state); - object->getPropertyNames(state, properties); - for (JSC::PropertyNameArray::const_iterator it = properties.begin(); - it != properties.end(); ++it) { - - JSC::JSValue property = object->get(state, *it); - if (!property) - continue; - - JSC::JSObject* function = property.toObject(state); - if (!function) - continue; - - JSC::CallData callData; - JSC::CallType callType = function->getCallData(callData); - if (callType == JSC::CallTypeNone) - continue; - - JSC::UString ustring = (*it).ustring(); - names << QString::fromUtf16((const ushort*)ustring.rep()->data(), ustring.size()); - } - - if (state->hadException()) - state->clearException(); - - return names; -} - -/*! - Returns the value of the element's \a name property. If no such property - exists, an invalid QVariant is returned. - - The return value's property has the same value as the corresponding - property in the element's JavaScript binding with the same name. - - Information about all available properties is provided through - scriptProperties(). - - \sa setScriptableProperty(), scriptableProperties() -*/ -QVariant QWebElement::scriptableProperty(const QString &name) const -{ - ScriptState* state = 0; - ScriptObject thisObject; - ScriptController *scriptController = 0; - - if (!setupScriptObject(m_element, thisObject, state, scriptController)) - return QVariant(); - - String wcName(name); - JSC::JSValue property = thisObject.jsObject()->get(state, JSC::Identifier(state, wcName)); - - // ### - if (state->hadException()) - state->clearException(); - - int distance = 0; - return JSC::Bindings::convertValueToQVariant(state, property, QMetaType::Void, &distance); -} - -/*! - Sets the value of the element's \a name property to \a value. - - Information about all available properties is provided through - scriptProperties(). - - Setting the property will affect the corresponding property in the - element's JavaScript binding with the same name. - - \sa scriptableProperty(), scriptableProperties() -*/ -void QWebElement::setScriptableProperty(const QString &name, const QVariant &value) -{ - ScriptState* state = 0; - ScriptObject thisObject; - ScriptController* scriptController = 0; - - if (!setupScriptObject(m_element, thisObject, state, scriptController)) - return; - - JSC::JSValue jsValue = JSC::Bindings::convertQVariantToValue(state, scriptController->bindingRootObject(), value); - if (!jsValue) - return; - - String wcName(name); - JSC::PutPropertySlot slot; - thisObject.jsObject()->put(state, JSC::Identifier(state, wcName), jsValue, slot); - if (state->hadException()) - state->clearException(); -} - -/*! - Returns a list of property names this element supports. - - The function names returned are the same properties that are accessible - from the DOM element's JavaScript binding. - - \sa setScriptableProperty(), scriptableProperty() -*/ -QStringList QWebElement::scriptableProperties() const -{ - if (!m_element) - return QStringList(); - - Document* document = m_element->document(); - if (!document) - return QStringList(); - - Frame* frame = document->frame(); - if (!frame) - return QStringList(); - - ScriptController* script = frame->script(); - JSC::ExecState* exec = script->globalObject()->globalExec(); - - JSC::JSValue thisValue = toJS(exec, m_element); - if (!thisValue) - return QStringList(); - - JSC::JSObject* object = thisValue.toObject(exec); - if (!object) - return QStringList(); - - QStringList names; - - // Enumerate the contents of the object - JSC::PropertyNameArray properties(exec); - object->getPropertyNames(exec, properties); - for (JSC::PropertyNameArray::const_iterator it = properties.begin(); - it != properties.end(); ++it) { - - JSC::JSValue property = object->get(exec, *it); - if (!property) - continue; - - JSC::JSObject* function = property.toObject(exec); - if (!function) - continue; - - JSC::CallData callData; - JSC::CallType callType = function->getCallData(callData); - if (callType != JSC::CallTypeNone) - continue; - - JSC::UString ustring = (*it).ustring(); - names << QString::fromUtf16((const ushort*)ustring.rep()->data(), ustring.size()); - } - - if (exec->hadException()) - exec->clearException(); - - return names; -} - -/*! - \enum QWebElement::ResolveRule - \since 4.6 + \enum QWebElement::StyleResolveStrategy This enum describes how QWebElement's styleProperty resolves the given property name. - \value IgnoreCascadingStyles Return the property value as it is defined in + \value InlineStyle Return the property value as it is defined in the element, without respecting style inheritance and other CSS rules. - \value RespectCascadingStyles The property's value is determined using the + \value CascadedStyle The property's value is determined using the inheritance and importance rules defined in the document's stylesheet. + \value ComputedStyle The property's value is the absolute value + of the style property resolved from the environment. */ /*! - \enum QWebElement::StylePriority - \since 4.6 - - This enum describes the priority newly set CSS properties should have when - set using QWebElement::setStyleProperty(). - - \value NormalStylePriority Define the property without important priority - even if "!important" is explicitly set in \a value. - \value DeclaredStylePriority Define the property respecting the priority - specified in \a value. - \value ImportantStylePriority Define the property to have an important - priority. This is equal to appending "!important" to the value. -*/ - -/*! - Returns the value of the style with the given \a name. If a style with - \a name does not exist, an empty string is returned. - - If \a rule is IgnoreCascadingStyles, the value defined inside the element - (inline in CSS terminology) is returned. - - if \a rule is RespectCascadingStyles, the actual style applied to the - element is returned. + Returns the value of the style with the given \a name using the specified + \a strategy. If a style with \a name does not exist, an empty string is + returned. In CSS, the cascading part depends on which CSS rule has priority and is thus applied. Generally, the last defined rule has priority. Thus, an @@ -997,7 +752,8 @@ QStringList QWebElement::scriptableProperties() const \sa setStyleProperty() */ -QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const + +QString QWebElement::styleProperty(const QString &name, StyleResolveStrategy strategy) const { if (!m_element || !m_element->isStyledElement()) return QString(); @@ -1009,10 +765,10 @@ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const CSSStyleDeclaration* style = static_cast(m_element)->style(); - if (rule == IgnoreCascadingStyles) + if (strategy == InlineStyle) return style->getPropertyValue(propID); - if (rule == RespectCascadingStyles) { + if (strategy == CascadedStyle) { if (style->getPropertyPriority(propID)) return style->getPropertyValue(propID); @@ -1040,33 +796,33 @@ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const return style->getPropertyValue(propID); } + if (strategy == ComputedStyle) { + if (!m_element || !m_element->isStyledElement()) + return QString(); + + int propID = cssPropertyID(name); + + RefPtr style = computedStyle(m_element); + if (!propID || !style) + return QString(); + + return style->getPropertyValue(propID); + } + return QString(); } /*! - Sets the value of the style with the given \a name to \a value. + Sets the value of the inline style with the given \a name to \a value. Setting a value, does not necessarily mean that it will become the applied value, due to the fact that the style property's value might have been set - earlier with priority in external or embedded style declarations. - - In order to ensure that the value will be applied, ImportantStylePriority - should be used as \a priority. + earlier with a higher priority in external or embedded style declarations. - Following the CSS syntax for property values, this is equal to appending + In order to ensure that the value will be applied, you may have to append "!important" to the value. - - This syntax is supported when using DeclaredStylePriority as \a priority. - - Using NormalStylePriority as \a priority, the property will have normal - priority, and any "!important" declaration will be ignored. On the other - hand, using ImportantStylePriority sets the important priority even when - it is not explicitly passed in \a value. - - By using DeclaredStylePriority as \a priority the property will respect the - priority specified in \a value. */ -void QWebElement::setStyleProperty(const QString &name, const QString &value, StylePriority priority) +void QWebElement::setStyleProperty(const QString &name, const QString &value) { if (!m_element || !m_element->isStyledElement()) return; @@ -1077,43 +833,7 @@ void QWebElement::setStyleProperty(const QString &name, const QString &value, St return; ExceptionCode exception = 0; - - const QRegExp hasImportantTest(QLatin1String("!\\s*important")); - int index = value.indexOf(hasImportantTest); - - QString newValue = (index != -1) ? value.left(index - 1) : value; - - switch (priority) { - case NormalStylePriority: - style->setProperty(name, newValue, "", exception); - break; - case DeclaredStylePriority: - style->setProperty(name, newValue, (index != -1) ? "important" : "", exception); - break; - case ImportantStylePriority: - style->setProperty(name, newValue, "important", exception); - break; - default: - break; - } -} - -/*! - Returns the computed value for style with the given \a name. If a style - with \a name does not exist, an empty string is returned. -*/ -QString QWebElement::computedStyleProperty(const QString &name) const -{ - if (!m_element || !m_element->isStyledElement()) - return QString(); - - int propID = cssPropertyID(name); - - RefPtr style = computedStyle(m_element); - if (!propID || !style) - return QString(); - - return style->getPropertyValue(propID); + style->setProperty(name, value, exception); } /*! diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h index 5f4870c..3db4637 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h @@ -74,6 +74,9 @@ public: void removeClass(const QString& name); void toggleClass(const QString& name); + bool hasFocus() const; + void setFocus(); + QRect geometry() const; QString tagName() const; @@ -120,22 +123,15 @@ public: void removeFromDocument(); void removeChildren(); - QVariant evaluateScript(const QString& scriptSource); - - QVariant callFunction(const QString& functionName, const QVariantList& arguments = QVariantList()); - QStringList functions() const; - - QVariant scriptableProperty(const QString& name) const; - void setScriptableProperty(const QString& name, const QVariant& value); - QStringList scriptableProperties() const; - - enum ResolveRule { IgnoreCascadingStyles, RespectCascadingStyles }; - QString styleProperty(const QString& name, ResolveRule = IgnoreCascadingStyles) const; - - enum StylePriority { NormalStylePriority, DeclaredStylePriority, ImportantStylePriority }; - void setStyleProperty(const QString& name, const QString& value, StylePriority = DeclaredStylePriority); + QVariant evaluateJavaScript(const QString& scriptSource); - QString computedStyleProperty(const QString& name) const; + enum StyleResolveStrategy { + InlineStyle, + CascadedStyle, + ComputedStyle, + }; + QString styleProperty(const QString& name, StyleResolveStrategy strategy) const; + void setStyleProperty(const QString& name, const QString& value); private: explicit QWebElement(WebCore::Element*); diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index af27788..aad718b 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -271,7 +271,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) contextMenuClient = new ContextMenuClientQt(); editorClient = new EditorClientQt(q); page = new Page(chromeClient, contextMenuClient, editorClient, - new DragClientQt(q), new InspectorClientQt(q)); + new DragClientQt(q), new InspectorClientQt(q), 0); // ### should be configurable page->settings()->setDefaultTextEncodingName("iso-8859-1"); @@ -1491,11 +1491,9 @@ QWebPage::QWebPage(QObject *parent) */ QWebPage::~QWebPage() { - if (d->mainFrame) { - FrameLoader *loader = d->mainFrame->d->frame->loader(); - if (loader) - loader->detachFromParent(); - } + FrameLoader *loader = d->mainFrame->d->frame->loader(); + if (loader) + loader->detachFromParent(); if (d->inspector) d->inspector->setPage(0); delete d; @@ -1522,7 +1520,6 @@ QWebFrame *QWebPage::mainFrame() const */ QWebFrame *QWebPage::currentFrame() const { - d->createMainFrame(); return static_cast(d->page->focusController()->focusedOrMainFrame()->loader()->client())->webFrame(); } @@ -1548,7 +1545,6 @@ QWebFrame* QWebPage::frameAt(const QPoint& pos) const */ QWebHistory *QWebPage::history() const { - d->createMainFrame(); return &d->history; } diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 7020ec0..a8b5c38 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,99 @@ +2009-09-28 Andre Poenitz + + Reviewed by Simon Hausmann. + + Compile fix with namespaced Qt. + + * Api/qwebinspector_p.h: + +2009-09-27 Joe Ligman + + Reviewed by Simon Hausmann. + + [Qt] Adding API setFocus and hasFocus to QWebElement. This API is needed for + clients that want to check/set the focus node of the document. + https://bugs.webkit.org/show_bug.cgi?id=29682 + + * Api/qwebelement.cpp: + (QWebElement::hasFocus): + (QWebElement::setFocus): + * Api/qwebelement.h: + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::hasSetFocus): + +2009-09-25 Csaba Osztrogonac + + Reviewed by Simon Hausmann. + + [Qt] Make tst_qwebframe work if Qt built without SSL support + https://bugs.webkit.org/show_bug.cgi?id=29735 + + * tests/qwebframe/tst_qwebframe.cpp: Missing #ifndef blocks added. + +2009-09-24 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Update QWebElement API to remove script related methods. + QWebElement::evaluateScript is the only one kept, these are + removed to postpone most of the QtWebKit<->JavaScript API design + after 4.6. + https://bugs.webkit.org/show_bug.cgi?id=29708 + + * Api/qwebelement.cpp: + * Api/qwebelement.h: + Methods removed: + - QWebElement::callFunction + - QWebElement::functions + - QWebElement::scriptableProperty + - QWebElement::setScriptableProperty + - QWebElement::scriptableProperties + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::evaluateScript): + +2009-09-25 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Rename QWebElement::evaluateScript + to QWebElement::evaluateJavaScript. + https://bugs.webkit.org/show_bug.cgi?id=29709 + + * Api/qwebelement.cpp: + (QWebElement::evaluateJavaScript): + * Api/qwebelement.h: + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::evaluateJavaScript): + +2009-09-25 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Update the stypeProperty API of QWebElement. + https://bugs.webkit.org/show_bug.cgi?id=29711 + + * Api/qwebelement.cpp: + (QWebElement::styleProperty): + - Merge the stypeProperty and the computedStyleProperty methods + - Remove the default value for the style resolving enum + - Rename ResolveRule to StyleResolveStrategy + (QWebElement::setStyleProperty): + - Remove the priority argument since it is possible to control the + behaviour by adding !important or removing in the value. + * Api/qwebelement.h: + * tests/qwebelement/tst_qwebelement.cpp: + (tst_QWebElement::style): + (tst_QWebElement::computedStyle): + * tests/qwebframe/tst_qwebframe.cpp: + +2009-09-24 Jon Honeycutt + + Reviewed by Alice Liu. + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + Pass 0 for new Page constructor argument. + 2009-09-24 Martin Smith Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp index 0819a3a..00783d1 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp @@ -71,15 +71,11 @@ private slots: void classes(); void namespaceURI(); void foreachManipulation(); - void evaluateScript(); - void callFunction(); - void callFunctionSubmitForm(); - void functionNames(); + void evaluateJavaScript(); void documentElement(); void frame(); void style(); void computedStyle(); - void properties(); void appendAndPrepend(); void insertBeforeAndAfter(); void remove(); @@ -90,6 +86,7 @@ private slots: void nullSelect(); void firstChildNextSibling(); void lastChildPreviousSibling(); + void hasSetFocus(); private: QWebView* m_view; @@ -282,69 +279,31 @@ void tst_QWebElement::foreachManipulation() QCOMPARE(body.findAll("div").count(), 4); } -void tst_QWebElement::evaluateScript() +void tst_QWebElement::evaluateJavaScript() { QVariant result; m_mainFrame->setHtml("

test"); QWebElement para = m_mainFrame->findFirstElement("p"); - result = para.evaluateScript("this.tagName"); + result = para.evaluateJavaScript("this.tagName"); QVERIFY(result.isValid()); QVERIFY(result.type() == QVariant::String); QCOMPARE(result.toString(), QLatin1String("P")); - QVERIFY(para.functions().contains("hasAttributes")); - result = para.evaluateScript("this.hasAttributes()"); + result = para.evaluateJavaScript("this.hasAttributes()"); QVERIFY(result.isValid()); QVERIFY(result.type() == QVariant::Bool); QVERIFY(!result.toBool()); - para.evaluateScript("this.setAttribute('align', 'left');"); + para.evaluateJavaScript("this.setAttribute('align', 'left');"); QCOMPARE(para.attribute("align"), QLatin1String("left")); - result = para.evaluateScript("this.hasAttributes()"); + result = para.evaluateJavaScript("this.hasAttributes()"); QVERIFY(result.isValid()); QVERIFY(result.type() == QVariant::Bool); QVERIFY(result.toBool()); } -void tst_QWebElement::callFunction() -{ - m_mainFrame->setHtml("

test"); - QWebElement body = m_mainFrame->documentElement(); - QVERIFY(body.functions().contains("hasChildNodes")); - QVariant result = body.callFunction("hasChildNodes"); - QVERIFY(result.isValid()); - QVERIFY(result.type() == QVariant::Bool); - QVERIFY(result.toBool()); - - body.callFunction("setAttribute", QVariantList() << "foo" << "bar"); - QCOMPARE(body.attribute("foo"), QString("bar")); -} - -void tst_QWebElement::callFunctionSubmitForm() -{ - m_mainFrame->setHtml(QString("

" - "
"), QUrl()); - - QWebElement form = m_mainFrame->documentElement().findAll("form").at(0); - QVERIFY(form.functions().contains("submit")); - QVERIFY(!form.isNull()); - form.callFunction("submit"); - - waitForSignal(m_page, SIGNAL(loadFinished(bool))); - QCOMPARE(m_mainFrame->url().toString(), QString("data:text/html,foo?")); -} - -void tst_QWebElement::functionNames() -{ - m_mainFrame->setHtml("

Test"); - - QWebElement body = m_mainFrame->documentElement(); - - QVERIFY(body.functions().contains("setAttribute")); -} - void tst_QWebElement::documentElement() { m_mainFrame->setHtml("

Test"); @@ -398,27 +357,27 @@ void tst_QWebElement::style() m_mainFrame->setHtml(html); QWebElement p = m_mainFrame->documentElement().findAll("p").at(0); - QCOMPARE(p.styleProperty("color"), QLatin1String("blue")); - QVERIFY(p.styleProperty("cursor").isEmpty()); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); + QVERIFY(p.styleProperty("cursor", QWebElement::InlineStyle).isEmpty()); p.setStyleProperty("color", "red"); p.setStyleProperty("cursor", "auto"); - QCOMPARE(p.styleProperty("color"), QLatin1String("red")); - QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("yellow")); - QCOMPARE(p.styleProperty("cursor"), QLatin1String("auto")); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("yellow")); + QCOMPARE(p.styleProperty("cursor", QWebElement::InlineStyle), QLatin1String("auto")); p.setStyleProperty("color", "green !important"); - QCOMPARE(p.styleProperty("color"), QLatin1String("green")); - QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green")); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green")); p.setStyleProperty("color", "blue"); - QCOMPARE(p.styleProperty("color"), QLatin1String("green")); - QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green")); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green")); - p.setStyleProperty("color", "blue", QWebElement::ImportantStylePriority); - QCOMPARE(p.styleProperty("color"), QLatin1String("blue")); - QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue")); + p.setStyleProperty("color", "blue !important"); + QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue")); + QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue")); QString html2 = "" "