source: trunk/src/3rdparty/phonon/mmf/abstractmediaplayer.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 4.2 KB
Line 
1/* This file is part of the KDE project.
2
3Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5This library is free software: you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation, either version 2.1 or 3 of the License.
8
9This library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public License
15along with this library. If not, see <http://www.gnu.org/licenses/>.
16
17*/
18
19#ifndef PHONON_MMF_ABSTRACTMEDIAPLAYER_H
20#define PHONON_MMF_ABSTRACTMEDIAPLAYER_H
21
22#include <QTimer>
23#include <QScopedPointer>
24#include <e32std.h>
25#include "abstractplayer.h"
26#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
27# include "download.h"
28#endif
29
30class RFile;
31
32QT_BEGIN_NAMESPACE
33
34namespace Phonon
35{
36namespace MMF
37{
38class AudioOutput;
39class MediaObject;
40
41/**
42 * Interface via which MMF client APIs for both audio and video can be
43 * accessed.
44 */
45class AbstractMediaPlayer : public AbstractPlayer
46{
47 Q_OBJECT
48
49protected:
50 AbstractMediaPlayer(MediaObject *parent, const AbstractPlayer *player);
51
52public:
53 virtual void open();
54 virtual void close();
55
56 // MediaObjectInterface
57 virtual void play();
58 virtual void pause();
59 virtual void stop();
60 virtual void seek(qint64 milliseconds);
61 virtual bool isSeekable() const;
62 virtual qint64 currentTime() const;
63 virtual void volumeChanged(qreal volume);
64
65protected:
66 // AbstractPlayer
67 virtual void doSetTickInterval(qint32 interval);
68 virtual Phonon::State phononState(PrivateState state) const;
69 virtual void changeState(PrivateState newState);
70
71 virtual void doPlay() = 0;
72 virtual void doPause() = 0;
73 virtual void doStop() = 0;
74 virtual void doSeek(qint64 pos) = 0;
75 virtual int setDeviceVolume(int mmfVolume) = 0;
76 virtual int openFile(const QString &fileName) = 0;
77 virtual int openFile(RFile& file) = 0;
78 virtual int openUrl(const QString& url, int iap) = 0;
79 virtual int openDescriptor(const TDesC8 &des) = 0;
80 virtual int bufferStatus() const = 0;
81 virtual void doClose() = 0;
82
83 void updateMetaData();
84 virtual qint64 getCurrentTime() const = 0;
85 virtual int numberOfMetaDataEntries() const = 0;
86 virtual QPair<QString, QString> metaDataEntry(int index) const = 0;
87
88protected:
89 void bufferingStarted();
90 void bufferingComplete();
91 void maxVolumeChanged(int maxVolume);
92 void loadingComplete(int error);
93 void playbackComplete(int error);
94
95 static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &);
96
97 bool isProgressiveDownload() const;
98 bool progressiveDownloadStalled() const;
99
100private:
101 void startPositionTimer();
102 void stopPositionTimer();
103 void startBufferStatusTimer();
104 void stopBufferStatusTimer();
105 void stopTimers();
106 void doVolumeChanged();
107 void emitMarksIfReached(qint64 position);
108 void resetMarksIfRewound();
109 void startPlayback();
110 void setProgressiveDownloadStalled();
111
112 enum Pending {
113 NothingPending,
114 PausePending,
115 PlayPending
116 };
117
118 void setPending(Pending pending);
119
120private Q_SLOTS:
121 void positionTick();
122 void bufferStatusTick();
123#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
124 void downloadLengthChanged(qint64);
125 void downloadStateChanged(Download::State);
126#endif
127
128private:
129 MediaObject *const m_parent;
130
131 Pending m_pending;
132
133 QScopedPointer<QTimer> m_positionTimer;
134 qint64 m_position;
135
136 QScopedPointer<QTimer> m_bufferStatusTimer;
137 PrivateState m_stateBeforeBuffering;
138
139 int m_mmfMaxVolume;
140
141 bool m_prefinishMarkSent;
142 bool m_aboutToFinishSent;
143
144 // Used for playback of resource files
145 TPtrC8 m_buffer;
146
147#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
148 Download *m_download;
149 bool m_downloadStalled;
150#endif
151
152 QMultiMap<QString, QString> m_metaData;
153
154};
155}
156}
157
158QT_END_NAMESPACE
159
160#endif
161
Note: See TracBrowser for help on using the repository browser.