summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/3rdparty/phonon/mmf/abstractplayer.h53
-rw-r--r--src/3rdparty/phonon/mmf/audiooutput.cpp2
-rw-r--r--src/3rdparty/phonon/mmf/audioplayer.cpp631
-rw-r--r--src/3rdparty/phonon/mmf/audioplayer.h173
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.cpp499
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.h102
-rw-r--r--src/3rdparty/phonon/mmf/mmf_videoplayer.cpp577
-rw-r--r--src/3rdparty/phonon/mmf/mmf_videoplayer.h163
-rw-r--r--src/plugins/phonon/mmf/mmf.pro27
9 files changed, 1618 insertions, 609 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h
new file mode 100644
index 0000000..6452090
--- /dev/null
+++ b/src/3rdparty/phonon/mmf/abstractplayer.h
@@ -0,0 +1,53 @@
+/* This file is part of the KDE project.
+
+Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+
+This library is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 2.1 or 3 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef PHONON_MMF_ABSTRACTPLAYER_H
+#define PHONON_MMF_ABSTRACTPLAYER_H
+
+#include <QObject>
+#include <Phonon/phononnamespace.h>
+#include <Phonon/MediaSource.h>
+
+namespace Phonon
+{
+ namespace MMF
+ {
+ class AbstractPlayer : public QObject
+ {
+ public:
+ virtual void play() = 0;
+ virtual void pause() = 0;
+ virtual void stop() = 0;
+ virtual void seek(qint64 milliseconds) = 0;
+ virtual qint32 tickInterval() const = 0;
+ virtual void setTickInterval() const = 0;
+ virtual bool hasVideo() const = 0;
+ virtual bool isSeekable() const = 0;
+ virtual qint64 currentTime() const = 0;
+ virtual Phonon::State state() const = 0;
+ virtual QString errorString() const = 0;
+ virtual Phonon::ErrorType errorType() const = 0;
+ virtual Phonon::MediaSource source() const = 0;
+ virtual void setSource(const Phonon::MediaSource &) = 0;
+ virtual void setNextSource(const Phonon::MediaSource &) = 0;
+ };
+ }
+}
+
+#endif
+
diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp
index 9c8cb6b..d8758fd 100644
--- a/src/3rdparty/phonon/mmf/audiooutput.cpp
+++ b/src/3rdparty/phonon/mmf/audiooutput.cpp
@@ -16,6 +16,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <e32debug.h>
+
#include "mediaobject.h"
#include "audiooutput.h"
#include "utils.h"
diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp
new file mode 100644
index 0000000..4dd2eb8
--- /dev/null
+++ b/src/3rdparty/phonon/mmf/audioplayer.cpp
@@ -0,0 +1,631 @@
+/* This file is part of the KDE project.
+
+Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+
+This library is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 2.1 or 3 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include <QUrl>
+#include <QTimer>
+#include <private/qcore_symbian_p.h>
+
+#include "audioplayer.h"
+#include "audiooutput.h"
+#include "utils.h"
+
+using namespace Phonon;
+using namespace Phonon::MMF;
+
+//-----------------------------------------------------------------------------
+// Constants
+//-----------------------------------------------------------------------------
+
+const qint32 DefaultTickInterval = 20;
+const int NullMaxVolume = -1;
+
+
+//-----------------------------------------------------------------------------
+// Constructor / destructor
+//-----------------------------------------------------------------------------
+
+MMF::AudioPlayer::AudioPlayer(QObject *parent) : m_player(NULL)
+ , m_audioOutput(NULL)
+ , m_error(NoError)
+ , m_state(GroundState)
+ , m_tickInterval(DefaultTickInterval)
+ , m_tickTimer(NULL)
+ , m_volume(0.0)
+ , m_maxVolume(NullMaxVolume)
+{
+ TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi);
+ TRACE_ENTRY_0();
+
+ Q_UNUSED(parent);
+
+ // TODO: should leaves be trapped in the constructor?
+ m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone);
+
+ m_tickTimer = new QTimer(this);
+ connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick()));
+
+ TRACE_EXIT_0();
+}
+
+MMF::AudioPlayer::~AudioPlayer()
+{
+ TRACE_CONTEXT(AudioPlayer::~AudioPlayer, EAudioApi);
+ TRACE_ENTRY_0();
+
+ delete m_tickTimer;
+ delete m_player;
+
+ TRACE_EXIT_0();
+}
+
+//-----------------------------------------------------------------------------
+// AudioPlayerInterface
+//-----------------------------------------------------------------------------
+
+void MMF::AudioPlayer::play()
+{
+ TRACE_CONTEXT(AudioPlayer::play, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ switch(m_state)
+ {
+ case GroundState:
+ case LoadingState:
+ // Is this the correct error? Really we want 'NotReadyError'
+ m_error = NormalError;
+ changeState(ErrorState);
+ break;
+
+ case StoppedState:
+ case PausedState:
+ m_player->Play();
+ m_tickTimer->start(m_tickInterval);
+ changeState(PlayingState);
+ break;
+
+ case PlayingState:
+ case BufferingState:
+ case ErrorState:
+ // Do nothing
+ break;
+
+ // Protection against adding new states and forgetting to update this switch
+ default:
+ TRACE_PANIC(InvalidStatePanic);
+ }
+
+ TRACE_EXIT("state %d", m_state);
+}
+
+void MMF::AudioPlayer::pause()
+{
+ TRACE_CONTEXT(AudioPlayer::pause, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ switch(m_state)
+ {
+ case GroundState:
+ case LoadingState:
+ case StoppedState:
+ case PausedState:
+ case ErrorState:
+ // Do nothing
+ break;
+
+ case PlayingState:
+ case BufferingState:
+ m_player->Pause();
+ m_tickTimer->stop();
+ changeState(PausedState);
+ break;
+
+ // Protection against adding new states and forgetting to update this switch
+ default:
+ TRACE_PANIC(InvalidStatePanic);
+ }
+
+ TRACE_EXIT("state %d", m_state);
+}
+
+void MMF::AudioPlayer::stop()
+{
+ TRACE_CONTEXT(AudioPlayer::stop, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ switch(m_state)
+ {
+ case GroundState:
+ case LoadingState:
+ case StoppedState:
+ case ErrorState:
+ // Do nothing
+ break;
+
+ case PlayingState:
+ case BufferingState:
+ case PausedState:
+ m_player->Stop();
+ m_tickTimer->stop();
+ changeState(StoppedState);
+ break;
+
+ // Protection against adding new states and forgetting to update this switch
+ default:
+ TRACE_PANIC(InvalidStatePanic);
+ }
+
+ TRACE_EXIT("state %d", m_state);
+}
+
+void MMF::AudioPlayer::seek(qint64 ms)
+{
+ TRACE_CONTEXT(AudioPlayer::seek, EAudioApi);
+ TRACE_ENTRY("state %d pos %Ld", m_state, ms);
+
+ m_player->SetPosition(TTimeIntervalMicroSeconds(ms));
+
+ TRACE_EXIT_0();
+}
+
+qint32 MMF::AudioPlayer::tickInterval() const
+{
+ TRACE_CONTEXT(AudioPlayer::tickInterval, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TRACE_RETURN("%d", m_tickInterval);
+}
+
+void MMF::AudioPlayer::setTickInterval(qint32 interval)
+{
+ TRACE_CONTEXT(AudioPlayer::setTickInterval, EAudioApi);
+ TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval);
+
+ m_tickInterval = interval;
+ m_tickTimer->setInterval(interval);
+
+ TRACE_EXIT_0();
+}
+
+bool MMF::AudioPlayer::hasVideo() const
+{
+ TRACE_CONTEXT(AudioPlayer::hasVideo, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ // TODO: re-factor this class so that audio playback and video playback are
+ // delegated to separate classes, which internally hoat a
+ // CMdaAudioPlayerUtility / CVideoPlayerUtility instance as appropriate.
+
+ TRACE_RETURN("%d", false);
+}
+
+bool MMF::AudioPlayer::isSeekable() const
+{
+ TRACE_CONTEXT(AudioPlayer::isSeekable, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TRACE_RETURN("%d", true);
+}
+
+Phonon::State MMF::AudioPlayer::state() const
+{
+ TRACE_CONTEXT(AudioPlayer::state, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ const Phonon::State result = phononState(m_state);
+
+ TRACE_RETURN("%d", result);
+}
+
+qint64 MMF::AudioPlayer::currentTime() const
+{
+ TRACE_CONTEXT(AudioPlayer::currentTime, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TTimeIntervalMicroSeconds us;
+ const TInt err = m_player->GetPosition(us);
+
+ qint64 result = -1;
+
+ if(KErrNone == err) {
+ result = toMilliSeconds(us);
+ }
+
+ TRACE_RETURN("%Ld", result);
+}
+
+QString MMF::AudioPlayer::errorString() const
+{
+ TRACE_CONTEXT(AudioPlayer::errorString, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TRACE_EXIT_0();
+ // TODO: put in proper error strings
+ QString result;
+ return result;
+}
+
+Phonon::ErrorType MMF::AudioPlayer::errorType() const
+{
+ TRACE_CONTEXT(AudioPlayer::errorType, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ const Phonon::ErrorType result = (ErrorState == m_state)
+ ? m_error : NoError;
+
+ TRACE_RETURN("%d", result);
+}
+
+qint64 MMF::AudioPlayer::totalTime() const
+{
+ TRACE_CONTEXT(AudioPlayer::totalTime, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ const qint64 result = toMilliSeconds(m_player->Duration());
+
+ TRACE_RETURN("%Ld", result);
+}
+
+MediaSource MMF::AudioPlayer::source() const
+{
+ TRACE_CONTEXT(AudioPlayer::source, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TRACE_EXIT_0();
+ return m_mediaSource;
+}
+
+void MMF::AudioPlayer::setSource(const MediaSource &source)
+{
+ TRACE_CONTEXT(AudioPlayer::setSource, EAudioApi);
+ TRACE_ENTRY("state %d source.type %d", m_state, source.type());
+
+ m_player->Close();
+ changeState(GroundState);
+
+ // TODO: is it correct to assign even if the media type is not supported in
+ // the switch statement below?
+ m_mediaSource = source;
+
+ TInt symbianErr = KErrNone;
+
+ switch(m_mediaSource.type())
+ {
+ case MediaSource::LocalFile:
+ {
+ // TODO: work out whose responsibility it is to ensure that paths
+ // are Symbian-style, i.e. have backslashes for path delimiters.
+ // Until then, use this utility function...
+ const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName());
+ TRAP(symbianErr, m_player->OpenFileL(*filename));
+ break;
+ }
+
+ case MediaSource::Url:
+ {
+ const QHBufC filename(m_mediaSource.url().toString());
+ TRAP(symbianErr, m_player->OpenUrlL(*filename));
+ break;
+ }
+
+ case MediaSource::Invalid:
+ case MediaSource::Disc:
+ case MediaSource::Stream:
+ symbianErr = KErrNotSupported;
+ break;
+
+ case MediaSource::Empty:
+ TRACE_EXIT_0();
+ return;
+
+ // Protection against adding new media types and forgetting to update this switch
+ default:
+ TRACE_PANIC(InvalidMediaTypePanic);
+ }
+
+ if(KErrNone == symbianErr)
+ {
+#ifdef QT_PHONON_MMF_AUDIO_DRM
+ // There appears to be a bug in the CDrmPlayerUtility implementation (at least
+ // in S60 5.x) whereby the player does not check whether the loading observer
+ // pointer is null before dereferencing it. Therefore we must register for
+ // loading notification, even though we do nothing in the callback functions.
+ m_player->RegisterForAudioLoadingNotification(*this);
+#endif
+ changeState(LoadingState);
+ }
+ else
+ {
+ // TODO: do something with the value of symbianErr?
+ m_error = NormalError;
+ changeState(ErrorState);
+ }
+
+ TRACE_EXIT_0();
+}
+
+void MMF::AudioPlayer::setNextSource(const MediaSource &source)
+{
+ TRACE_CONTEXT(AudioPlayer::setNextSource, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ // TODO: handle 'next source'
+
+ m_nextSource = source;
+ Q_UNUSED(source);
+
+ TRACE_EXIT_0();
+}
+
+qint32 MMF::AudioPlayer::prefinishMark() const
+{
+ TRACE_CONTEXT(AudioPlayer::prefinishMark, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ // TODO: implement prefinish mark
+ const qint32 result = 0;
+ TRACE_RETURN("%d", result);
+}
+
+void MMF::AudioPlayer::setPrefinishMark(qint32 mark)
+{
+ TRACE_CONTEXT(AudioPlayer::setPrefinishMark, EAudioApi);
+ TRACE_ENTRY("state %d mark %d", m_state, mark);
+ Q_UNUSED(mark); // to silence warnings in release builds
+
+ // TODO: implement prefinish mark
+
+ TRACE_EXIT_0();
+}
+
+qint32 MMF::AudioPlayer::transitionTime() const
+{
+ TRACE_CONTEXT(AudioPlayer::transitionTime, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ // TODO: implement transition time
+ const qint32 result = 0;
+ TRACE_RETURN("%d", result);
+}
+
+void MMF::AudioPlayer::setTransitionTime(qint32 time)
+{
+ TRACE_CONTEXT(AudioPlayer::setTransitionTime, EAudioApi);
+ TRACE_ENTRY("state %d time %d", m_state, time);
+ Q_UNUSED(time); // to silence warnings in release builds
+
+ // TODO: implement transition time
+
+ TRACE_EXIT_0();
+}
+
+
+//-----------------------------------------------------------------------------
+// Symbian multimedia client observer callbacks
+//-----------------------------------------------------------------------------
+
+#ifdef QT_PHONON_MMF_AUDIO_DRM
+void MMF::AudioPlayer::MdapcInitComplete(TInt aError,
+ const TTimeIntervalMicroSeconds &)
+#else
+void MMF::AudioPlayer::MapcInitComplete(TInt aError,
+ const TTimeIntervalMicroSeconds &)
+#endif
+{
+ TRACE_CONTEXT(AudioPlayer::MapcInitComplete, EAudioInternal);
+ TRACE_ENTRY("state %d error %d", m_state, aError);
+
+ __ASSERT_ALWAYS(LoadingState == m_state, Utils::panic(InvalidStatePanic));
+
+ if(KErrNone == aError)
+ {
+ TInt volume = 0;
+ aError = m_player->GetVolume(volume);
+ if(KErrNone == aError)
+ {
+ m_maxVolume = m_player->MaxVolume();
+ m_volume = static_cast<qreal>(volume) / m_maxVolume;
+
+ if(m_audioOutput)
+ {
+ // Trigger AudioOutput signal
+ m_audioOutput->triggerVolumeChanged(m_volume);
+ }
+
+ emit totalTimeChanged();
+ changeState(StoppedState);
+ }
+ }
+ else
+ {
+ // TODO: set different error states according to value of aError?
+ m_error = NormalError;
+ changeState(ErrorState);
+ }
+
+ TRACE_EXIT_0();
+}
+
+#ifdef QT_PHONON_MMF_AUDIO_DRM
+void MMF::AudioPlayer::MdapcPlayComplete(TInt aError)
+#else
+void MMF::AudioPlayer::MapcPlayComplete(TInt aError)
+#endif
+{
+ TRACE_CONTEXT(AudioPlayer::MapcPlayComplete, EAudioInternal);
+ TRACE_ENTRY("state %d error %d", m_state, aError);
+
+ m_tickTimer->stop();
+
+ if(KErrNone == aError)
+ {
+ changeState(StoppedState);
+ // TODO: move on to m_nextSource
+ }
+ else
+ {
+ // TODO: do something with aError?
+ m_error = NormalError;
+ changeState(ErrorState);
+ }
+
+/*
+ if(aError == KErrNone) {
+ if(m_nextSource.type() == MediaSource::Empty) {
+ emit finished();
+ } else {
+ setSource(m_nextSource);
+ m_nextSource = MediaSource();
+ }
+
+ changeState(StoppedState);
+ }
+ else {
+ m_error = NormalError;
+ changeState(ErrorState);
+ }
+*/
+
+ TRACE_EXIT_0();
+}
+
+#ifdef QT_PHONON_MMF_AUDIO_DRM
+void MMF::AudioPlayer::MaloLoadingStarted()
+{
+
+}
+
+void MMF::AudioPlayer::MaloLoadingComplete()
+{
+
+}
+#endif // QT_PHONON_MMF_AUDIO_DRM
+
+
+//-----------------------------------------------------------------------------
+// Volume
+//-----------------------------------------------------------------------------
+
+qreal MMF::AudioPlayer::volume() const
+{
+ return m_volume;
+}
+
+bool MMF::AudioPlayer::setVolume(qreal volume)
+{
+ TRACE_CONTEXT(AudioPlayer::setVolume, EAudioInternal);
+ TRACE_ENTRY("state %d", m_state);
+
+ bool volumeChanged = false;
+
+ switch(m_state)
+ {
+ case GroundState:
+ case LoadingState:
+ case ErrorState:
+ // Do nothing
+ break;
+
+ case StoppedState:
+ case PausedState:
+ case PlayingState:
+ case BufferingState:
+ {
+ if(volume != m_volume)
+ {
+ const int err = m_player->SetVolume(volume * m_maxVolume);
+ if(KErrNone == err)
+ {
+ m_volume = volume;
+ volumeChanged = true;
+ }
+ else
+ {
+ m_error = NormalError;
+ changeState(ErrorState);
+ }
+ }
+ break;
+ }
+
+ // Protection against adding new states and forgetting to update this
+ // switch
+ default:
+ TRACE_PANIC(InvalidStatePanic);
+ }
+
+ TRACE_RETURN("%d", volumeChanged);
+}
+
+void MMF::AudioPlayer::setAudioOutput(AudioOutput* audioOutput)
+{
+ m_audioOutput = audioOutput;
+}
+
+
+//-----------------------------------------------------------------------------
+// Private functions
+//-----------------------------------------------------------------------------
+
+qint64 MMF::AudioPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in)
+{
+ return in.Int64() / 1000;
+}
+
+Phonon::State MMF::AudioPlayer::phononState(PrivateState state)
+{
+ const Phonon::State phononState =
+ GroundState == state
+ ? Phonon::StoppedState
+ : static_cast<Phonon::State>(state);
+
+ return phononState;
+}
+
+void MMF::AudioPlayer::changeState(PrivateState newState)
+{
+ TRACE_CONTEXT(AudioPlayer::changeState, EAudioInternal);
+ TRACE_ENTRY("state %d newState %d", m_state, newState);
+
+ // TODO: add some invariants to check that the transition is valid
+
+ const Phonon::State currentPhononState = phononState(m_state);
+ const Phonon::State newPhononState = phononState(newState);
+ if(currentPhononState != newPhononState)
+ {
+ TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState);
+ emit stateChanged(newPhononState, currentPhononState);
+ }
+
+ m_state = newState;
+
+ TRACE_EXIT_0();
+}
+
+void MMF::AudioPlayer::tick()
+{
+ TRACE_CONTEXT(AudioPlayer::tick, EAudioInternal);
+ TRACE_ENTRY("state %d", m_state);
+
+ emit tick(currentTime());
+
+ TRACE_EXIT_0();
+}
+
+
+
+
diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h
new file mode 100644
index 0000000..d9a64e1
--- /dev/null
+++ b/src/3rdparty/phonon/mmf/audioplayer.h
@@ -0,0 +1,173 @@
+/* This file is part of the KDE project.
+
+Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+
+This library is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 2.1 or 3 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef PHONON_MMF_AUDIOPLAYER_H
+#define PHONON_MMF_AUDIOPLAYER_H
+
+#include "abstractplayer.h"
+
+class CDrmPlayerUtility;
+class TTimeIntervalMicroSeconds;
+class QTimer;
+
+#ifdef QT_PHONON_MMF_AUDIO_DRM
+#include <drmaudiosampleplayer.h>
+typedef CDrmPlayerUtility CPlayerType;
+typedef MDrmAudioPlayerCallback MPlayerObserverType;
+#else
+#include <mdaaudiosampleplayer.h>
+typedef CMdaAudioPlayerUtility CPlayerType;
+typedef MMdaAudioPlayerCallback MPlayerObserverType;
+#endif
+
+namespace Phonon
+{
+ namespace MMF
+ {
+ class AudioOutput;
+
+ /**
+ *
+ * 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 AudioPlayer : public AbstractPlayer
+ , public MPlayerObserverType // typedef
+#ifdef QT_PHONON_MMF_AUDIO_DRM
+ , public MAudioLoadingObserver
+#endif
+ {
+ Q_OBJECT
+
+ public:
+ AudioPlayer(QObject *parent);
+ virtual ~AudioPlayer();
+
+ // AbstractPlayer
+ virtual void play();
+ virtual void pause();
+ virtual void stop();
+ virtual void seek(qint64 milliseconds);
+ virtual qint32 tickInterval() const;
+ virtual void setTickInterval(qint32 interval);
+ virtual bool hasVideo() const;
+ virtual bool isSeekable() const;
+ virtual qint64 currentTime() const;
+ virtual Phonon::State state() const;
+ virtual QString errorString() const;
+ virtual Phonon::ErrorType errorType() const;
+ virtual qint64 totalTime() const;
+ virtual MediaSource source() const;
+ virtual void setSource(const MediaSource &);
+ virtual void setNextSource(const MediaSource &source);
+ virtual qint32 prefinishMark() const;
+ virtual void setPrefinishMark(qint32);
+ virtual qint32 transitionTime() const;
+ virtual void setTransitionTime(qint32);
+
+#ifdef QT_PHONON_MMF_AUDIO_DRM
+ // MDrmAudioPlayerCallback
+ virtual void MdapcInitComplete(TInt aError,
+ const TTimeIntervalMicroSeconds &aDuration);
+ virtual void MdapcPlayComplete(TInt aError);
+
+ // MAudioLoadingObserver
+ virtual void MaloLoadingStarted();
+ virtual void MaloLoadingComplete();
+#else
+ // MMdaAudioPlayerCallback
+ virtual void MapcInitComplete(TInt aError,
+ const TTimeIntervalMicroSeconds &aDuration);
+ virtual void MapcPlayComplete(TInt aError);
+#endif
+
+ qreal volume() const;
+ bool setVolume(qreal volume);
+
+ void setAudioOutput(AudioOutput* audioOutput);
+
+ Q_SIGNALS:
+ void totalTimeChanged();
+ void stateChanged(Phonon::State oldState,
+ Phonon::State newState);
+ void finished();
+ void tick(qint64 time);
+
+ private Q_SLOTS:
+ /**
+ * Receives signal from m_tickTimer
+ */
+ void tick();
+
+ private:
+ static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &);
+
+ /**
+ * Defined private state enumeration in order to add GroundState
+ */
+ enum PrivateState
+ {
+ LoadingState = Phonon::LoadingState,
+ StoppedState = Phonon::StoppedState,
+ PlayingState = Phonon::PlayingState,
+ BufferingState = Phonon::BufferingState,
+ PausedState = Phonon::PausedState,
+ ErrorState = Phonon::ErrorState,
+ GroundState
+ };
+
+ /**
+ * Converts PrivateState into the corresponding Phonon::State
+ */
+ static Phonon::State phononState(PrivateState state);
+
+ /**
+ * Changes state and emits stateChanged()
+ */
+ void changeState(PrivateState newState);
+
+ /**
+ * Using CPlayerType typedef in order to be able to easily switch between
+ * CMdaAudioPlayerUtility and CDrmPlayerUtility
+ */
+ CPlayerType* m_player;
+
+ AudioOutput* m_audioOutput;
+
+ ErrorType m_error;
+
+ /**
+ * Do not set this directly - call changeState() instead.
+ */
+ PrivateState m_state;
+
+ qint32 m_tickInterval;
+
+ QTimer* m_tickTimer;
+
+ MediaSource m_mediaSource;
+ MediaSource m_nextSource;
+
+ qreal m_volume;
+ int m_maxVolume;
+ };
+ }
+}
+
+#endif
diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp
index 8a4b76e..fb079f0 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.cpp
+++ b/src/3rdparty/phonon/mmf/mediaobject.cpp
@@ -16,61 +16,21 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <QUrl>
-#include <QTimer>
-#include <private/qcore_symbian_p.h>
-
#include "mediaobject.h"
-#include "audiooutput.h"
-#include "utils.h"
using namespace Phonon;
using namespace Phonon::MMF;
//-----------------------------------------------------------------------------
-// Constants
-//-----------------------------------------------------------------------------
-
-const qint32 DefaultTickInterval = 20;
-const int NullMaxVolume = -1;
-
-
-//-----------------------------------------------------------------------------
// Constructor / destructor
//-----------------------------------------------------------------------------
-MMF::MediaObject::MediaObject(QObject *parent) : m_player(NULL)
- , m_audioOutput(NULL)
- , m_error(NoError)
- , m_state(GroundState)
- , m_tickInterval(DefaultTickInterval)
- , m_tickTimer(NULL)
- , m_volume(0.0)
- , m_maxVolume(NullMaxVolume)
+MMF::MediaObject::MediaObject(QObject *parent) : QObject::QObject(parent)
{
- TRACE_CONTEXT(MediaObject::MediaObject, EAudioApi);
- TRACE_ENTRY_0();
-
- Q_UNUSED(parent);
-
- // TODO: should leaves be trapped in the constructor?
- m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone);
-
- m_tickTimer = new QTimer(this);
- connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick()));
-
- TRACE_EXIT_0();
}
MMF::MediaObject::~MediaObject()
{
- TRACE_CONTEXT(MediaObject::~MediaObject, EAudioApi);
- TRACE_ENTRY_0();
-
- delete m_tickTimer;
- delete m_player;
-
- TRACE_EXIT_0();
}
//-----------------------------------------------------------------------------
@@ -79,442 +39,84 @@ MMF::MediaObject::~MediaObject()
void MMF::MediaObject::play()
{
- TRACE_CONTEXT(MediaObject::play, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- switch(m_state)
- {
- case GroundState:
- case LoadingState:
- // Is this the correct error? Really we want 'NotReadyError'
- m_error = NormalError;
- changeState(ErrorState);
- break;
-
- case StoppedState:
- case PausedState:
- m_player->Play();
- m_tickTimer->start(m_tickInterval);
- changeState(PlayingState);
- break;
-
- case PlayingState:
- case BufferingState:
- case ErrorState:
- // Do nothing
- break;
-
- // Protection against adding new states and forgetting to update this switch
- default:
- TRACE_PANIC(InvalidStatePanic);
- }
-
- TRACE_EXIT("state %d", m_state);
}
void MMF::MediaObject::pause()
{
- TRACE_CONTEXT(MediaObject::pause, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- switch(m_state)
- {
- case GroundState:
- case LoadingState:
- case StoppedState:
- case PausedState:
- case ErrorState:
- // Do nothing
- break;
-
- case PlayingState:
- case BufferingState:
- m_player->Pause();
- m_tickTimer->stop();
- changeState(PausedState);
- break;
-
- // Protection against adding new states and forgetting to update this switch
- default:
- TRACE_PANIC(InvalidStatePanic);
- }
-
- TRACE_EXIT("state %d", m_state);
}
void MMF::MediaObject::stop()
{
- TRACE_CONTEXT(MediaObject::stop, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- switch(m_state)
- {
- case GroundState:
- case LoadingState:
- case StoppedState:
- case ErrorState:
- // Do nothing
- break;
-
- case PlayingState:
- case BufferingState:
- case PausedState:
- m_player->Stop();
- m_tickTimer->stop();
- changeState(StoppedState);
- break;
-
- // Protection against adding new states and forgetting to update this switch
- default:
- TRACE_PANIC(InvalidStatePanic);
- }
-
- TRACE_EXIT("state %d", m_state);
}
void MMF::MediaObject::seek(qint64 ms)
{
- TRACE_CONTEXT(MediaObject::seek, EAudioApi);
- TRACE_ENTRY("state %d pos %Ld", m_state, ms);
-
- m_player->SetPosition(TTimeIntervalMicroSeconds(ms));
-
- TRACE_EXIT_0();
+ Q_UNUSED(ms);
}
qint32 MMF::MediaObject::tickInterval() const
{
- TRACE_CONTEXT(MediaObject::tickInterval, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- TRACE_RETURN("%d", m_tickInterval);
}
void MMF::MediaObject::setTickInterval(qint32 interval)
{
- TRACE_CONTEXT(MediaObject::setTickInterval, EAudioApi);
- TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval);
-
- m_tickInterval = interval;
- m_tickTimer->setInterval(interval);
-
- TRACE_EXIT_0();
}
bool MMF::MediaObject::hasVideo() const
{
- TRACE_CONTEXT(MediaObject::hasVideo, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- // TODO: re-factor this class so that audio playback and video playback are
- // delegated to separate classes, which internally hoat a
- // CMdaAudioPlayerUtility / CVideoPlayerUtility instance as appropriate.
-
- TRACE_RETURN("%d", false);
}
bool MMF::MediaObject::isSeekable() const
{
- TRACE_CONTEXT(MediaObject::isSeekable, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- TRACE_RETURN("%d", true);
}
Phonon::State MMF::MediaObject::state() const
{
- TRACE_CONTEXT(MediaObject::state, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- const Phonon::State result = phononState(m_state);
-
- TRACE_RETURN("%d", result);
}
qint64 MMF::MediaObject::currentTime() const
{
- TRACE_CONTEXT(MediaObject::currentTime, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- TTimeIntervalMicroSeconds us;
- const TInt err = m_player->GetPosition(us);
-
- qint64 result = -1;
-
- if(KErrNone == err) {
- result = toMilliSeconds(us);
- }
-
- TRACE_RETURN("%Ld", result);
}
QString MMF::MediaObject::errorString() const
{
- TRACE_CONTEXT(MediaObject::errorString, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- TRACE_EXIT_0();
- // TODO: put in proper error strings
- QString result;
- return result;
}
Phonon::ErrorType MMF::MediaObject::errorType() const
{
- TRACE_CONTEXT(MediaObject::errorType, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- const Phonon::ErrorType result = (ErrorState == m_state)
- ? m_error : NoError;
-
- TRACE_RETURN("%d", result);
}
qint64 MMF::MediaObject::totalTime() const
{
- TRACE_CONTEXT(MediaObject::totalTime, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- const qint64 result = toMilliSeconds(m_player->Duration());
-
- TRACE_RETURN("%Ld", result);
}
MediaSource MMF::MediaObject::source() const
{
- TRACE_CONTEXT(MediaObject::source, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- TRACE_EXIT_0();
- return m_mediaSource;
}
void MMF::MediaObject::setSource(const MediaSource &source)
{
- TRACE_CONTEXT(MediaObject::setSource, EAudioApi);
- TRACE_ENTRY("state %d source.type %d", m_state, source.type());
-
- m_player->Close();
- changeState(GroundState);
-
- // TODO: is it correct to assign even if the media type is not supported in
- // the switch statement below?
- m_mediaSource = source;
-
- TInt symbianErr = KErrNone;
-
- switch(m_mediaSource.type())
- {
- case MediaSource::LocalFile:
- {
- // TODO: work out whose responsibility it is to ensure that paths
- // are Symbian-style, i.e. have backslashes for path delimiters.
- // Until then, use this utility function...
- const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName());
- TRAP(symbianErr, m_player->OpenFileL(*filename));
- break;
- }
-
- case MediaSource::Url:
- {
- const QHBufC filename(m_mediaSource.url().toString());
- TRAP(symbianErr, m_player->OpenUrlL(*filename));
- break;
- }
-
- case MediaSource::Invalid:
- case MediaSource::Disc:
- case MediaSource::Stream:
- symbianErr = KErrNotSupported;
- break;
-
- case MediaSource::Empty:
- TRACE_EXIT_0();
- return;
-
- // Protection against adding new media types and forgetting to update this switch
- default:
- TRACE_PANIC(InvalidMediaTypePanic);
- }
-
- if(KErrNone == symbianErr)
- {
-#ifdef QT_PHONON_MMF_AUDIO_DRM
- // There appears to be a bug in the CDrmPlayerUtility implementation (at least
- // in S60 5.x) whereby the player does not check whether the loading observer
- // pointer is null before dereferencing it. Therefore we must register for
- // loading notification, even though we do nothing in the callback functions.
- m_player->RegisterForAudioLoadingNotification(*this);
-#endif
- changeState(LoadingState);
- }
- else
- {
- // TODO: do something with the value of symbianErr?
- m_error = NormalError;
- changeState(ErrorState);
- }
-
- TRACE_EXIT_0();
}
void MMF::MediaObject::setNextSource(const MediaSource &source)
{
- TRACE_CONTEXT(MediaObject::setNextSource, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- // TODO: handle 'next source'
-
- m_nextSource = source;
- Q_UNUSED(source);
-
- TRACE_EXIT_0();
}
qint32 MMF::MediaObject::prefinishMark() const
{
- TRACE_CONTEXT(MediaObject::prefinishMark, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- // TODO: implement prefinish mark
- const qint32 result = 0;
- TRACE_RETURN("%d", result);
}
void MMF::MediaObject::setPrefinishMark(qint32 mark)
{
- TRACE_CONTEXT(MediaObject::setPrefinishMark, EAudioApi);
- TRACE_ENTRY("state %d mark %d", m_state, mark);
- Q_UNUSED(mark); // to silence warnings in release builds
-
- // TODO: implement prefinish mark
-
- TRACE_EXIT_0();
}
qint32 MMF::MediaObject::transitionTime() const
{
- TRACE_CONTEXT(MediaObject::transitionTime, EAudioApi);
- TRACE_ENTRY("state %d", m_state);
-
- // TODO: implement transition time
- const qint32 result = 0;
- TRACE_RETURN("%d", result);
}
void MMF::MediaObject::setTransitionTime(qint32 time)
{
- TRACE_CONTEXT(MediaObject::setTransitionTime, EAudioApi);
- TRACE_ENTRY("state %d time %d", m_state, time);
- Q_UNUSED(time); // to silence warnings in release builds
-
- // TODO: implement transition time
-
- TRACE_EXIT_0();
-}
-
-
-//-----------------------------------------------------------------------------
-// Symbian multimedia client observer callbacks
-//-----------------------------------------------------------------------------
-
-#ifdef QT_PHONON_MMF_AUDIO_DRM
-void MMF::MediaObject::MdapcInitComplete(TInt aError,
- const TTimeIntervalMicroSeconds &)
-#else
-void MMF::MediaObject::MapcInitComplete(TInt aError,
- const TTimeIntervalMicroSeconds &)
-#endif
-{
- TRACE_CONTEXT(MediaObject::MapcInitComplete, EAudioInternal);
- TRACE_ENTRY("state %d error %d", m_state, aError);
-
- __ASSERT_ALWAYS(LoadingState == m_state, Utils::panic(InvalidStatePanic));
-
- if(KErrNone == aError)
- {
- TInt volume = 0;
- aError = m_player->GetVolume(volume);
- if(KErrNone == aError)
- {
- m_maxVolume = m_player->MaxVolume();
- m_volume = static_cast<qreal>(volume) / m_maxVolume;
-
- if(m_audioOutput)
- {
- // Trigger AudioOutput signal
- m_audioOutput->triggerVolumeChanged(m_volume);
- }
-
- emit totalTimeChanged();
- changeState(StoppedState);
- }
- }
- else
- {
- // TODO: set different error states according to value of aError?
- m_error = NormalError;
- changeState(ErrorState);
- }
-
- TRACE_EXIT_0();
-}
-
-#ifdef QT_PHONON_MMF_AUDIO_DRM
-void MMF::MediaObject::MdapcPlayComplete(TInt aError)
-#else
-void MMF::MediaObject::MapcPlayComplete(TInt aError)
-#endif
-{
- TRACE_CONTEXT(MediaObject::MapcPlayComplete, EAudioInternal);
- TRACE_ENTRY("state %d error %d", m_state, aError);
-
- m_tickTimer->stop();
-
- if(KErrNone == aError)
- {
- changeState(StoppedState);
- // TODO: move on to m_nextSource
- }
- else
- {
- // TODO: do something with aError?
- m_error = NormalError;
- changeState(ErrorState);
- }
-
-/*
- if(aError == KErrNone) {
- if(m_nextSource.type() == MediaSource::Empty) {
- emit finished();
- } else {
- setSource(m_nextSource);
- m_nextSource = MediaSource();
- }
-
- changeState(StoppedState);
- }
- else {
- m_error = NormalError;
- changeState(ErrorState);
- }
-*/
-
- TRACE_EXIT_0();
-}
-
-#ifdef QT_PHONON_MMF_AUDIO_DRM
-void MMF::MediaObject::MaloLoadingStarted()
-{
-
-}
-
-void MMF::MediaObject::MaloLoadingComplete()
-{
-
}
-#endif // QT_PHONON_MMF_AUDIO_DRM
-
//-----------------------------------------------------------------------------
// Volume
@@ -522,110 +124,13 @@ void MMF::MediaObject::MaloLoadingComplete()
qreal MMF::MediaObject::volume() const
{
- return m_volume;
}
bool MMF::MediaObject::setVolume(qreal volume)
{
- TRACE_CONTEXT(MediaObject::setVolume, EAudioInternal);
- TRACE_ENTRY("state %d", m_state);
-
- bool volumeChanged = false;
-
- switch(m_state)
- {
- case GroundState:
- case LoadingState:
- case ErrorState:
- // Do nothing
- break;
-
- case StoppedState:
- case PausedState:
- case PlayingState:
- case BufferingState:
- {
- if(volume != m_volume)
- {
- const int err = m_player->SetVolume(volume * m_maxVolume);
- if(KErrNone == err)
- {
- m_volume = volume;
- volumeChanged = true;
- }
- else
- {
- m_error = NormalError;
- changeState(ErrorState);
- }
- }
- break;
- }
-
- // Protection against adding new states and forgetting to update this
- // switch
- default:
- TRACE_PANIC(InvalidStatePanic);
- }
-
- TRACE_RETURN("%d", volumeChanged);
}
void MMF::MediaObject::setAudioOutput(AudioOutput* audioOutput)
{
- m_audioOutput = audioOutput;
-}
-
-
-//-----------------------------------------------------------------------------
-// Private functions
-//-----------------------------------------------------------------------------
-
-qint64 MMF::MediaObject::toMilliSeconds(const TTimeIntervalMicroSeconds &in)
-{
- return in.Int64() / 1000;
-}
-
-Phonon::State MMF::MediaObject::phononState(PrivateState state)
-{
- const Phonon::State phononState =
- GroundState == state
- ? Phonon::StoppedState
- : static_cast<Phonon::State>(state);
-
- return phononState;
-}
-
-void MMF::MediaObject::changeState(PrivateState newState)
-{
- TRACE_CONTEXT(MediaObject::changeState, EAudioInternal);
- TRACE_ENTRY("state %d newState %d", m_state, newState);
-
- // TODO: add some invariants to check that the transition is valid
-
- const Phonon::State currentPhononState = phononState(m_state);
- const Phonon::State newPhononState = phononState(newState);
- if(currentPhononState != newPhononState)
- {
- TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState);
- emit stateChanged(newPhononState, currentPhononState);
- }
-
- m_state = newState;
-
- TRACE_EXIT_0();
-}
-
-void MMF::MediaObject::tick()
-{
- TRACE_CONTEXT(MediaObject::tick, EAudioInternal);
- TRACE_ENTRY("state %d", m_state);
-
- emit tick(currentTime());
-
- TRACE_EXIT_0();
}
-
-
-
diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h
index f17580e..d162455 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.h
+++ b/src/3rdparty/phonon/mmf/mediaobject.h
@@ -19,26 +19,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#ifndef PHONON_MMF_MEDIAOBJECT_H
#define PHONON_MMF_MEDIAOBJECT_H
-/* We use the extra qualification include/ to avoid picking up the include
- * Phonon has. */
-#include <include/videoplayer.h>
-
#include <Phonon/MediaSource>
-#include <Phonon/mediaobjectinterface.h>
-
-class CDrmPlayerUtility;
-class TTimeIntervalMicroSeconds;
-class QTimer;
-
-#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
+#include <Phonon/MediaObjectInterface>
namespace Phonon
{
@@ -47,17 +29,9 @@ namespace Phonon
class AudioOutput;
/**
- *
- * 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 MediaObject : public QObject
, public MediaObjectInterface
- , public MPlayerObserverType // typedef
-#ifdef QT_PHONON_MMF_AUDIO_DRM
- , public MAudioLoadingObserver
-#endif
{
Q_OBJECT
Q_INTERFACES(Phonon::MediaObjectInterface)
@@ -88,22 +62,6 @@ namespace Phonon
virtual qint32 transitionTime() const;
virtual void setTransitionTime(qint32);
-#ifdef QT_PHONON_MMF_AUDIO_DRM
- // MDrmAudioPlayerCallback
- virtual void MdapcInitComplete(TInt aError,
- const TTimeIntervalMicroSeconds &aDuration);
- virtual void MdapcPlayComplete(TInt aError);
-
- // MAudioLoadingObserver
- virtual void MaloLoadingStarted();
- virtual void MaloLoadingComplete();
-#else
- // MMdaAudioPlayerCallback
- virtual void MapcInitComplete(TInt aError,
- const TTimeIntervalMicroSeconds &aDuration);
- virtual void MapcPlayComplete(TInt aError);
-#endif
-
qreal volume() const;
bool setVolume(qreal volume);
@@ -115,64 +73,6 @@ namespace Phonon
Phonon::State newState);
void finished();
void tick(qint64 time);
-
- private Q_SLOTS:
- /**
- * Receives signal from m_tickTimer
- */
- void tick();
-
- private:
- static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &);
-
- /**
- * Defined private state enumeration in order to add GroundState
- */
- enum PrivateState
- {
- LoadingState = Phonon::LoadingState,
- StoppedState = Phonon::StoppedState,
- PlayingState = Phonon::PlayingState,
- BufferingState = Phonon::BufferingState,
- PausedState = Phonon::PausedState,
- ErrorState = Phonon::ErrorState,
- GroundState
- };
-
- /**
- * Converts PrivateState into the corresponding Phonon::State
- */
- static Phonon::State phononState(PrivateState state);
-
- /**
- * Changes state and emits stateChanged()
- */
- void changeState(PrivateState newState);
-
- /**
- * Using CPlayerType typedef in order to be able to easily switch between
- * CMdaAudioPlayerUtility and CDrmPlayerUtility
- */
- CPlayerType* m_player;
-
- AudioOutput* m_audioOutput;
-
- ErrorType m_error;
-
- /**
- * Do not set this directly - call changeState() instead.
- */
- PrivateState m_state;
-
- qint32 m_tickInterval;
-
- QTimer* m_tickTimer;
-
- MediaSource m_mediaSource;
- MediaSource m_nextSource;
-
- qreal m_volume;
- int m_maxVolume;
};
}
}
diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp
new file mode 100644
index 0000000..3a51070
--- /dev/null
+++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp
@@ -0,0 +1,577 @@
+/* This file is part of the KDE project.
+
+Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+
+This library is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 2.1 or 3 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include <QUrl>
+#include <QTimer>
+#include <private/qcore_symbian_p.h>
+
+#include "mmf_videoplayer.h"
+#include "audiooutput.h"
+#include "utils.h"
+
+using namespace Phonon;
+using namespace Phonon::MMF;
+
+//-----------------------------------------------------------------------------
+// Constants
+//-----------------------------------------------------------------------------
+
+const qint32 DefaultTickInterval = 20;
+const int NullMaxVolume = -1;
+
+
+//-----------------------------------------------------------------------------
+// Constructor / destructor
+//-----------------------------------------------------------------------------
+
+MMF::VideoPlayer::VideoPlayer(QObject *parent) : m_audioOutput(NULL)
+ , m_error(NoError)
+ , m_state(GroundState)
+ , m_tickInterval(DefaultTickInterval)
+ , m_tickTimer(NULL)
+ , m_volume(0.0)
+ , m_maxVolume(NullMaxVolume)
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::VideoPlayer, EAudioApi);
+ TRACE_ENTRY_0();
+
+ Q_UNUSED(parent);
+
+ // TODO: should leaves be trapped in the constructor?
+ m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone);
+
+ m_tickTimer = new QTimer(this);
+ connect(m_tickTimer, SIGNAL(timeout()), this, SLOT(tick()));
+
+ TRACE_EXIT_0();
+#endif
+}
+
+MMF::VideoPlayer::~VideoPlayer()
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EAudioApi);
+ TRACE_ENTRY_0();
+
+ delete m_tickTimer;
+ delete m_player;
+
+ TRACE_EXIT_0();
+#endif
+}
+
+//-----------------------------------------------------------------------------
+// VideoPlayerInterface
+//-----------------------------------------------------------------------------
+
+void MMF::VideoPlayer::play()
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::play, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ switch(m_state)
+ {
+ case GroundState:
+ case LoadingState:
+ // Is this the correct error? Really we want 'NotReadyError'
+ m_error = NormalError;
+ changeState(ErrorState);
+ break;
+
+ case StoppedState:
+ case PausedState:
+ m_player->Play();
+ m_tickTimer->start(m_tickInterval);
+ changeState(PlayingState);
+ break;
+
+ case PlayingState:
+ case BufferingState:
+ case ErrorState:
+ // Do nothing
+ break;
+
+ // Protection against adding new states and forgetting to update this switch
+ default:
+ TRACE_PANIC(InvalidStatePanic);
+ }
+
+ TRACE_EXIT("state %d", m_state);
+#endif
+}
+
+void MMF::VideoPlayer::pause()
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::pause, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ switch(m_state)
+ {
+ case GroundState:
+ case LoadingState:
+ case StoppedState:
+ case PausedState:
+ case ErrorState:
+ // Do nothing
+ break;
+
+ case PlayingState:
+ case BufferingState:
+ m_player->Pause();
+ m_tickTimer->stop();
+ changeState(PausedState);
+ break;
+
+ // Protection against adding new states and forgetting to update this switch
+ default:
+ TRACE_PANIC(InvalidStatePanic);
+ }
+
+ TRACE_EXIT("state %d", m_state);
+#endif
+}
+
+void MMF::VideoPlayer::stop()
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::stop, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ switch(m_state)
+ {
+ case GroundState:
+ case LoadingState:
+ case StoppedState:
+ case ErrorState:
+ // Do nothing
+ break;
+
+ case PlayingState:
+ case BufferingState:
+ case PausedState:
+ m_player->Stop();
+ m_tickTimer->stop();
+ changeState(StoppedState);
+ break;
+
+ // Protection against adding new states and forgetting to update this switch
+ default:
+ TRACE_PANIC(InvalidStatePanic);
+ }
+
+ TRACE_EXIT("state %d", m_state);
+#endif
+}
+
+void MMF::VideoPlayer::seek(qint64 ms)
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::seek, EAudioApi);
+ TRACE_ENTRY("state %d pos %Ld", m_state, ms);
+
+ m_player->SetPosition(TTimeIntervalMicroSeconds(ms));
+
+ TRACE_EXIT_0();
+#endif
+}
+
+qint32 MMF::VideoPlayer::tickInterval() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::tickInterval, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TRACE_RETURN("%d", m_tickInterval);
+#endif
+}
+
+void MMF::VideoPlayer::setTickInterval(qint32 interval)
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::setTickInterval, EAudioApi);
+ TRACE_ENTRY("state %d m_interval %d interval %d", m_state, m_tickInterval, interval);
+
+ m_tickInterval = interval;
+ m_tickTimer->setInterval(interval);
+
+ TRACE_EXIT_0();
+#endif
+}
+
+bool MMF::VideoPlayer::hasVideo() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::hasVideo, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ // TODO: re-factor this class so that audio playback and video playback are
+ // delegated to separate classes, which internally hoat a
+ // CMdaVideoPlayerUtility / CVideoPlayerUtility instance as appropriate.
+
+ TRACE_RETURN("%d", false);
+#endif
+}
+
+bool MMF::VideoPlayer::isSeekable() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::isSeekable, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TRACE_RETURN("%d", true);
+#endif
+}
+
+Phonon::State MMF::VideoPlayer::state() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::state, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ const Phonon::State result = phononState(m_state);
+
+ TRACE_RETURN("%d", result);
+#endif
+}
+
+qint64 MMF::VideoPlayer::currentTime() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::currentTime, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TTimeIntervalMicroSeconds us;
+ const TInt err = m_player->GetPosition(us);
+
+ qint64 result = -1;
+
+ if(KErrNone == err) {
+ result = toMilliSeconds(us);
+ }
+
+ TRACE_RETURN("%Ld", result);
+#endif
+}
+
+QString MMF::VideoPlayer::errorString() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::errorString, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TRACE_EXIT_0();
+ // TODO: put in proper error strings
+ QString result;
+ return result;
+#endif
+}
+
+Phonon::ErrorType MMF::VideoPlayer::errorType() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::errorType, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ const Phonon::ErrorType result = (ErrorState == m_state)
+ ? m_error : NoError;
+
+ TRACE_RETURN("%d", result);
+#endif
+}
+
+qint64 MMF::VideoPlayer::totalTime() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::totalTime, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ const qint64 result = toMilliSeconds(m_player->Duration());
+
+ TRACE_RETURN("%Ld", result);
+#endif
+}
+
+MediaSource MMF::VideoPlayer::source() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::source, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ TRACE_EXIT_0();
+ return m_mediaSource;
+#endif
+}
+
+void MMF::VideoPlayer::setSource(const MediaSource &source)
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::setSource, EAudioApi);
+ TRACE_ENTRY("state %d source.type %d", m_state, source.type());
+
+ m_player->Close();
+ changeState(GroundState);
+
+ // TODO: is it correct to assign even if the media type is not supported in
+ // the switch statement below?
+ m_mediaSource = source;
+
+ TInt symbianErr = KErrNone;
+
+ switch(m_mediaSource.type())
+ {
+ case MediaSource::LocalFile:
+ {
+ // TODO: work out whose responsibility it is to ensure that paths
+ // are Symbian-style, i.e. have backslashes for path delimiters.
+ // Until then, use this utility function...
+ const QHBufC filename = Utils::symbianFilename(m_mediaSource.fileName());
+ TRAP(symbianErr, m_player->OpenFileL(*filename));
+ break;
+ }
+
+ case MediaSource::Url:
+ {
+ const QHBufC filename(m_mediaSource.url().toString());
+ TRAP(symbianErr, m_player->OpenUrlL(*filename));
+ break;
+ }
+
+ case MediaSource::Invalid:
+ case MediaSource::Disc:
+ case MediaSource::Stream:
+ symbianErr = KErrNotSupported;
+ break;
+
+ case MediaSource::Empty:
+ TRACE_EXIT_0();
+ return;
+
+ // Protection against adding new media types and forgetting to update this switch
+ default:
+ TRACE_PANIC(InvalidMediaTypePanic);
+ }
+
+ if(KErrNone == symbianErr)
+ {
+#ifdef QT_PHONON_MMF_AUDIO_DRM
+ // There appears to be a bug in the CDrmPlayerUtility implementation (at least
+ // in S60 5.x) whereby the player does not check whether the loading observer
+ // pointer is null before dereferencing it. Therefore we must register for
+ // loading notification, even though we do nothing in the callback functions.
+ m_player->RegisterForAudioLoadingNotification(*this);
+#endif
+ changeState(LoadingState);
+ }
+ else
+ {
+ // TODO: do something with the value of symbianErr?
+ m_error = NormalError;
+ changeState(ErrorState);
+ }
+
+ TRACE_EXIT_0();
+#endif
+}
+
+void MMF::VideoPlayer::setNextSource(const MediaSource &source)
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::setNextSource, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ // TODO: handle 'next source'
+
+ m_nextSource = source;
+ Q_UNUSED(source);
+
+ TRACE_EXIT_0();
+#endif
+}
+
+qint32 MMF::VideoPlayer::prefinishMark() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::prefinishMark, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ // TODO: implement prefinish mark
+ const qint32 result = 0;
+ TRACE_RETURN("%d", result);
+#endif
+}
+
+void MMF::VideoPlayer::setPrefinishMark(qint32 mark)
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::setPrefinishMark, EAudioApi);
+ TRACE_ENTRY("state %d mark %d", m_state, mark);
+ Q_UNUSED(mark); // to silence warnings in release builds
+
+ // TODO: implement prefinish mark
+
+ TRACE_EXIT_0();
+#endif
+}
+
+qint32 MMF::VideoPlayer::transitionTime() const
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::transitionTime, EAudioApi);
+ TRACE_ENTRY("state %d", m_state);
+
+ // TODO: implement transition time
+ const qint32 result = 0;
+ TRACE_RETURN("%d", result);
+#endif
+}
+
+void MMF::VideoPlayer::setTransitionTime(qint32 time)
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::setTransitionTime, EAudioApi);
+ TRACE_ENTRY("state %d time %d", m_state, time);
+ Q_UNUSED(time); // to silence warnings in release builds
+
+ // TODO: implement transition time
+
+ TRACE_EXIT_0();
+#endif
+}
+
+
+//-----------------------------------------------------------------------------
+// Volume
+//-----------------------------------------------------------------------------
+
+qreal MMF::VideoPlayer::volume() const
+{
+ //return m_volume;
+}
+
+bool MMF::VideoPlayer::setVolume(qreal volume)
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::setVolume, EAudioInternal);
+ TRACE_ENTRY("state %d", m_state);
+
+ bool volumeChanged = false;
+
+ switch(m_state)
+ {
+ case GroundState:
+ case LoadingState:
+ case ErrorState:
+ // Do nothing
+ break;
+
+ case StoppedState:
+ case PausedState:
+ case PlayingState:
+ case BufferingState:
+ {
+ if(volume != m_volume)
+ {
+ const int err = m_player->SetVolume(volume * m_maxVolume);
+ if(KErrNone == err)
+ {
+ m_volume = volume;
+ volumeChanged = true;
+ }
+ else
+ {
+ m_error = NormalError;
+ changeState(ErrorState);
+ }
+ }
+ break;
+ }
+
+ // Protection against adding new states and forgetting to update this
+ // switch
+ default:
+ TRACE_PANIC(InvalidStatePanic);
+ }
+
+ TRACE_RETURN("%d", volumeChanged);
+#endif
+}
+
+void MMF::VideoPlayer::setAudioOutput(AudioOutput* audioOutput)
+{
+ //m_audioOutput = audioOutput;
+}
+
+
+//-----------------------------------------------------------------------------
+// Private functions
+//-----------------------------------------------------------------------------
+
+qint64 MMF::VideoPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds &in)
+{
+ //return in.Int64() / 1000;
+}
+
+Phonon::State MMF::VideoPlayer::phononState(PrivateState state)
+{
+#if 0
+ const Phonon::State phononState =
+ GroundState == state
+ ? Phonon::StoppedState
+ : static_cast<Phonon::State>(state);
+
+ return phononState;
+#endif
+}
+
+void MMF::VideoPlayer::changeState(PrivateState newState)
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::changeState, EAudioInternal);
+ TRACE_ENTRY("state %d newState %d", m_state, newState);
+
+ // TODO: add some invariants to check that the transition is valid
+
+ const Phonon::State currentPhononState = phononState(m_state);
+ const Phonon::State newPhononState = phononState(newState);
+ if(currentPhononState != newPhononState)
+ {
+ TRACE("emit stateChanged(%d, %d)", newPhononState, currentPhononState);
+ emit stateChanged(newPhononState, currentPhononState);
+ }
+
+ m_state = newState;
+
+ TRACE_EXIT_0();
+#endif
+}
+
+void MMF::VideoPlayer::tick()
+{
+#if 0
+ TRACE_CONTEXT(VideoPlayer::tick, EAudioInternal);
+ TRACE_ENTRY("state %d", m_state);
+
+ emit tick(currentTime());
+
+ TRACE_EXIT_0();
+#endif
+}
+
diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h
new file mode 100644
index 0000000..3b0cd98
--- /dev/null
+++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h
@@ -0,0 +1,163 @@
+/* This file is part of the KDE project.
+
+Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+
+This library is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 2.1 or 3 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef PHONON_MMF_VIDEOPLAYER_H
+#define PHONON_MMF_VIDEOPLAYER_H
+
+/* We use the extra qualification include/ to avoid picking up the include
+ * Phonon has. */
+#include <include/videoplayer.h>
+#include "abstractplayer.h"
+
+#include <Phonon/MediaSource>
+
+class CDrmPlayerUtility;
+class TTimeIntervalMicroSeconds;
+class QTimer;
+
+namespace Phonon
+{
+ namespace MMF
+ {
+ class AudioOutput;
+
+ /**
+ *
+ * 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 AbstractPlayer
+ {
+ Q_OBJECT
+ public:
+ VideoPlayer(QObject *parent);
+ virtual ~VideoPlayer();
+
+ // AbstractPlayer
+ virtual void play();
+ virtual void pause();
+ virtual void stop();
+ virtual void seek(qint64 milliseconds);
+ virtual qint32 tickInterval() const;
+ virtual void setTickInterval(qint32 interval);
+ virtual bool hasVideo() const;
+ virtual bool isSeekable() const;
+ virtual qint64 currentTime() const;
+ virtual Phonon::State state() const;
+ virtual QString errorString() const;
+ virtual Phonon::ErrorType errorType() const;
+ virtual qint64 totalTime() const;
+ virtual MediaSource source() const;
+ virtual void setSource(const MediaSource &);
+ virtual void setNextSource(const MediaSource &source);
+ virtual qint32 prefinishMark() const;
+ virtual void setPrefinishMark(qint32);
+ virtual qint32 transitionTime() const;
+ virtual void setTransitionTime(qint32);
+
+#ifdef QT_PHONON_MMF_AUDIO_DRM
+ // MDrmVideoPlayerCallback
+ virtual void MdapcInitComplete(TInt aError,
+ const TTimeIntervalMicroSeconds &aDuration);
+ virtual void MdapcPlayComplete(TInt aError);
+
+ // MAudioLoadingObserver
+ virtual void MaloLoadingStarted();
+ virtual void MaloLoadingComplete();
+#else
+ // MMdaVideoPlayerCallback
+ virtual void MapcInitComplete(TInt aError,
+ const TTimeIntervalMicroSeconds &aDuration);
+ virtual void MapcPlayComplete(TInt aError);
+#endif
+
+ qreal volume() const;
+ bool setVolume(qreal volume);
+
+ void setAudioOutput(AudioOutput* audioOutput);
+
+ Q_SIGNALS:
+ void totalTimeChanged();
+ void stateChanged(Phonon::State oldState,
+ Phonon::State newState);
+ void finished();
+ void tick(qint64 time);
+
+ private Q_SLOTS:
+ /**
+ * Receives signal from m_tickTimer
+ */
+ void tick();
+
+ private:
+ static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &);
+
+ /**
+ * Defined private state enumeration in order to add GroundState
+ */
+ enum PrivateState
+ {
+ LoadingState = Phonon::LoadingState,
+ StoppedState = Phonon::StoppedState,
+ PlayingState = Phonon::PlayingState,
+ BufferingState = Phonon::BufferingState,
+ PausedState = Phonon::PausedState,
+ ErrorState = Phonon::ErrorState,
+ GroundState
+ };
+
+ /**
+ * Converts PrivateState into the corresponding Phonon::State
+ */
+ static Phonon::State phononState(PrivateState state);
+
+ /**
+ * Changes state and emits stateChanged()
+ */
+ void changeState(PrivateState newState);
+
+ /**
+ * Using CPlayerType typedef in order to be able to easily switch between
+ * CMdaVideoPlayerUtility and CDrmPlayerUtility
+ */
+ // CPlayerType* m_player; TODO
+
+ AudioOutput* m_audioOutput;
+
+ ErrorType m_error;
+
+ /**
+ * Do not set this directly - call changeState() instead.
+ */
+ PrivateState m_state;
+
+ qint32 m_tickInterval;
+
+ QTimer* m_tickTimer;
+
+ MediaSource m_mediaSource;
+ MediaSource m_nextSource;
+
+ qreal m_volume;
+ int m_maxVolume;
+ };
+ }
+}
+
+#endif
diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro
index ee2d3f9..266c3db 100644
--- a/src/plugins/phonon/mmf/mmf.pro
+++ b/src/plugins/phonon/mmf/mmf.pro
@@ -21,17 +21,22 @@ phonon_mmf_audio_drm {
LIBS += -lmediaclientaudio.lib
}
-HEADERS += \
- $$PHONON_MMF_DIR/audiooutput.h \
- $$PHONON_MMF_DIR/backend.h \
- $$PHONON_MMF_DIR/mediaobject.h \
- $$PHONON_MMF_DIR/utils.h
-
-SOURCES += \
- $$PHONON_MMF_DIR/audiooutput.cpp \
- $$PHONON_MMF_DIR/backend.cpp \
- $$PHONON_MMF_DIR/mediaobject.cpp \
- $$PHONON_MMF_DIR/utils.cpp
+HEADERS += \
+ $$PHONON_MMF_DIR/abstractplayer.h \
+ $$PHONON_MMF_DIR/audiooutput.h \
+ $$PHONON_MMF_DIR/audioplayer.h \
+ $$PHONON_MMF_DIR/backend.h \
+ $$PHONON_MMF_DIR/mediaobject.h \
+ $$PHONON_MMF_DIR/utils.h \
+ $$PHONON_MMF_DIR/mmf_videoplayer.h
+
+SOURCES += \
+ $$PHONON_MMF_DIR/audiooutput.cpp \
+ $$PHONON_MMF_DIR/audioplayer.cpp \
+ $$PHONON_MMF_DIR/backend.cpp \
+ $$PHONON_MMF_DIR/mediaobject.cpp \
+ $$PHONON_MMF_DIR/utils.cpp \
+ $$PHONON_MMF_DIR/mmf_videoplayer.cpp
# This is needed for having the .qtplugin file properly created on Symbian.
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend