author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 02 Feb 2010 00:43:10 +0200 | |
changeset 3 | 41300fa6a67c |
parent 0 | 1918ee327afb |
child 4 | 3b1da2848fc7 |
child 7 | f7bc934e204c |
permissions | -rw-r--r-- |
0 | 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_ABSTRACTPLAYER_H |
|
20 |
#define PHONON_MMF_ABSTRACTPLAYER_H |
|
21 |
||
22 |
#include <Phonon/phononnamespace.h> |
|
23 |
#include <Phonon/MediaSource.h> |
|
24 |
||
25 |
#include <QObject> |
|
26 |
||
27 |
#include "videooutput.h" |
|
28 |
||
29 |
class RFile; |
|
30 |
||
31 |
QT_BEGIN_NAMESPACE |
|
32 |
||
33 |
namespace Phonon |
|
34 |
{ |
|
35 |
namespace MMF |
|
36 |
{ |
|
37 |
class VideoOutput; |
|
38 |
||
39 |
/** |
|
40 |
* @short Interface which abstracts from MediaObject the current |
|
41 |
* media type |
|
42 |
* |
|
43 |
* This may be: |
|
44 |
* - Nothing, in which case this interface is implemented by |
|
45 |
* DummyPlayer |
|
46 |
* - Audio, in which case the implementation is AudioPlayer |
|
47 |
* - Video, in which case the implementation is VideoPlayer |
|
48 |
*/ |
|
49 |
class AbstractPlayer : public QObject |
|
50 |
{ |
|
51 |
// Required although this class has no signals or slots |
|
52 |
// Without this, qobject_cast will fail |
|
53 |
Q_OBJECT |
|
54 |
||
55 |
public: |
|
56 |
AbstractPlayer(); |
|
57 |
explicit AbstractPlayer(const AbstractPlayer& player); |
|
58 |
||
59 |
// MediaObjectInterface (implemented) |
|
60 |
qint32 tickInterval() const; |
|
61 |
void setTickInterval(qint32); |
|
62 |
void setTransitionTime(qint32); |
|
63 |
qint32 transitionTime() const; |
|
64 |
void setPrefinishMark(qint32); |
|
65 |
qint32 prefinishMark() const; |
|
66 |
||
67 |
// MediaObjectInterface (abstract) |
|
68 |
virtual void play() = 0; |
|
69 |
virtual void pause() = 0; |
|
70 |
virtual void stop() = 0; |
|
71 |
virtual void seek(qint64 milliseconds) = 0; |
|
72 |
virtual bool hasVideo() const = 0; |
|
73 |
virtual bool isSeekable() const = 0; |
|
74 |
virtual qint64 currentTime() const = 0; |
|
75 |
virtual Phonon::ErrorType errorType() const; |
|
76 |
virtual QString errorString() const; |
|
77 |
virtual qint64 totalTime() const = 0; |
|
78 |
virtual Phonon::MediaSource source() const = 0; |
|
79 |
// This is a temporary hack to work around KErrInUse from MMF |
|
80 |
// client utility OpenFileL calls |
|
81 |
//virtual void setSource(const Phonon::MediaSource &) = 0; |
|
82 |
virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; |
|
83 |
virtual void setNextSource(const Phonon::MediaSource &) = 0; |
|
84 |
||
85 |
virtual void volumeChanged(qreal volume); |
|
86 |
||
87 |
void setVideoOutput(VideoOutput* videoOutput); |
|
88 |
||
89 |
/** |
|
90 |
* Records error and changes state to ErrorState |
|
91 |
*/ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
92 |
void setError(Phonon::ErrorType error, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
const QString &errorMessage = QString()); |
0 | 94 |
|
95 |
Phonon::State state() const; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
|
0 | 97 |
Q_SIGNALS: |
98 |
void totalTimeChanged(qint64 length); |
|
99 |
void finished(); |
|
100 |
void tick(qint64 time); |
|
101 |
void stateChanged(Phonon::State oldState, |
|
102 |
Phonon::State newState); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
103 |
void metaDataChanged(const QMultiMap<QString, QString>& metaData); |
0 | 104 |
|
105 |
protected: |
|
106 |
/** |
|
107 |
* Defined private state enumeration in order to add GroundState |
|
108 |
*/ |
|
109 |
enum PrivateState { |
|
110 |
LoadingState = Phonon::LoadingState, |
|
111 |
StoppedState = Phonon::StoppedState, |
|
112 |
PlayingState = Phonon::PlayingState, |
|
113 |
BufferingState = Phonon::BufferingState, |
|
114 |
PausedState = Phonon::PausedState, |
|
115 |
ErrorState = Phonon::ErrorState, |
|
116 |
GroundState |
|
117 |
}; |
|
118 |
||
119 |
/** |
|
120 |
* Converts PrivateState into the corresponding Phonon::State |
|
121 |
*/ |
|
122 |
Phonon::State phononState() const; |
|
123 |
||
124 |
/** |
|
125 |
* Converts PrivateState into the corresponding Phonon::State |
|
126 |
*/ |
|
127 |
static Phonon::State phononState(PrivateState state); |
|
128 |
||
129 |
virtual void videoOutputChanged(); |
|
130 |
||
131 |
PrivateState privateState() const; |
|
132 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
/** |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
* Changes state and emits stateChanged() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
virtual void changeState(PrivateState newState); |
0 | 137 |
|
138 |
/** |
|
139 |
* Modifies m_state directly. Typically you want to call changeState(), |
|
140 |
* which performs the business logic. |
|
141 |
*/ |
|
142 |
void setState(PrivateState newState); |
|
143 |
||
144 |
private: |
|
145 |
virtual void doSetTickInterval(qint32 interval) = 0; |
|
146 |
||
147 |
protected: |
|
148 |
// Not owned |
|
149 |
VideoOutput* m_videoOutput; |
|
150 |
||
151 |
qreal m_volume; |
|
152 |
||
153 |
private: |
|
154 |
PrivateState m_state; |
|
155 |
Phonon::ErrorType m_error; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
156 |
QString m_errorString; |
0 | 157 |
qint32 m_tickInterval; |
158 |
qint32 m_transitionTime; |
|
159 |
qint32 m_prefinishMark; |
|
160 |
||
161 |
}; |
|
162 |
} |
|
163 |
} |
|
164 |
||
165 |
QT_END_NAMESPACE |
|
166 |
||
167 |
#endif |
|
168 |