| 1 |
/* This file is part of the KDE project. |
| 2 |
|
| 3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
|
| 5 |
This library is free software: you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU Lesser General Public License as published by |
| 7 |
the Free Software Foundation, either version 2.1 or 3 of the License. |
| 8 |
|
| 9 |
This library is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU Lesser General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU Lesser General Public License |
| 15 |
along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef PHONON_MMF_AUDIOPLAYER_H |
| 20 |
#define PHONON_MMF_AUDIOPLAYER_H |
| 21 |
|
| 22 |
#include "abstractmediaplayer.h" |
| 23 |
|
| 24 |
class CDrmPlayerUtility; |
| 25 |
class TTimeIntervalMicroSeconds; |
| 26 |
|
| 27 |
#ifdef QT_PHONON_MMF_AUDIO_DRM |
| 28 |
#include <drmaudiosampleplayer.h> |
| 29 |
typedef MDrmAudioPlayerCallback NativePlayerObserver; |
| 30 |
#else |
| 31 |
#include <mdaaudiosampleplayer.h> |
| 32 |
typedef MMdaAudioPlayerCallback NativePlayerObserver; |
| 33 |
#endif |
| 34 |
|
| 35 |
QT_BEGIN_NAMESPACE |
| 36 |
|
| 37 |
namespace Phonon |
| 38 |
{ |
| 39 |
namespace MMF |
| 40 |
{ |
| 41 |
/** |
| 42 |
* @short Wrapper over MMF audio client utility |
| 43 |
*/ |
| 44 |
class AudioPlayer : public AbstractMediaPlayer |
| 45 |
, public NativePlayerObserver |
| 46 |
, public MAudioLoadingObserver |
| 47 |
{ |
| 48 |
Q_OBJECT |
| 49 |
|
| 50 |
public: |
| 51 |
AudioPlayer(MediaObject *parent = 0, const AbstractPlayer *player = 0); |
| 52 |
virtual ~AudioPlayer(); |
| 53 |
|
| 54 |
#ifdef QT_PHONON_MMF_AUDIO_DRM |
| 55 |
typedef CDrmPlayerUtility NativePlayer; |
| 56 |
#else |
| 57 |
typedef CMdaAudioPlayerUtility NativePlayer; |
| 58 |
#endif |
| 59 |
|
| 60 |
NativePlayer *nativePlayer() const; |
| 61 |
|
| 62 |
// AbstractMediaPlayer |
| 63 |
virtual void doPlay(); |
| 64 |
virtual void doPause(); |
| 65 |
virtual void doStop(); |
| 66 |
virtual void doSeek(qint64 milliseconds); |
| 67 |
virtual int setDeviceVolume(int mmfVolume); |
| 68 |
virtual int openFile(const QString &fileName); |
| 69 |
virtual int openFile(RFile& file); |
| 70 |
virtual int openUrl(const QString& url, int iap); |
| 71 |
virtual int openDescriptor(const TDesC8 &des); |
| 72 |
virtual int bufferStatus() const; |
| 73 |
virtual void doClose(); |
| 74 |
|
| 75 |
// MediaObjectInterface |
| 76 |
virtual bool hasVideo() const; |
| 77 |
virtual qint64 totalTime() const; |
| 78 |
|
| 79 |
// AbstractMediaPlayer |
| 80 |
virtual qint64 getCurrentTime() const; |
| 81 |
virtual int numberOfMetaDataEntries() const; |
| 82 |
virtual QPair<QString, QString> metaDataEntry(int index) const; |
| 83 |
|
| 84 |
/** |
| 85 |
* This class owns the pointer. |
| 86 |
*/ |
| 87 |
NativePlayer *player() const; |
| 88 |
|
| 89 |
private: |
| 90 |
void construct(); |
| 91 |
|
| 92 |
private: |
| 93 |
#ifdef QT_PHONON_MMF_AUDIO_DRM |
| 94 |
// MDrmAudioPlayerCallback |
| 95 |
virtual void MdapcInitComplete(TInt aError, |
| 96 |
const TTimeIntervalMicroSeconds &aDuration); |
| 97 |
virtual void MdapcPlayComplete(TInt aError); |
| 98 |
#else |
| 99 |
// MMdaAudioPlayerCallback |
| 100 |
virtual void MapcInitComplete(TInt aError, |
| 101 |
const TTimeIntervalMicroSeconds &aDuration); |
| 102 |
virtual void MapcPlayComplete(TInt aError); |
| 103 |
#endif |
| 104 |
|
| 105 |
// MAudioLoadingObserver |
| 106 |
virtual void MaloLoadingStarted(); |
| 107 |
virtual void MaloLoadingComplete(); |
| 108 |
|
| 109 |
private: |
| 110 |
/** |
| 111 |
* Using CPlayerType typedef in order to be able to easily switch between |
| 112 |
* CMdaAudioPlayerUtility and CDrmPlayerUtility |
| 113 |
*/ |
| 114 |
QScopedPointer<NativePlayer> m_player; |
| 115 |
|
| 116 |
qint64 m_totalTime; |
| 117 |
|
| 118 |
}; |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
QT_END_NAMESPACE |
| 123 |
|
| 124 |
#endif |