diff options
Diffstat (limited to 'src/3rdparty/phonon')
47 files changed, 6089 insertions, 9 deletions
diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp index 13f9734..5dcbd42 100644 --- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp +++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp @@ -369,6 +369,11 @@ bool MediaObject::createPipefromURL(const QUrl &url) if (!m_datasource) return false; + // Set the device for MediaSource::Disc + QByteArray mediaDevice = QFile::encodeName(m_source.deviceName()); + if (!mediaDevice.isEmpty()) + g_object_set (m_datasource, "device", mediaDevice.constData(), (const char*)NULL); + // Link data source into pipeline gst_bin_add(GST_BIN(m_pipeline), m_datasource); if (!gst_element_link(m_datasource, m_decodebin)) { @@ -904,8 +909,21 @@ void MediaObject::setSource(const MediaSource &source) case MediaSource::Disc: // CD tracks can be specified by setting the url in the following way uri=cdda:4 { - QUrl cdurl(QLatin1String("cdda://")); - if (createPipefromURL(cdurl)) + QUrl url; + switch (source.discType()) { + case Phonon::Cd: + url = QUrl(QLatin1String("cdda://")); + break; + case Phonon::Dvd: + url = QUrl(QLatin1String("dvd://")); + break; + case Phonon::Vcd: + url = QUrl(QLatin1String("vcd://")); + break; + default: + break; + } + if (!url.isEmpty() && createPipefromURL(url)) m_loading = true; else setError(tr("Could not open media source.")); diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt new file mode 100644 index 0000000..a2b1865 --- /dev/null +++ b/src/3rdparty/phonon/mmf/TODO.txt @@ -0,0 +1,29 @@ +TODO list for MMF Phonon backend +-------------------------------- + +The following items are in rough order of priority. + +* 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 + 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 +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 + +* 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). + +* 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..a793390 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -0,0 +1,78 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "mediaobject.h" + +#include "abstractaudioeffect.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::AbstractAudioEffect + \internal +*/ + +AbstractAudioEffect::AbstractAudioEffect(QObject *parent, + const QList<EffectParameter> ¶ms) : MediaNode::MediaNode(parent) + , m_params(params) +{ +} + +bool AbstractAudioEffect::disconnectMediaNode(MediaNode *target) +{ + MediaNode::disconnectMediaNode(target); + m_effect.reset(); + return true; +} + +QList<EffectParameter> 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; +} + +bool AbstractAudioEffect::activateOnMediaObject(MediaObject *mo) +{ + AudioPlayer *const ap = qobject_cast<AudioPlayer *>(mo->abstractPlayer()); + + if (ap) + return activateOn(ap->player()); + else + return true; +} + +void AbstractAudioEffect::setParameterValue(const EffectParameter ¶m, + const QVariant &newValue) +{ + 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 new file mode 100644 index 0000000..01542c9 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_ABSTRACTEFFECT_H +#define PHONON_MMF_ABSTRACTEFFECT_H + +#include "mmf_medianode.h" + +#include <QScopedPointer> + +#include <AudioEffectBase.h> + +#include <Phonon/EffectInterface> +#include <Phonon/EffectParameter> +#include "audioplayer.h" + +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<EffectParameter> ¶ms); + + virtual QList<EffectParameter> parameters() const; + virtual QVariant parameterValue(const EffectParameter ¶m) const; + virtual void setParameterValue(const EffectParameter &, + const QVariant &newValue); + + virtual bool disconnectMediaNode(MediaNode *target); + + enum Type + { + EffectAudioEqualizer = 1, + EffectBassBoost, + EffectDistanceAttenuation, + EffectEnvironmentalReverb, + EffectListenerOrientation, + EffectLoudness, + EffectSourceOrientation, + EffectStereoWidening + }; + +protected: + virtual bool activateOn(CPlayerType *player) = 0; + virtual void parameterChanged(const int id, + const QVariant &value) = 0; + + /** + * Part of the implementation of AbstractAudioEffect. Forwards the call to + * activateOn(), essentially. + */ + virtual bool activateOnMediaObject(MediaObject *mo); + + QScopedPointer<CAudioEffect> m_effect; +private: + const QList<EffectParameter> m_params; + QHash<int, QVariant> m_values; +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp new file mode 100644 index 0000000..2fdb092 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -0,0 +1,408 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <QUrl> + +#include "abstractmediaplayer.h" +#include "defs.h" +#include "utils.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::AbstractMediaPlayer + \internal +*/ + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const int NullMaxVolume = -1; + + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AbstractMediaPlayer::AbstractMediaPlayer() : + m_playPending(false) + , m_tickTimer(new QTimer(this)) + , m_mmfMaxVolume(NullMaxVolume) +{ + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); +} + +MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) : + AbstractPlayer(player) + , m_playPending(false) + , m_tickTimer(new QTimer(this)) + , m_mmfMaxVolume(NullMaxVolume) +{ + connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick())); +} + +//----------------------------------------------------------------------------- +// MediaObjectInterface +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::play() +{ + TRACE_CONTEXT(AbstractMediaPlayer::play, EAudioApi); + TRACE_ENTRY("state %d", privateState()); + + switch (privateState()) { + case GroundState: + setError(NormalError); + 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); + } + + TRACE_EXIT("state %d", privateState()); +} + +void MMF::AbstractMediaPlayer::pause() +{ + TRACE_CONTEXT(AbstractMediaPlayer::pause, EAudioApi); + TRACE_ENTRY("state %d", privateState()); + + m_playPending = false; + + switch (privateState()) { + case GroundState: + case LoadingState: + case PausedState: + case ErrorState: + // Do nothing + break; + + case StoppedState: + 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", privateState()); +} + +void MMF::AbstractMediaPlayer::stop() +{ + TRACE_CONTEXT(AbstractMediaPlayer::stop, EAudioApi); + TRACE_ENTRY("state %d", privateState()); + + m_playPending = false; + + switch (privateState()) { + 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", privateState()); +} + +void MMF::AbstractMediaPlayer::seek(qint64 ms) +{ + TRACE_CONTEXT(AbstractMediaPlayer::seek, EAudioApi); + TRACE_ENTRY("state %d pos %Ld", state(), ms); + + switch (privateState()) { + // Fallthrough all these + case GroundState: + case StoppedState: + case PausedState: + case PlayingState: + case LoadingState: + { + const bool tickTimerWasRunning = m_tickTimer->isActive(); + stopTickTimer(); + + doSeek(ms); + + if (tickTimerWasRunning) { + startTickTimer(); + } + break; + } + case BufferingState: + // Fallthrough + case ErrorState: + // Do nothing + break; + } + + TRACE_EXIT_0(); +} + +bool MMF::AbstractMediaPlayer::isSeekable() const +{ + return true; +} + +void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) +{ + TRACE_CONTEXT(AbstractMediaPlayer::doSetTickInterval, EAudioApi); + TRACE_ENTRY("state %d m_interval %d interval %d", privateState(), tickInterval(), interval); + + m_tickTimer->setInterval(interval); + + TRACE_EXIT_0(); +} + +MediaSource MMF::AbstractMediaPlayer::source() const +{ + return m_source; +} + +void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& file) +{ + TRACE_CONTEXT(AbstractMediaPlayer::setFileSource, EAudioApi); + TRACE_ENTRY("state %d source.type %d", privateState(), 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: { + symbianErr = openFile(file); + break; + } + + case MediaSource::Url: { + const QUrl url(source.url()); + + if (url.scheme() == QLatin1String("file")) { + symbianErr = openFile(file); + } + else { + TRACE_0("Source type not supported"); + // TODO: support network URLs + 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; + + // Protection against adding new media types and forgetting to update this switch + default: + TRACE_PANIC(InvalidMediaTypePanic); + } + + if (KErrNone == symbianErr) { + changeState(LoadingState); + } else { + TRACE("error %d", symbianErr) + setError(NormalError); + } + + TRACE_EXIT_0(); +} + +void MMF::AbstractMediaPlayer::setNextSource(const MediaSource &source) +{ + TRACE_CONTEXT(AbstractMediaPlayer::setNextSource, EAudioApi); + TRACE_ENTRY("state %d", privateState()); + + // TODO: handle 'next source' + + m_nextSource = source; + Q_UNUSED(source); + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- +// VolumeObserver +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) +{ + TRACE_CONTEXT(AbstractMediaPlayer::volumeChanged, EAudioInternal); + TRACE_ENTRY("state %d", privateState()); + + AbstractPlayer::volumeChanged(volume); + doVolumeChanged(); + + TRACE_EXIT_0(); +} + + +void MMF::AbstractMediaPlayer::doVolumeChanged() +{ + switch (privateState()) { + 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) { + setError(NormalError); + } + break; + } + + // Protection against adding new states and forgetting to update this + // switch + default: + Utils::panic(InvalidStatePanic); + } +} + + +//----------------------------------------------------------------------------- +// Protected functions +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::startTickTimer() +{ + m_tickTimer->start(tickInterval()); +} + +void MMF::AbstractMediaPlayer::stopTickTimer() +{ + m_tickTimer->stop(); +} + +void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) +{ + m_mmfMaxVolume = mmfMaxVolume; + doVolumeChanged(); +} + +qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in) +{ + return in.Int64() / 1000; +} + +void MMF::AbstractMediaPlayer::changeState(PrivateState newState) +{ + TRACE_CONTEXT(AbstractPlayer::changeState, EAudioInternal); + TRACE_ENTRY("state %d newState %d", privateState(), newState); + + // TODO: add some invariants to check that the transition is valid + + const Phonon::State oldPhononState = phononState(privateState()); + const Phonon::State newPhononState = phononState(newState); + if (oldPhononState != newPhononState) { + TRACE("emit stateChanged(%d, %d)", newPhononState, oldPhononState); + emit stateChanged(newPhononState, oldPhononState); + } + + setState(newState); + + if ( + LoadingState == oldPhononState + and StoppedState == newPhononState + ) { + // Ensure initial volume is set on MMF API before starting playback + doVolumeChanged(); + + // Check whether play() was called while clip was being loaded. If so, + // playback should be started now + if (m_playPending) { + TRACE_0("play was called while loading; starting playback now"); + m_playPending = false; + play(); + } + } + + TRACE_EXIT_0(); +} + +//----------------------------------------------------------------------------- +// Slots +//----------------------------------------------------------------------------- + +void MMF::AbstractMediaPlayer::tick() +{ + // 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 new file mode 100644 index 0000000..698b899 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -0,0 +1,119 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_ABSTRACTMEDIAPLAYER_H +#define PHONON_MMF_ABSTRACTMEDIAPLAYER_H + +#include <QTimer> +#include <QScopedPointer> +#include <e32std.h> +#include "abstractplayer.h" + +class RFile; + +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); + +public: + // MediaObjectInterface + virtual void play(); + virtual void pause(); + virtual void stop(); + virtual void seek(qint64 milliseconds); + virtual bool isSeekable() 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); + + 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; + + /** + * Changes state and emits stateChanged() + */ + virtual void changeState(PrivateState newState); + +protected: + bool tickTimerRunning() const; + void startTickTimer(); + void stopTickTimer(); + void maxVolumeChanged(int maxVolume); + + static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + +private: + void doVolumeChanged(); + +private Q_SLOTS: + /** + * Receives signal from m_tickTimer + */ + void tick(); + +private: + /** + * 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<QTimer> m_tickTimer; + + int m_mmfMaxVolume; + + MediaSource m_source; + MediaSource m_nextSource; + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp new file mode 100644 index 0000000..e3c0ecb --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -0,0 +1,177 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "abstractplayer.h" +#include "defs.h" +#include "utils.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::AbstractPlayer + \internal +*/ + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AbstractPlayer::AbstractPlayer() + : m_videoOutput(0) + , m_volume(InitialVolume) + , m_state(GroundState) + , m_error(NoError) + , m_tickInterval(DefaultTickInterval) + , m_transitionTime(0) + , m_prefinishMark(0) +{ + +} + +MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) + : m_videoOutput(player.m_videoOutput) + , m_volume(player.m_volume) + , m_state(GroundState) + , m_error(NoError) + , m_tickInterval(player.tickInterval()) + , 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; +} + + +//----------------------------------------------------------------------------- +// VolumeObserver +//----------------------------------------------------------------------------- + +void MMF::AbstractPlayer::volumeChanged(qreal volume) +{ + m_volume = volume; +} + + +//----------------------------------------------------------------------------- +// Video output +//----------------------------------------------------------------------------- + +void MMF::AbstractPlayer::setVideoOutput(VideoOutput* videoOutput) +{ + m_videoOutput = videoOutput; + videoOutputChanged(); +} + +void MMF::AbstractPlayer::videoOutputChanged() +{ + // Default behaviour is empty - overridden by VideoPlayer +} + +void MMF::AbstractPlayer::setError(Phonon::ErrorType error) +{ + TRACE_CONTEXT(AbstractPlayer::setError, EAudioInternal); + TRACE_ENTRY("state %d error %d", m_state, error); + + m_error = error; + changeState(ErrorState); + + TRACE_EXIT_0(); +} + +Phonon::ErrorType MMF::AbstractPlayer::errorType() const +{ + const Phonon::ErrorType result = (ErrorState == m_state) + ? errorType() : NoError; + return result; +} + +QString MMF::AbstractPlayer::errorString() const +{ + // TODO: put in proper error strings + QString result; + return result; +} + +Phonon::State MMF::AbstractPlayer::phononState() const +{ + return phononState(m_state); +} + +Phonon::State MMF::AbstractPlayer::phononState(PrivateState state) +{ + const Phonon::State phononState = + GroundState == state + ? Phonon::LoadingState + : static_cast<Phonon::State>(state); + + return phononState; +} + +AbstractPlayer::PrivateState AbstractPlayer::privateState() const +{ + return m_state; +} + +Phonon::State MMF::AbstractPlayer::state() const +{ + return phononState(m_state); +} + +void MMF::AbstractPlayer::setState(PrivateState newState) +{ + m_state = newState; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h new file mode 100644 index 0000000..ec39ab1 --- /dev/null +++ b/src/3rdparty/phonon/mmf/abstractplayer.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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_ABSTRACTPLAYER_H +#define PHONON_MMF_ABSTRACTPLAYER_H + +#include <Phonon/phononnamespace.h> +#include <Phonon/MediaSource.h> + +#include <QObject> + +#include "volumeobserver.h" + +#include "videooutput.h" + +class RFile; + +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::ErrorType errorType() const; + virtual QString errorString() const; + 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; + + // VolumeObserver + virtual void volumeChanged(qreal volume); + + void setVideoOutput(VideoOutput* videoOutput); + + /** + * Records error and changes state to ErrorState + */ + void setError(Phonon::ErrorType error); + + Phonon::State state() const; +Q_SIGNALS: + void totalTimeChanged(qint64 length); + void finished(); + void tick(qint64 time); + void stateChanged(Phonon::State oldState, + Phonon::State newState); + + +protected: + /** + * 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); + + virtual void videoOutputChanged(); + + PrivateState privateState() const; + + virtual void changeState(PrivateState newState) = 0; + + /** + * Modifies m_state directly. Typically you want to call changeState(), + * which performs the business logic. + */ + void setState(PrivateState newState); + +private: + virtual void doSetTickInterval(qint32 interval) = 0; + +protected: + // Not owned + VideoOutput* m_videoOutput; + + qreal m_volume; + +private: + PrivateState m_state; + Phonon::ErrorType m_error; + qint32 m_tickInterval; + qint32 m_transitionTime; + qint32 m_prefinishMark; + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp new file mode 100644 index 0000000..c691e1e --- /dev/null +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -0,0 +1,89 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "audioequalizer.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::AudioEqualizer + \internal +*/ + +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())); +} + +bool AudioEqualizer::activateOn(CPlayerType *player) +{ + m_effect.reset(CAudioEqualizer::NewL(*player)); + return true; +} + +CAudioEqualizer *AudioEqualizer::eq() const +{ + return static_cast<CAudioEqualizer *>(m_effect.data()); +} + +QList<EffectParameter> AudioEqualizer::createParams() +{ + QList<EffectParameter> 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..6415411 --- /dev/null +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -0,0 +1,62 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_AUDIOEQUALIZER_H +#define PHONON_MMF_AUDIOEQUALIZER_H + +#include <AudioEqualizerBase.h> +#include "abstractaudioeffect.h" + +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 bool activateOn(CPlayerType *player); + +private: + inline CAudioEqualizer *eq() const; + QList<EffectParameter> createParams(); + QScopedPointer<CAudioEqualizer> m_bassBoost; +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp new file mode 100644 index 0000000..58e2f5e --- /dev/null +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -0,0 +1,104 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <e32debug.h> + +#include "audiooutput.h" +#include "defs.h" +#include "mediaobject.h" +#include "utils.h" +#include "volumeobserver.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::AudioOutput + \internal +*/ + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : MediaNode(parent) + , m_volume(InitialVolume) + , m_observer(0) +{ + +} + + +//----------------------------------------------------------------------------- +// Public API +//----------------------------------------------------------------------------- + +qreal MMF::AudioOutput::volume() const +{ + return m_volume; +} + +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); + } + + TRACE_EXIT_0(); +} + +int MMF::AudioOutput::outputDevice() const +{ + return 0; +} + +bool MMF::AudioOutput::setOutputDevice(int) +{ + return true; +} + +bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) +{ + return true; +} + +void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer) +{ + m_observer = observer; + if (m_observer) { + m_observer->volumeChanged(m_volume); + } +} + +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 new file mode 100644 index 0000000..0a962a9 --- /dev/null +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -0,0 +1,93 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_AUDIOOUTPUT_H +#define PHONON_MMF_AUDIOOUTPUT_H + +#include "mmf_medianode.h" +#include <phonon/audiooutputinterface.h> + +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<frans.englich@nokia.com> + */ +class AudioOutput : public MediaNode + , 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 &); + +protected: + virtual bool activateOnMediaObject(MediaObject *mo); + +Q_SIGNALS: + void volumeChanged(qreal volume); + void audioDeviceFailed(); + +private: + void setVolumeObserver(VolumeObserver* observer); + + qreal m_volume; + + // Not owned + VolumeObserver* m_observer; +}; +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp new file mode 100644 index 0000000..aa2a94b --- /dev/null +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -0,0 +1,258 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <QUrl> + +#include "audioplayer.h" +#include "utils.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::AudioPlayer + \internal +*/ + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::AudioPlayer::AudioPlayer() : m_player(0) +{ + construct(); +} + +MMF::AudioPlayer::AudioPlayer(const AbstractPlayer& player) + : AbstractMediaPlayer(player) + , m_player(0) +{ + construct(); +} + +void MMF::AudioPlayer::construct() +{ + TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); + TRACE_ENTRY_0(); + + TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); + if (KErrNone != err) { + changeState(ErrorState); + } + + TRACE_EXIT_0(); +} + +MMF::AudioPlayer::~AudioPlayer() +{ + TRACE_CONTEXT(AudioPlayer::~AudioPlayer, EAudioApi); + TRACE_ENTRY_0(); + + delete m_player; + + TRACE_EXIT_0(); +} + +//----------------------------------------------------------------------------- +// Public API +//----------------------------------------------------------------------------- + +void MMF::AudioPlayer::doPlay() +{ + m_player->Play(); +} + +void MMF::AudioPlayer::doPause() +{ + m_player->Pause(); +} + +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) +{ + /* 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__) + 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 +} + +int MMF::AudioPlayer::openFile(RFile& file) +{ + 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; +} + +void MMF::AudioPlayer::close() +{ + m_player->Close(); +} + +bool MMF::AudioPlayer::hasVideo() const +{ + return false; +} + +qint64 MMF::AudioPlayer::currentTime() const +{ + TRACE_CONTEXT(AudioPlayer::currentTime, EAudioApi); + + TTimeIntervalMicroSeconds us; + const TInt err = m_player->GetPosition(us); + + qint64 result = 0; + + 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<AudioPlayer*>(this)->setError(NormalError); + } + + return result; +} + +qint64 MMF::AudioPlayer::totalTime() const +{ + return toMilliSeconds(m_player->Duration()); +} + + +//----------------------------------------------------------------------------- +// 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", state(), aError); + + __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); + + if (KErrNone == aError) { + maxVolumeChanged(m_player->MaxVolume()); + + emit totalTimeChanged(totalTime()); + changeState(StoppedState); + } else { + // TODO: set different error states according to value of aError? + setError(NormalError); + } + + 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", state(), aError); + + stopTickTimer(); + + if (KErrNone == aError) { + changeState(StoppedState); + // TODO: move on to m_nextSource + } 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(); + } + + changeState(StoppedState); + } + else { + m_error = NormalError; + changeState(ErrorState); + } + */ + + TRACE_EXIT_0(); +} + +CPlayerType *MMF::AudioPlayer::player() const +{ + return m_player; +} + + +#ifdef QT_PHONON_MMF_AUDIO_DRM +void MMF::AudioPlayer::MaloLoadingStarted() +{ + +} + +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 new file mode 100644 index 0000000..f16de1d --- /dev/null +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -0,0 +1,106 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_AUDIOPLAYER_H +#define PHONON_MMF_AUDIOPLAYER_H + +#include "abstractmediaplayer.h" + +class CDrmPlayerUtility; +class TTimeIntervalMicroSeconds; + +#ifdef QT_PHONON_MMF_AUDIO_DRM +#include <drmaudiosampleplayer.h> +typedef CDrmPlayerUtility CPlayerType; +typedef MDrmAudioPlayerCallback MPlayerObserverType; +#else +#include <mdaaudiosampleplayer.h> +typedef CMdaAudioPlayerUtility CPlayerType; +typedef MMdaAudioPlayerCallback MPlayerObserverType; +#endif + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short Wrapper over MMF audio client utility + */ +class AudioPlayer : public AbstractMediaPlayer + , public MPlayerObserverType // typedef +#ifdef QT_PHONON_MMF_AUDIO_DRM + , 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; + +#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 + + CPlayerType *player() const; + +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 + +#endif diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp new file mode 100644 index 0000000..be43f46 --- /dev/null +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -0,0 +1,202 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <QStringList> +#include <QtPlugin> + +#include <apgcli.h> // for RApaLsSession +#include <apmrec.h> // for CDataTypeArray +#include <apmstd.h> // for TDataType + +#include "abstractaudioeffect.h" +#include "audiooutput.h" +#include "audioplayer.h" +#include "backend.h" +#include "effectfactory.h" +#include "mediaobject.h" +#include "utils.h" +#include "videowidget.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::VolumeObserver + \internal +*/ + +/*! \class MMF::Backend + \internal +*/ + +Backend::Backend(QObject *parent) : QObject(parent) +{ + 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://qt.nokia.com/")); + + TRACE_EXIT_0(); +} + +QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args) +{ + TRACE_CONTEXT(Backend::createObject, EBackend); + TRACE_ENTRY("class %d", c); + + QObject* result = 0; + + 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: + { + 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<QWidget *>(parent)); + break; + + default: + TRACE_PANIC(InvalidBackendInterfaceClass); + } + + TRACE_RETURN("0x%08x", result); +} + +QList<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const +{ + TRACE_CONTEXT(Backend::objectDescriptionIndexes, EAudioApi); + TRACE_ENTRY_0(); + QList<int> retval; + + switch(type) + { + case EffectType: + retval.append(EffectFactory::effectIndexes()); + default: + ; + } + + TRACE_EXIT_0(); + return retval; +} + +QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const +{ + TRACE_CONTEXT(Backend::connectNodes, EBackend); + + if (type == EffectType) + return EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type(index)); + else + return QHash<QByteArray, QVariant>(); +} + +bool Backend::startConnectionChange(QSet<QObject *>) +{ + return true; +} + +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<MediaNode *>(source)); + Q_ASSERT(qobject_cast<MediaNode *>(target)); + + MediaNode *const mediaSource = static_cast<MediaNode *>(source); + MediaNode *const mediaTarget = static_cast<MediaNode *>(target); + + return mediaSource->connectMediaNode(mediaTarget); +} + +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<MediaNode *>(source)); + Q_ASSERT(qobject_cast<MediaNode *>(target)); + + const bool result = static_cast<MediaNode *>(source)->disconnectMediaNode(static_cast<MediaNode *>(target)); + + TRACE_RETURN("%d", result); +} + +bool Backend::endConnectionChange(QSet<QObject *>) +{ + 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; 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; +} + +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 new file mode 100644 index 0000000..1886ae6 --- /dev/null +++ b/src/3rdparty/phonon/mmf/backend.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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_BACKEND_H +#define PHONON_MMF_BACKEND_H + +#include <Phonon/MediaSource> +#include <Phonon/BackendInterface> + +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<QVariant> &args); + virtual QList<int> objectDescriptionIndexes(ObjectDescriptionType type) const; + virtual QHash<QByteArray, QVariant> objectDescriptionProperties(ObjectDescriptionType type, int index) const; + virtual bool startConnectionChange(QSet<QObject *>); + virtual bool connectNodes(QObject *, QObject *); + virtual bool disconnectNodes(QObject *, QObject *); + virtual bool endConnectionChange(QSet<QObject *>); + virtual QStringList availableMimeTypes() const; + +Q_SIGNALS: + void objectDescriptionChanged(ObjectDescriptionType); +}; +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp new file mode 100644 index 0000000..e34f9e7 --- /dev/null +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -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 <http://www.gnu.org/licenses/>. + +*/ + +#include "bassboost.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::BassBoost + \internal +*/ + +BassBoost::BassBoost(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, + QList<EffectParameter>()) +{ +} + +void BassBoost::parameterChanged(const int, + const QVariant &) +{ + // We should never be called, because we have no parameters. +} + +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 new file mode 100644 index 0000000..c16393a --- /dev/null +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -0,0 +1,58 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_BASSBOOST_H +#define PHONON_MMF_BASSBOOST_H + +#include <BassBoostBase.h> +#include "abstractaudioeffect.h" + +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 bool activateOn(CPlayerType *player); + +private: + QScopedPointer<CBassBoost> m_bassBoost; +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h new file mode 100644 index 0000000..1a93aa9 --- /dev/null +++ b/src/3rdparty/phonon/mmf/defs.h @@ -0,0 +1,43 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_DEFS_H +#define PHONON_MMF_DEFS_H + +#include <QtGlobal> + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +static const qint32 DefaultTickInterval = 10; +static const qreal InitialVolume = 0.5; + +enum MediaType { + MediaTypeUnknown, + MediaTypeAudio, + MediaTypeVideo +}; +} +} + +QT_END_NAMESPACE + +#endif // PHONON_MMF_DEFS_H diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp new file mode 100644 index 0000000..bd21d20 --- /dev/null +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -0,0 +1,135 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "dummyplayer.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::DummyPlayer + \internal +*/ + +//----------------------------------------------------------------------------- +// 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 &) +{ + +} + + +//----------------------------------------------------------------------------- +// AbstractPlayer +//----------------------------------------------------------------------------- + +void MMF::DummyPlayer::doSetTickInterval(qint32) +{ + +} + +void MMF::DummyPlayer::changeState(PrivateState) +{ +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h new file mode 100644 index 0000000..9ff9f78 --- /dev/null +++ b/src/3rdparty/phonon/mmf/dummyplayer.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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_DUMMYPLAYER_H +#define PHONON_MMF_DUMMYPLAYER_H + +#include "abstractplayer.h" + +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); + + // AbstractPlayer + virtual void doSetTickInterval(qint32 interval); + +protected: + virtual void changeState(PrivateState newState); +}; +} +} + +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..214baa0 --- /dev/null +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -0,0 +1,155 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <QObject> +#include <QCoreApplication> + +#include <AudioEqualizerBase.h> +#include <BassBoostBase.h> +#include <DistanceAttenuationBase.h> +#include <DopplerBase.h> +#include <EnvironmentalReverbBase.h> +#include <ListenerOrientationBase.h> +#include <LocationBase.h> +#include <LoudnessBase.h> +#include <SourceOrientationBase.h> +#include <StereoWideningBase.h> + +#include "audioequalizer.h" +#include "bassboost.h" + +#include "effectfactory.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::EffectFactory + \internal +*/ + +QHash<QByteArray, QVariant> EffectFactory::constructEffectDescription(const QString &name, + const QString &description) +{ + QHash<QByteArray, QVariant> retval; + + retval.insert("name", name); + retval.insert("description", description); + retval.insert("available", true); + + return retval; +} + + +QHash<QByteArray, QVariant> EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type type) +{ + switch (type) + { + case AbstractAudioEffect::EffectAudioEqualizer: + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "audio equalizer"), "Audio equalizer."); + case AbstractAudioEffect::EffectBassBoost: + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Bass boost"), "Bass boost."); + case AbstractAudioEffect::EffectDistanceAttenuation: + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Distance Attenuation"), "Distance Attenuation."); + case AbstractAudioEffect::EffectEnvironmentalReverb: + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Environmental Reverb"), "Environmental Reverb."); + case AbstractAudioEffect::EffectListenerOrientation: + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Environmental Reverb"), "Environmental Reverb."); + case AbstractAudioEffect::EffectLoudness: + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Loudness"), "Loudness."); + case AbstractAudioEffect::EffectSourceOrientation: + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Source Orientation"), "Source Orientation."); + case AbstractAudioEffect::EffectStereoWidening: + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Stereo Widening"), "Stereo Widening."); + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect type."); + return QHash<QByteArray, QVariant>(); +} + +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: + case AbstractAudioEffect::EffectSourceOrientation: + case AbstractAudioEffect::EffectStereoWidening: + ; + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect."); + return 0; +} + +template<typename TEffect> +bool isEffectSupported() +{ + AudioPlayer audioPlayer; + + QScopedPointer<TEffect> eff; + TRAPD(errorCode, eff.reset(TEffect::NewL(*audioPlayer.player()))); + + return errorCode != KErrNone; +} + +QList<int> EffectFactory::effectIndexes() +{ + QList<int> retval; + + if (isEffectSupported<CAudioEqualizer>()) + retval.append(AbstractAudioEffect::EffectAudioEqualizer); + + if (isEffectSupported<CBassBoost>()) + retval.append(AbstractAudioEffect::EffectBassBoost); + + /* We haven't implemented these yet. + if (isEffectSupported<CDistanceAttenuation>()) + retval.append(AbstractAudioEffect::EffectDistanceAttenuation); + + if (isEffectSupported<CEnvironmentalReverb>()) + retval.append(AbstractAudioEffect::EffectEnvironmentalReverb); + + if (isEffectSupported<CLoudness>()) + retval.append(AbstractAudioEffect::EffectLoudness); + + if (isEffectSupported<CListenerOrientation>()) + retval.append(AbstractAudioEffect::EffectListenerOrientation); + + if (isEffectSupported<CSourceOrientation>()) + retval.append(AbstractAudioEffect::EffectSourceOrientation); + + if (isEffectSupported<CStereoWidening>()) + 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..e83ad15 --- /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 <http://www.gnu.org/licenses/>. + +*/ + +#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<QByteArray, QVariant> audioEffectDescriptions(AbstractAudioEffect::Type type); + + /** + * @short Returns the indexes for the supported effects. + * + * This handles the effects for + * BackendInterface::objectDescriptionIndexes(). + */ + static QList<int> effectIndexes(); + +private: + static inline QHash<QByteArray, QVariant> 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 new file mode 100644 index 0000000..76db5cb --- /dev/null +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -0,0 +1,389 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "audiooutput.h" +#include "audioplayer.h" +#include "defs.h" +#include "dummyplayer.h" +#include "utils.h" +#include "utils.h" +#include "mmf_videoplayer.h" +#include "videowidget.h" + +#include "mediaobject.h" + +#include <QDir> +#include <QUrl> + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::MediaObject + \internal +*/ + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::MediaObject::MediaObject(QObject *parent) : MMF::MediaNode::MediaNode(parent) + , m_recognizerOpened(false) +{ + m_player.reset(new DummyPlayer()); + + TRACE_CONTEXT(MediaObject::MediaObject, EAudioApi); + TRACE_ENTRY_0(); + + Q_UNUSED(parent); + + TRACE_EXIT_0(); +} + +MMF::MediaObject::~MediaObject() +{ + TRACE_CONTEXT(MediaObject::~MediaObject, EAudioApi); + TRACE_ENTRY_0(); + + m_file.Close(); + m_fileServer.Close(); + m_recognizer.Close(); + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- +// Recognizer +//----------------------------------------------------------------------------- + +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; +} + +MMF::MediaType MMF::MediaObject::fileMediaType +(const QString& fileName) +{ + TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal); + + MediaType result = MediaTypeUnknown; + + if (openRecognizer()) { + + const QHBufC fileNameSymbian(QDir::toNativeSeparators(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; +} + + +//----------------------------------------------------------------------------- +// MediaObjectInterface +//----------------------------------------------------------------------------- + +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) +{ + m_player->seek(ms); + + if (state() == PausedState or state() == PlayingState) { + emit tick(currentTime()); + } +} + +qint32 MMF::MediaObject::tickInterval() const +{ + return m_player->tickInterval(); +} + +void MMF::MediaObject::setTickInterval(qint32 interval) +{ + m_player->setTickInterval(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) +{ + 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_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(); + + Phonon::ErrorType error = NoError; + + // Determine media type + switch (source.type()) { + case MediaSource::LocalFile: + mediaType = fileMediaType(source.fileName()); + break; + + case MediaSource::Url: + { + const QUrl url(source.url()); + if (url.scheme() == QLatin1String("file")) { + mediaType = fileMediaType(url.toLocalFile()); + } + else { + TRACE_0("Network streaming not supported yet"); + error = NormalError; + } + } + break; + + case MediaSource::Invalid: + case MediaSource::Disc: + case MediaSource::Stream: + TRACE_0("Unsupported media type"); + error = NormalError; + break; + + case MediaSource::Empty: + TRACE_0("Empty media source"); + break; + } + + AbstractPlayer* newPlayer = 0; + + // Construct newPlayer using oldPlayer (if not 0) 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(); + } + + newPlayer->setError(NormalError); + 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))); + + if (error != NoError ) { + newPlayer = new DummyPlayer(); + newPlayer->setError(error); + } + + TRACE_EXIT_0(); +} + +void MMF::MediaObject::setNextSource(const MediaSource &source) +{ + 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); +} + + +//----------------------------------------------------------------------------- +// VolumeObserver +//----------------------------------------------------------------------------- + +void MMF::MediaObject::volumeChanged(qreal volume) +{ + m_player->volumeChanged(volume); +} + +//----------------------------------------------------------------------------- +// Video output +//----------------------------------------------------------------------------- + +void MMF::MediaObject::setVideoOutput(VideoOutput* videoOutput) +{ + m_player->setVideoOutput(videoOutput); +} + + +AbstractPlayer *MMF::MediaObject::abstractPlayer() const +{ + return m_player.data(); +} + +bool MMF::MediaObject::activateOnMediaObject(MediaObject *) +{ + // 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 new file mode 100644 index 0000000..409918d --- /dev/null +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -0,0 +1,140 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_MEDIAOBJECT_H +#define PHONON_MMF_MEDIAOBJECT_H + +#include <Phonon/MediaSource> +#include <Phonon/MediaObjectInterface> +#include <QScopedPointer> +#include <QTimer> + +// For recognizer +#include <apgcli.h> + +#include "abstractplayer.h" +#include "mmf_medianode.h" +#include "defs.h" +#include "volumeobserver.h" + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +class AbstractPlayer; +class VideoOutput; + +/** + * @short Facade class which wraps MMF client utility instance + */ +class MediaObject : public MediaNode + , 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); + + /** + * 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); + 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<QString, QString>& 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<AbstractPlayer> m_player; + +}; +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/mmf_medianode.cpp b/src/3rdparty/phonon/mmf/mmf_medianode.cpp new file mode 100644 index 0000000..b5ea91a --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmf_medianode.cpp @@ -0,0 +1,121 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "mediaobject.h" + +#include "mmf_medianode.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::MediaNode + \internal +*/ + +MMF::MediaNode::MediaNode(QObject *parent) : QObject::QObject(parent) + , m_source(0) + , m_target(0) + , m_isApplied(false) +{ +} + +bool MMF::MediaNode::connectMediaNode(MediaNode *target) +{ + m_target = target; + m_target->setSource(this); + + return applyNodesOnMediaObject(target); +} + +bool MMF::MediaNode::disconnectMediaNode(MediaNode *target) +{ + Q_UNUSED(target); + m_target = 0; + m_isApplied = false; + 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; +} + +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. + MMF::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<MediaNode *> unapplied; + MMF::MediaObject *mo = 0; + + do { + if (!current->m_isApplied) + unapplied.append(current); + + if (!mo) + mo = qobject_cast<MMF::MediaObject *>(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 new file mode 100644 index 0000000..4616ff1 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmf_medianode.h @@ -0,0 +1,100 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_MEDIANODE_H +#define PHONON_MMF_MEDIANODE_H + +#include <QObject> +#include <Phonon/EffectInterface> +#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 +{ +class MediaObject; + +/** + * @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. Due to that MMF has no concept of chaining, the + * order of the nodes in the graph has no meaning. + */ +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; + +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: + /** + * 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; +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp new file mode 100644 index 0000000..83d715d --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -0,0 +1,452 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <QUrl> +#include <QTimer> +#include <QWidget> + +#include <coemain.h> // For CCoeEnv +#include <coecntrl.h> + +#include "mmf_videoplayer.h" +#include "utils.h" + +#ifdef _DEBUG +#include "objectdump.h" +#endif + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::VideoPlayer + \internal +*/ + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::VideoPlayer::VideoPlayer() + : m_wsSession(0) + , m_screenDevice(0) + , m_window(0) + , m_totalTime(0) + , m_mmfOutputChangePending(false) +{ + construct(); +} + +MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) + : AbstractMediaPlayer(player) + , m_wsSession(0) + , m_screenDevice(0) + , m_window(0) + , 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(0)); + } + + 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); + + bool wasPlaying = false; + if(state() == PlayingState) { + // The call to SetPositionL does not have any effect if playback is + // ongoing, so we pause before seeking. + doPause(); + wasPlaying = true; + } + + TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms * 1000))); + + if(KErrNone == err) { + if(wasPlaying) + doPlay(); + } + else { + 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<VideoPlayer*>(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(0)); + } + + 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<ObjectDump::QDumper> 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..a805135 --- /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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_VIDEOPLAYER_H +#define PHONON_MMF_VIDEOPLAYER_H + +#include <videoplayer.h> // from epoc32/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 + * <a href="http://wiki.forum.nokia.com/index.php/How_to_play_a_video_file_using_CVideoPlayerUtility">How to + * play a video file using CVideoPlayerUtility</a> + */ +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<CVideoPlayerUtility> m_player; + QScopedPointer<VideoOutput> 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/mmfphonondebug/objectdump.cpp b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump.cpp new file mode 100644 index 0000000..ef2b81c --- /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 <http://www.gnu.org/licenses/>. + +*/ + +#include <QByteArray> +#include <QDebug> +#include <QHash> +#include <QTextStream> +#include <QWidget> + +#include "objectdump.h" +#include "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +//----------------------------------------------------------------------------- +// QObjectAnnotator +//----------------------------------------------------------------------------- + +QAnnotator::~QAnnotator() +{ + +} + + +//----------------------------------------------------------------------------- +// Annotators +//----------------------------------------------------------------------------- + +QList<QByteArray> QAnnotatorBasic::annotation(const QObject& object) +{ + QList<QByteArray> 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<QByteArray> QAnnotatorWidget::annotation(const QObject& object) +{ + QList<QByteArray> result; + + const QWidget* widget = qobject_cast<const QWidget*>(&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<QAnnotator*> 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<QAnnotator> 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<QByteArray> 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<QByteArray> m_annotation; + QList<Node*> m_children; + + typedef QList<Node*>::const_iterator child_iterator; + }; + +private: + Node* findNode(const QObject* object) const; + QByteArray branchBuffer(const QList<bool>& branches, bool isNodeLine, bool isLastChild) const; + void dumpRecursive(const Node& node, QList<bool> branches, bool isLastChild); + void dumpNode(const Node& node, const QList<bool>& branches, bool isLastChild); + +private: + unsigned m_indent; + + QScopedPointer<Node> m_root; + + // Hash table used to associate internal nodes with QObjects + typedef QHash<const QObject*, Node*> 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) : 0; + + // Create a new node and store in scoped pointer for exception safety + Node* node = new Node; + QScopedPointer<Node> 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<bool> branches; + static const bool isLastChild = true; + dumpRecursive(*m_root, branches, isLastChild); + 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) ? 0 : *i; +} + +QByteArray QVisitorPrivate::branchBuffer + (const QList<bool>& 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<depth-1; ++i) { + if(branches[i]) + stream << '|'; + else + stream << ' '; + stream << indent; + } + + if(depth) { + if(isNodeLine) + stream << '+' << horiz; + else { + if(!isLastChild) + stream << '|'; + else + stream << ' '; + stream << indent; + } + } + + stream.flush(); + buffer.push_front(m_prefix); + + return buffer; +} + +void QVisitorPrivate::dumpRecursive + (const Node& node, QList<bool> 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<bool>& branches, bool isLastChild) +{ + const QList<QByteArray>::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() << 0; // TODO + } + else { + // Dump annotations + for(QList<QByteArray>::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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef OBJECTDUMP_H +#define OBJECTDUMP_H + +#include "objectdump_global.h" + +#include <QObject> +#include <QList> +#include <QByteArray> +#include <QScopedPointer> + +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<QByteArray> annotation(const QObject& object) = 0; +}; + +/** + * Annotator which replicates QObject::dumpObjectTree functionality. + */ +class OBJECTDUMP_EXPORT QAnnotatorBasic : public QAnnotator +{ + Q_OBJECT +public: + QList<QByteArray> annotation(const QObject& object); +}; + +/** + * Annotator which returns widget information. + */ +class OBJECTDUMP_EXPORT QAnnotatorWidget : public QAnnotator +{ + Q_OBJECT +public: + QList<QByteArray> 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<QDumperPrivate> 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<QVisitorPrivate> 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..b8987e0 --- /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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef OBJECTDUMP_GLOBAL_H +#define OBJECTDUMP_GLOBAL_H + +#include <QtCore/QtGlobal> + +#if defined(OBJECTDUMP_LIBRARY) +# define OBJECTDUMP_EXPORT +#else +# define OBJECTDUMP_EXPORT +#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 <http://www.gnu.org/licenses/>. + +*/ + +#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..f8adcd5 --- /dev/null +++ b/src/3rdparty/phonon/mmf/mmfphonondebug/objectdump_symbian.cpp @@ -0,0 +1,135 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <QTextStream> +#include <QWidget> +#include <coecntrl.h> +#include "objectdump_symbian.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ +namespace Symbian +{ + +QList<QByteArray> QAnnotatorControl::annotation(const QObject& object) +{ + QList<QByteArray> result; + + const QWidget* widget = qobject_cast<const QWidget*>(&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<QByteArray> QAnnotatorWindow::annotation(const QObject& object) +{ + QList<QByteArray> result; + + const QWidget* widget = qobject_cast<const QWidget*>(&object); + if(widget) { + + const CCoeControl* control = widget->effectiveWinId(); + if(control) { + + RDrawableWindow& window = *(control->DrawableWindow()); + + QByteArray array; + QTextStream stream(&array); + + 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<const void*>(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). + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "srv " << reinterpret_cast<const void*>(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<const void*>(window.Parent()) << ' '; + + stream << window.Position().iX << ',' << window.Position().iY << ' '; + stream << '(' << window.AbsPosition().iX << ',' << window.AbsPosition().iY << ") "; + stream << window.Size().iWidth << 'x' << window.Size().iHeight << ' '; + + const TDisplayMode displayMode = window.DisplayMode(); + stream << "mode " << displayMode; + + 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 <http://www.gnu.org/licenses/>. + +*/ + +#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<QByteArray> annotation(const QObject& object); +}; + +/** + * Annotator which returns window information + */ +class QAnnotatorWindow : public QAnnotator +{ + Q_OBJECT +public: + QList<QByteArray> 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..5053b2d --- /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 <http://www.gnu.org/licenses/>. + +*/ + +#include <QTextStream> +#include <QWidget> +#include "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectTree +{ + +DepthFirstConstIterator::DepthFirstConstIterator() + : m_pointee(0) +{ + +} + +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 = 0; + } +} + + + +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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef OBJECTTREE_H +#define OBJECTTREE_H + +#include "objectdump_global.h" + +#include <QObject> +#include <QStack> + +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<int> 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<const QObject*> 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 <class Iterator, class Visitor> +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/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp new file mode 100644 index 0000000..2f5b68f --- /dev/null +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -0,0 +1,154 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "utils.h" +#include <e32std.h> + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \namespace MMF::Utils + \internal +*/ + +/*! \class MMF::TTraceContext + \internal +*/ + +/*! \class MMF::Utils + \internal +*/ + +_LIT(PanicCategory, "Phonon::MMF"); + +void MMF::Utils::panic(PanicCode code) +{ + User::Panic(PanicCategory, code); +} + + +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; +} + + +#ifdef _DEBUG + +#include <hal.h> +#include <hal_data.h> +#include <gdi.h> +#include <eikenv.h> + +struct TScreenInfo +{ + int width; + int height; + int bpp; + const char* address; + int initialOffset; + int lineOffset; + TDisplayMode displayMode; +}; + +static 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<const char*>(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; +} + +// 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 new file mode 100644 index 0000000..38964d0 --- /dev/null +++ b/src/3rdparty/phonon/mmf/utils.h @@ -0,0 +1,167 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_UTILS_H +#define PHONON_MMF_UTILS_H + +#include <private/qcore_symbian_p.h> +#include <e32debug.h> // for RDebug + +#include <QColor> + +#include "defs.h" + +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); + +/** + * 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); + +#ifdef _DEBUG +/** + * 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 +} + +/** + * 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 +#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); } +#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...) +#endif +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp new file mode 100644 index 0000000..041b0a8 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -0,0 +1,177 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "utils.h" +#include "videooutput.h" +#include "videooutputobserver.h" + +#ifdef _DEBUG +#include "objectdump.h" +#endif + +#include <QPaintEvent> +#include <QPainter> +#include <QMoveEvent> +#include <QResizeEvent> + +#include <QtGui/private/qwidget_p.h> // to access QWExtra + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::VideoOutput + \internal +*/ + +//----------------------------------------------------------------------------- +// Constructor / destructor +//----------------------------------------------------------------------------- + +MMF::VideoOutput::VideoOutput(QWidget* parent) + : QWidget(parent) + , m_observer(0) +{ + 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); + + // 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(); +} + +MMF::VideoOutput::~VideoOutput() +{ + TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); + TRACE_ENTRY_0(); + + 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(); + } +} + +void MMF::VideoOutput::setObserver(VideoOutputObserver* observer) +{ + TRACE_CONTEXT(VideoOutput::setObserver, EVideoInternal); + TRACE("observer 0x%08x", observer); + + m_observer = observer; +} + + +//----------------------------------------------------------------------------- +// QWidget +//----------------------------------------------------------------------------- + +QSize MMF::VideoOutput::sizeHint() const +{ + // TODO: replace this with a more sensible default + QSize result(320, 240); + + if (!m_frameSize.isNull()) { + result = m_frameSize; + } + + 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()); + + dump(); + + // Do not paint anything +} + +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(); +} + +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) + m_observer->videoOutputRegionChanged(); +} + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void VideoOutput::dump() const +{ +#ifdef _DEBUG + TRACE_CONTEXT(VideoOutput::dump, EVideoInternal); + QScopedPointer<ObjectDump::QVisitor> 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 new file mode 100644 index 0000000..639a5ed --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutput.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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_VIDEOOUTPUT_H +#define PHONON_MMF_VIDEOOUTPUT_H + +#include <QtGui/QWidget> +#include <QVector> +#include <QRect> +#include "defs.h" + +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: + // Override QWidget functions + QSize sizeHint() const; + void paintEvent(QPaintEvent* event); + void resizeEvent(QResizeEvent* event); + void moveEvent(QMoveEvent* event); + +private: + void dump() const; + +private: + QSize m_frameSize; + + // Not owned + VideoOutputObserver* m_observer; +}; +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/videooutputobserver.h b/src/3rdparty/phonon/mmf/videooutputobserver.h new file mode 100644 index 0000000..e3ba305 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videooutputobserver.h @@ -0,0 +1,44 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_VIDEOOUTPUTOBSERVER_H +#define PHONON_MMF_VIDEOOUTPUTOBSERVER_H + +#include <QtGlobal> + +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; +}; +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp new file mode 100644 index 0000000..8a5c9ff --- /dev/null +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -0,0 +1,177 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "mediaobject.h" +#include "utils.h" +#include "videooutput.h" + +#include "videowidget.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::VideoWidget + \internal +*/ + +//----------------------------------------------------------------------------- +// 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(QWidget* parent) + : MediaNode(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(); +} + +MMF::VideoWidget::~VideoWidget() +{ + TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); +} + + +//----------------------------------------------------------------------------- +// VideoWidgetInterface +//----------------------------------------------------------------------------- + +Phonon::VideoWidget::AspectRatio MMF::VideoWidget::aspectRatio() const +{ + return m_aspectRatio; +} + +void MMF::VideoWidget::setAspectRatio +(Phonon::VideoWidget::AspectRatio aspectRatio) +{ + TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi); + TRACE("aspectRatio %d", aspectRatio); + + m_aspectRatio = aspectRatio; +} + +qreal MMF::VideoWidget::brightness() const +{ + return m_brightness; +} + +void MMF::VideoWidget::setBrightness(qreal brightness) +{ + TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi); + TRACE("brightness %f", brightness); + + m_brightness = brightness; +} + +Phonon::VideoWidget::ScaleMode MMF::VideoWidget::scaleMode() const +{ + return m_scaleMode; +} + +void MMF::VideoWidget::setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode) +{ + TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi); + TRACE("setScaleMode %d", setScaleMode); + + m_scaleMode = scaleMode; +} + +qreal MMF::VideoWidget::contrast() const +{ + return m_contrast; +} + +void MMF::VideoWidget::setContrast(qreal contrast) +{ + TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi); + TRACE("contrast %f", contrast); + + m_contrast = contrast; +} + +qreal MMF::VideoWidget::hue() const +{ + return m_hue; +} + +void MMF::VideoWidget::setHue(qreal hue) +{ + TRACE_CONTEXT(VideoWidget::setHue, EVideoApi); + TRACE("hue %f", hue); + + m_hue = hue; +} + +qreal MMF::VideoWidget::saturation() const +{ + return m_saturation; +} + +void MMF::VideoWidget::setSaturation(qreal saturation) +{ + TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi); + TRACE("saturation %f", saturation); + + m_saturation = saturation; +} + +QWidget* MMF::VideoWidget::widget() +{ + return m_widget.data(); +} + +VideoOutput& MMF::VideoWidget::videoOutput() +{ + return *static_cast<VideoOutput*>(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 new file mode 100644 index 0000000..970f749 --- /dev/null +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -0,0 +1,82 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_VIDEOWIDGET_H +#define PHONON_MMF_VIDEOWIDGET_H + +#include "mmf_medianode.h" + +#include <QtGui/QWidget> +#include <Phonon/VideoWidget> +#include <Phonon/VideoWidgetInterface> + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +class VideoOutput; + +class VideoWidget : public MediaNode + , 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(); + +protected: + virtual bool activateOnMediaObject(MediaObject *mo); + +private: + QScopedPointer<QWidget> 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 + +#endif diff --git a/src/3rdparty/phonon/mmf/volumeobserver.h b/src/3rdparty/phonon/mmf/volumeobserver.h new file mode 100644 index 0000000..bedd3de --- /dev/null +++ b/src/3rdparty/phonon/mmf/volumeobserver.h @@ -0,0 +1,44 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_VOLUMEOBSERVER_H +#define PHONON_MMF_VOLUMEOBSERVER_H + +#include <QtGlobal> + +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; +}; +} +} + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index fef88f0..5c3752a 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -133,9 +133,30 @@ bool FactoryPrivate::createBackend() continue; } - const QStringList files = dir.entryList(QDir::Files); - for (int i = 0; i < files.count(); ++i) { - QPluginLoader pluginLoader(libPath + files.at(i)); + 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 + * 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 hxphonon = plugins.indexOf(QLatin1String("hxphonon")); + if (hxphonon != -1) + plugins.move(hxphonon, 0); + + // Code for debugging the MMF backend. + if(hxphonon != -1) { + qDebug() << "Found hxphonon backend and removed it from the lookup list."; + plugins.removeAll(QLatin1String("hxphonon")); + } + } +#endif + + 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(); 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<QObjectPair> &disconnections, if (!transaction) return false; - QList<QObjectPair>::const_iterator it = disconnections.begin(); - for(;it != disconnections.end();++it) { + QList<QObjectPair>::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<QObjectPair> &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<QObjectPair>::const_iterator it2 = connections.begin(); |