|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef S60MEDIAPLAYERSESSION_H |
|
43 #define S60MEDIAPLAYERSESSION_H |
|
44 |
|
45 #include <QtCore/qobject.h> |
|
46 #include <QtCore/qurl.h> |
|
47 #include <QtCore/qpair.h> |
|
48 #include <QMediaPlayer> |
|
49 #include <e32cmn.h> // for TDesC |
|
50 #include <QRect> |
|
51 #include "s60mediaplayerservice.h" |
|
52 |
|
53 QTM_BEGIN_NAMESPACE |
|
54 class QMediaTimeRange; |
|
55 QTM_END_NAMESPACE |
|
56 |
|
57 class QTimer; |
|
58 |
|
59 class S60MediaPlayerSession : public QObject |
|
60 { |
|
61 Q_OBJECT |
|
62 |
|
63 public: |
|
64 S60MediaPlayerSession(QObject *parent); |
|
65 virtual ~S60MediaPlayerSession(); |
|
66 |
|
67 // for player control interface to use |
|
68 QMediaPlayer::State state() const; |
|
69 QMediaPlayer::MediaStatus mediaStatus() const; |
|
70 qint64 duration() const; |
|
71 qint64 position() const; |
|
72 void setPosition(qint64 pos); |
|
73 int volume() const; |
|
74 void setVolume(int volume); |
|
75 bool isMuted() const; |
|
76 void setMuted(bool muted); |
|
77 virtual bool isVideoAvailable() const = 0; |
|
78 virtual bool isAudioAvailable() const = 0; |
|
79 bool isSeekable() const; |
|
80 void play(); |
|
81 void pause(); |
|
82 void stop(); |
|
83 void reset(); |
|
84 bool isMetadataAvailable() const; |
|
85 QVariant metaData(const QString &key) const; |
|
86 QMap<QString, QVariant> availableMetaData() const; |
|
87 void load(QUrl url); |
|
88 int bufferStatus(); |
|
89 virtual void setVideoRenderer(QObject *renderer); |
|
90 void setMediaStatus(QMediaPlayer::MediaStatus); |
|
91 void setState(QMediaPlayer::State state); |
|
92 |
|
93 protected: |
|
94 virtual void doLoadL(const TDesC &path) = 0; |
|
95 virtual void doLoadUrlL(const TDesC &path) = 0; |
|
96 virtual void doPlay() = 0; |
|
97 virtual void doStop() = 0; |
|
98 virtual void doPauseL() = 0; |
|
99 virtual void doSetVolumeL(int volume) = 0; |
|
100 virtual void doSetPositionL(qint64 microSeconds) = 0; |
|
101 virtual qint64 doGetPositionL() const = 0; |
|
102 virtual void updateMetaDataEntriesL() = 0; |
|
103 virtual int doGetBufferStatusL() const = 0; |
|
104 virtual qint64 doGetDurationL() const = 0; |
|
105 |
|
106 public: |
|
107 // From S60MediaPlayerAudioEndpointSelector |
|
108 virtual QString activeEndpoint() const = 0; |
|
109 virtual QString defaultEndpoint() const = 0; |
|
110 public Q_SLOTS: |
|
111 virtual void setActiveEndpoint(const QString& name) = 0; |
|
112 Q_SIGNALS: |
|
113 virtual void activeEndpointChanged(const QString &name) = 0; |
|
114 |
|
115 protected: |
|
116 void setError(int error, const QString &errorString = QString(), bool forceReset = false); |
|
117 void loaded(); |
|
118 void buffering(); |
|
119 void buffered(); |
|
120 void endOfMedia(); |
|
121 QMap<QString, QVariant>& metaDataEntries(); |
|
122 QMediaPlayer::Error fromSymbianErrorToMultimediaError(int error); |
|
123 void startProgressTimer(); |
|
124 void stopProgressTimer(); |
|
125 void startStalledTimer(); |
|
126 void stopStalledTimer(); |
|
127 QString TDesC2QString(const TDesC& aDescriptor); |
|
128 TPtrC QString2TPtrC( const QString& string ); |
|
129 QRect TRect2QRect(const TRect& tr); |
|
130 TRect QRect2TRect(const QRect& qr); |
|
131 |
|
132 |
|
133 protected slots: |
|
134 void tick(); |
|
135 void stalled(); |
|
136 |
|
137 signals: |
|
138 void durationChanged(qint64 duration); |
|
139 void positionChanged(qint64 position); |
|
140 void stateChanged(QMediaPlayer::State state); |
|
141 void mediaStatusChanged(QMediaPlayer::MediaStatus mediaStatus); |
|
142 void videoAvailableChanged(bool videoAvailable); |
|
143 void audioAvailableChanged(bool audioAvailable); |
|
144 void bufferStatusChanged(int percentFilled); |
|
145 void seekableChanged(bool); |
|
146 void availablePlaybackRangesChanged(const QMediaTimeRange&); |
|
147 void metaDataChanged(); |
|
148 void error(int error, const QString &errorString); |
|
149 |
|
150 private: |
|
151 qreal m_playbackRate; |
|
152 QMap<QString, QVariant> m_metaDataMap; |
|
153 bool m_muted; |
|
154 int m_volume; |
|
155 QMediaPlayer::State m_state; |
|
156 QMediaPlayer::MediaStatus m_mediaStatus; |
|
157 QTimer *m_progressTimer; |
|
158 QTimer *m_stalledTimer; |
|
159 int m_error; |
|
160 bool m_play_requested; |
|
161 bool m_stream; |
|
162 }; |
|
163 |
|
164 #endif |