summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/3rdparty/phonon/mmf/abstractmediaplayer.cpp148
-rw-r--r--src/3rdparty/phonon/mmf/abstractmediaplayer.h17
-rw-r--r--src/3rdparty/phonon/mmf/abstractvideoplayer.cpp24
-rw-r--r--src/3rdparty/phonon/mmf/abstractvideoplayer.h5
-rw-r--r--src/3rdparty/phonon/mmf/audioplayer.cpp18
-rw-r--r--src/3rdparty/phonon/mmf/audioplayer.h5
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.cpp36
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.h1
8 files changed, 211 insertions, 43 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
index 3702560..a728423 100644
--- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
+++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
@@ -51,10 +51,13 @@ MMF::AbstractMediaPlayer::AbstractMediaPlayer
, m_parent(parent)
, m_pending(NothingPending)
, m_positionTimer(new QTimer(this))
+ , m_position(0)
, m_bufferStatusTimer(new QTimer(this))
, m_mmfMaxVolume(NullMaxVolume)
, m_prefinishMarkSent(false)
, m_aboutToFinishSent(false)
+ , m_download(0)
+ , m_downloadStalled(false)
{
connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick()));
connect(m_bufferStatusTimer.data(), SIGNAL(timeout()), this, SLOT(bufferStatusTick()));
@@ -183,6 +186,7 @@ void MMF::AbstractMediaPlayer::seek(qint64 ms)
}
doSeek(ms);
+ m_position = ms;
resetMarksIfRewound();
if(wasPlaying && state() != ErrorState) {
@@ -207,6 +211,11 @@ bool MMF::AbstractMediaPlayer::isSeekable() const
return true;
}
+qint64 MMF::AbstractMediaPlayer::currentTime() const
+{
+ return m_position;
+}
+
void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval)
{
TRACE_CONTEXT(AbstractMediaPlayer::doSetTickInterval, EAudioApi);
@@ -247,6 +256,14 @@ void MMF::AbstractMediaPlayer::open()
symbianErr = openFile(*file);
if (KErrNone != symbianErr)
errorMessage = tr("Error opening file");
+ } else if (url.scheme() == QLatin1String("http")) {
+ Q_ASSERT(!m_download);
+ m_download = new Download(url, this);
+ connect(m_download, SIGNAL(lengthChanged(qint64)),
+ this, SLOT(downloadLengthChanged(qint64)));
+ connect(m_download, SIGNAL(stateChanged(Download::State)),
+ this, SLOT(downloadStateChanged(Download::State)));
+ m_download->start();
} else {
symbianErr = openUrl(url.toString());
if (KErrNone != symbianErr)
@@ -288,6 +305,14 @@ void MMF::AbstractMediaPlayer::open()
TRACE_EXIT_0();
}
+void MMF::AbstractMediaPlayer::close()
+{
+ doClose();
+ delete m_download;
+ m_download = 0;
+ m_position = 0;
+}
+
void MMF::AbstractMediaPlayer::volumeChanged(qreal volume)
{
TRACE_CONTEXT(AbstractMediaPlayer::volumeChanged, EAudioInternal);
@@ -374,7 +399,8 @@ void MMF::AbstractMediaPlayer::bufferingComplete()
{
stopBufferStatusTimer();
emit MMF::AbstractPlayer::bufferStatus(100);
- changeState(m_stateBeforeBuffering);
+ if (!progressiveDownloadStalled())
+ changeState(m_stateBeforeBuffering);
}
void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume)
@@ -385,13 +411,28 @@ void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume)
void MMF::AbstractMediaPlayer::loadingComplete(int error)
{
- Q_ASSERT(Phonon::LoadingState == state());
-
- if (KErrNone == error) {
- updateMetaData();
- changeState(StoppedState);
+ TRACE_CONTEXT(AbstractMediaPlayer::loadingComplete, EAudioApi);
+ TRACE_ENTRY("state %d error %d", state(), error);
+ if (progressiveDownloadStalled()) {
+ Q_ASSERT(Phonon::BufferingState == state());
+ if (KErrNone == error) {
+ bufferingComplete();
+ doSeek(m_position);
+ startPlayback();
+ m_downloadStalled = false;
+ }
} else {
- setError(tr("Loading clip failed"), error);
+ Q_ASSERT(Phonon::LoadingState == state());
+ if (KErrNone == error) {
+ updateMetaData();
+ changeState(StoppedState);
+ } else {
+ if (isProgressiveDownload() && KErrCorrupt == error) {
+ setProgressiveDownloadStalled();
+ } else {
+ setError(tr("Loading clip failed"), error);
+ }
+ }
}
}
@@ -415,8 +456,12 @@ void MMF::AbstractMediaPlayer::playbackComplete(int error)
QMetaObject::invokeMethod(m_parent, "switchToNextSource", Qt::QueuedConnection);
}
else {
- setError(tr("Playback complete"), error);
- emit finished();
+ if (isProgressiveDownload() && KErrCorrupt == error) {
+ setProgressiveDownloadStalled();
+ } else {
+ setError(tr("Playback complete"), error);
+ emit finished();
+ }
}
}
@@ -425,15 +470,28 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds
return in.Int64() / 1000;
}
+bool MMF::AbstractMediaPlayer::isProgressiveDownload() const
+{
+ return (0 != m_download);
+}
+
+bool MMF::AbstractMediaPlayer::progressiveDownloadStalled() const
+{
+ return m_downloadStalled;
+}
+
//-----------------------------------------------------------------------------
// Slots
//-----------------------------------------------------------------------------
void MMF::AbstractMediaPlayer::positionTick()
{
- const qint64 current = currentTime();
- emitMarksIfReached(current);
- emit MMF::AbstractPlayer::tick(current);
+ const qint64 pos = getCurrentTime();
+ if (pos > m_position) {
+ m_position = pos;
+ emitMarksIfReached(m_position);
+ emit MMF::AbstractPlayer::tick(m_position);
+ }
}
void MMF::AbstractMediaPlayer::emitMarksIfReached(qint64 current)
@@ -458,7 +516,7 @@ void MMF::AbstractMediaPlayer::emitMarksIfReached(qint64 current)
void MMF::AbstractMediaPlayer::resetMarksIfRewound()
{
- const qint64 current = currentTime();
+ const qint64 current = getCurrentTime();
const qint64 total = totalTime();
const qint64 remaining = total - current;
@@ -487,9 +545,71 @@ void MMF::AbstractMediaPlayer::startPlayback()
changeState(PlayingState);
}
+void MMF::AbstractMediaPlayer::setProgressiveDownloadStalled()
+{
+ TRACE_CONTEXT(AbstractMediaPlayer::setProgressiveDownloadStalled, EAudioApi);
+ TRACE_ENTRY("state %d", state());
+ Q_ASSERT(isProgressiveDownload());
+ m_downloadStalled = true;
+ doClose();
+ bufferingStarted();
+ // Video player loses window handle when closed - need to reapply it here
+ videoOutputChanged();
+#ifdef QT_PHONON_MMF_DOWNLOAD_DUMMY
+ m_download->resume();
+#endif
+}
+
void MMF::AbstractMediaPlayer::bufferStatusTick()
{
- emit MMF::AbstractPlayer::bufferStatus(bufferStatus());
+ // During progressive download, there is no way to detect the buffering status.
+ // Phonon does not support a "buffering; amount unknown" signal, therefore we
+ // return a buffering status of zero.
+ const int status = progressiveDownloadStalled() ? 0 : bufferStatus();
+ emit MMF::AbstractPlayer::bufferStatus(status);
+}
+
+void MMF::AbstractMediaPlayer::downloadLengthChanged(qint64 length)
+{
+ TRACE_CONTEXT(AbstractMediaPlayer::downloadLengthChanged, EAudioApi);
+ TRACE_ENTRY("length %Ld", length);
+ Q_UNUSED(length)
+ if (m_downloadStalled) {
+ bufferingComplete();
+ int err = m_parent->openFileHandle(m_download->targetFileName());
+ if (KErrNone == err)
+ err = openFile(*m_parent->file());
+ if (KErrNone != err)
+ setError(tr("Error opening file"));
+ }
+}
+
+void MMF::AbstractMediaPlayer::downloadStateChanged(Download::State state)
+{
+ TRACE_CONTEXT(AbstractMediaPlayer::downloadStateChanged, EAudioApi);
+ TRACE_ENTRY("state %d", state);
+ switch (state) {
+ case Download::Idle:
+ case Download::Initializing:
+ break;
+ case Download::Downloading:
+ {
+ int err = m_parent->openFileHandle(m_download->targetFileName());
+ if (KErrNone == err)
+ err = openFile(*m_parent->file());
+ else if (KErrCorrupt == err)
+ // Insufficient data downloaded - enter Buffering state
+ setProgressiveDownloadStalled();
+ if (KErrNone != err)
+ setError(tr("Error opening file"));
+ }
+ break;
+ case Download::Complete:
+ break;
+ case Download::Error:
+ setError(tr("Download error"));
+ break;
+ }
}
Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) const
diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h
index e795ecb..99fc101 100644
--- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h
+++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h
@@ -23,6 +23,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <QScopedPointer>
#include <e32std.h>
#include "abstractplayer.h"
+#include "download.h"
class RFile;
@@ -48,6 +49,7 @@ protected:
public:
virtual void open();
+ virtual void close();
// MediaObjectInterface
virtual void play();
@@ -55,6 +57,7 @@ public:
virtual void stop();
virtual void seek(qint64 milliseconds);
virtual bool isSeekable() const;
+ virtual qint64 currentTime() const;
virtual void volumeChanged(qreal volume);
protected:
@@ -68,12 +71,15 @@ protected:
virtual void doStop() = 0;
virtual void doSeek(qint64 pos) = 0;
virtual int setDeviceVolume(int mmfVolume) = 0;
+ virtual int openFile(const QString &fileName) = 0;
virtual int openFile(RFile& file) = 0;
virtual int openUrl(const QString& url) = 0;
virtual int openDescriptor(const TDesC8 &des) = 0;
virtual int bufferStatus() const = 0;
+ virtual void doClose() = 0;
void updateMetaData();
+ virtual qint64 getCurrentTime() const = 0;
virtual int numberOfMetaDataEntries() const = 0;
virtual QPair<QString, QString> metaDataEntry(int index) const = 0;
@@ -86,6 +92,9 @@ protected:
static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &);
+ bool isProgressiveDownload() const;
+ bool progressiveDownloadStalled() const;
+
private:
void startPositionTimer();
void stopPositionTimer();
@@ -96,6 +105,7 @@ private:
void emitMarksIfReached(qint64 position);
void resetMarksIfRewound();
void startPlayback();
+ void setProgressiveDownloadStalled();
enum Pending {
NothingPending,
@@ -108,6 +118,8 @@ private:
private Q_SLOTS:
void positionTick();
void bufferStatusTick();
+ void downloadLengthChanged(qint64);
+ void downloadStateChanged(Download::State);
private:
MediaObject *const m_parent;
@@ -115,6 +127,7 @@ private:
Pending m_pending;
QScopedPointer<QTimer> m_positionTimer;
+ qint64 m_position;
QScopedPointer<QTimer> m_bufferStatusTimer;
PrivateState m_stateBeforeBuffering;
@@ -127,6 +140,10 @@ private:
// Used for playback of resource files
TPtrC8 m_buffer;
+ // Used for progressive download
+ Download *m_download;
+ bool m_downloadStalled;
+
QMultiMap<QString, QString> m_metaData;
};
diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
index fb20bea..1ab5bae 100644
--- a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
+++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
@@ -16,6 +16,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <QDir>
#include <QUrl>
#include <QTimer>
#include <QWidget>
@@ -132,6 +133,13 @@ int MMF::AbstractVideoPlayer::setDeviceVolume(int mmfVolume)
return err;
}
+int MMF::AbstractVideoPlayer::openFile(const QString &fileName)
+{
+ const QHBufC nativeFileName(QDir::toNativeSeparators(fileName));
+ TRAPD(err, m_player->OpenFileL(*nativeFileName));
+ return err;
+}
+
int MMF::AbstractVideoPlayer::openFile(RFile &file)
{
TRAPD(err, m_player->OpenFileL(file));
@@ -157,7 +165,7 @@ int MMF::AbstractVideoPlayer::bufferStatus() const
return result;
}
-void MMF::AbstractVideoPlayer::close()
+void MMF::AbstractVideoPlayer::doClose()
{
m_player->Close();
}
@@ -167,9 +175,9 @@ bool MMF::AbstractVideoPlayer::hasVideo() const
return true;
}
-qint64 MMF::AbstractVideoPlayer::currentTime() const
+qint64 MMF::AbstractVideoPlayer::getCurrentTime() const
{
- TRACE_CONTEXT(AbstractVideoPlayer::currentTime, EVideoApi);
+ TRACE_CONTEXT(AbstractVideoPlayer::getCurrentTime, EVideoApi);
TTimeIntervalMicroSeconds us;
TRAPD(err, us = m_player->PositionL())
@@ -246,7 +254,9 @@ void MMF::AbstractVideoPlayer::MvpuoOpenComplete(TInt aError)
TRACE_CONTEXT(AbstractVideoPlayer::MvpuoOpenComplete, EVideoApi);
TRACE_ENTRY("state %d error %d", state(), aError);
- __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic));
+ __ASSERT_ALWAYS(LoadingState == state() ||
+ progressiveDownloadStalled() && BufferingState == state(),
+ Utils::panic(InvalidStatePanic));
if (KErrNone == aError)
m_player->Prepare();
@@ -261,7 +271,9 @@ void MMF::AbstractVideoPlayer::MvpuoPrepareComplete(TInt aError)
TRACE_CONTEXT(AbstractVideoPlayer::MvpuoPrepareComplete, EVideoApi);
TRACE_ENTRY("state %d error %d", state(), aError);
- __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic));
+ __ASSERT_ALWAYS(LoadingState == state() ||
+ progressiveDownloadStalled() && BufferingState == state(),
+ Utils::panic(InvalidStatePanic));
TRAPD(err, getVideoClipParametersL(aError));
@@ -470,7 +482,7 @@ void MMF::AbstractVideoPlayer::updateScaleFactors(const QSize &windowSize, bool
void MMF::AbstractVideoPlayer::parametersChanged(VideoParameters parameters)
{
- if (state() == LoadingState)
+ if (state() == LoadingState || progressiveDownloadStalled() && BufferingState == state())
m_pendingChanges |= parameters;
else
handleParametersChanged(parameters);
diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.h b/src/3rdparty/phonon/mmf/abstractvideoplayer.h
index 3ff3c75..3bc5c7c 100644
--- a/src/3rdparty/phonon/mmf/abstractvideoplayer.h
+++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.h
@@ -64,21 +64,22 @@ public:
virtual void doStop();
virtual void doSeek(qint64 milliseconds);
virtual int setDeviceVolume(int mmfVolume);
+ virtual int openFile(const QString &fileName);
virtual int openFile(RFile &file);
virtual int openUrl(const QString &url);
virtual int openDescriptor(const TDesC8 &des);
virtual int bufferStatus() const;
- virtual void close();
+ virtual void doClose();
// MediaObjectInterface
virtual bool hasVideo() const;
- virtual qint64 currentTime() const;
virtual qint64 totalTime() const;
// AbstractPlayer
virtual void videoOutputChanged();
// AbstractMediaPlayer
+ virtual qint64 getCurrentTime() const;
virtual int numberOfMetaDataEntries() const;
virtual QPair<QString, QString> metaDataEntry(int index) const;
diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp
index 7c8b9bd..dc5c800 100644
--- a/src/3rdparty/phonon/mmf/audioplayer.cpp
+++ b/src/3rdparty/phonon/mmf/audioplayer.cpp
@@ -16,6 +16,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <QDir>
#include <QUrl>
#include "audioplayer.h"
@@ -109,6 +110,13 @@ int MMF::AudioPlayer::setDeviceVolume(int mmfVolume)
#endif
}
+int MMF::AudioPlayer::openFile(const QString &fileName)
+{
+ const QHBufC nativeFileName(QDir::toNativeSeparators(fileName));
+ TRAPD(err, m_player->OpenFileL(*nativeFileName));
+ return err;
+}
+
int MMF::AudioPlayer::openFile(RFile& file)
{
TRAPD(err, m_player->OpenFileL(file));
@@ -150,7 +158,7 @@ int MMF::AudioPlayer::bufferStatus() const
return result;
}
-void MMF::AudioPlayer::close()
+void MMF::AudioPlayer::doClose()
{
m_player->Close();
}
@@ -160,9 +168,9 @@ bool MMF::AudioPlayer::hasVideo() const
return false;
}
-qint64 MMF::AudioPlayer::currentTime() const
+qint64 MMF::AudioPlayer::getCurrentTime() const
{
- TRACE_CONTEXT(AudioPlayer::currentTime, EAudioApi);
+ TRACE_CONTEXT(AudioPlayer::getCurrentTime, EAudioApi);
TTimeIntervalMicroSeconds us;
const TInt err = m_player->GetPosition(us);
@@ -203,7 +211,9 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError,
TRACE_CONTEXT(AudioPlayer::MapcInitComplete, EAudioInternal);
TRACE_ENTRY("state %d error %d", state(), aError);
- __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic));
+ __ASSERT_ALWAYS(LoadingState == state() ||
+ progressiveDownloadStalled() && BufferingState == state(),
+ Utils::panic(InvalidStatePanic));
if (KErrNone == aError) {
maxVolumeChanged(m_player->MaxVolume());
diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h
index e43cadd..cf4f6d5 100644
--- a/src/3rdparty/phonon/mmf/audioplayer.h
+++ b/src/3rdparty/phonon/mmf/audioplayer.h
@@ -65,18 +65,19 @@ typedef CMdaAudioPlayerUtility NativePlayer;
virtual void doStop();
virtual void doSeek(qint64 milliseconds);
virtual int setDeviceVolume(int mmfVolume);
+ virtual int openFile(const QString &fileName);
virtual int openFile(RFile& file);
virtual int openUrl(const QString& url);
virtual int openDescriptor(const TDesC8 &des);
virtual int bufferStatus() const;
- virtual void close();
+ virtual void doClose();
// MediaObjectInterface
virtual bool hasVideo() const;
- virtual qint64 currentTime() const;
virtual qint64 totalTime() const;
// AbstractMediaPlayer
+ virtual qint64 getCurrentTime() const;
virtual int numberOfMetaDataEntries() const;
virtual QPair<QString, QString> metaDataEntry(int index) const;
diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp
index 98326b8..2c7a7ef 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.cpp
+++ b/src/3rdparty/phonon/mmf/mediaobject.cpp
@@ -61,6 +61,9 @@ MMF::MediaObject::MediaObject(QObject *parent) : MMF::MediaNode::MediaNode(paren
TRACE_CONTEXT(MediaObject::MediaObject, EAudioApi);
TRACE_ENTRY_0();
+ const int err = m_fileServer.Connect();
+ QT_TRAP_THROWING(User::LeaveIfError(err));
+
Q_UNUSED(parent);
TRACE_EXIT_0();
@@ -99,12 +102,6 @@ bool MMF::MediaObject::openRecognizer()
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();
@@ -127,13 +124,8 @@ MMF::MediaType MMF::MediaObject::fileMediaType
MediaType result = MediaTypeUnknown;
if (openRecognizer()) {
-
- const QHBufC fileNameSymbian(QDir::toNativeSeparators(fileName));
-
- Q_ASSERT(!m_file);
- m_file = new RFile;
- TInt err = m_file->Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly);
-
+ TInt err = openFileHandle(fileName);
+ const QHBufC nativeFileName(QDir::toNativeSeparators(fileName));
if (KErrNone == err) {
TDataRecognitionResult recognizerResult;
err = m_recognizer.RecognizeData(*m_file, recognizerResult);
@@ -141,16 +133,30 @@ MMF::MediaType MMF::MediaObject::fileMediaType
const TPtrC mimeType = recognizerResult.iDataType.Des();
result = Utils::mimeTypeToMediaType(mimeType);
} else {
- TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err);
+ TRACE("RApaLsSession::RecognizeData filename %S error %d", nativeFileName.data(), err);
}
} else {
- TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err);
+ TRACE("RFile::Open filename %S error %d", nativeFileName.data(), err);
}
}
return result;
}
+int MMF::MediaObject::openFileHandle(const QString &fileName)
+{
+ TRACE_CONTEXT(MediaObject::openFileHandle, EAudioInternal);
+ const QHBufC nativeFileName(QDir::toNativeSeparators(fileName));
+ TRACE_ENTRY("filename %S", nativeFileName.data());
+ if (m_file)
+ m_file->Close();
+ delete m_file;
+ m_file = 0;
+ m_file = new RFile;
+ TInt err = m_file->Open(m_fileServer, *nativeFileName, EFileRead | EFileShareReadersOrWriters);
+ return err;
+}
+
MMF::MediaType MMF::MediaObject::bufferMediaType(const uchar *data, qint64 size)
{
TRACE_CONTEXT(MediaObject::bufferMediaType, EAudioInternal);
diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h
index 5399e27..5d785fb 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.h
+++ b/src/3rdparty/phonon/mmf/mediaobject.h
@@ -89,6 +89,7 @@ public:
void setVideoOutput(AbstractVideoOutput* videoOutput);
+ int openFileHandle(const QString &fileName);
RFile* file() const;
QResource* resource() const;