|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Base class definition of the S60 Audio Player |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CS60AUDIOPLAYER_H__ |
|
19 #define __CS60AUDIOPLAYER_H__ |
|
20 |
|
21 #include <e32std.h> |
|
22 #include <e32base.h> |
|
23 #include <mmf/common/mmfcontroller.h> |
|
24 #include <mmf/common/mmfaudio.h> |
|
25 #include <mmf/server/mmffile.h> |
|
26 #include <mmf/server/mmfdes.h> |
|
27 #include <mmfcontrollerimplementationuids.hrh> |
|
28 #include <mmf/common/mmfstandardcustomcommands.h> |
|
29 #include <mmf/common/mmfdrmcustomcommands.h> |
|
30 #include <mmf/common/mmfcontrollerframeworkbase.h> |
|
31 |
|
32 #include "S60AudioUtility.h" |
|
33 #include "MS60AudioPlayerObserver.h" |
|
34 #include "S60AudioSource.h" |
|
35 #include <MCustomInterface.h> |
|
36 |
|
37 |
|
38 //FORWARD DECLARATION |
|
39 class CPlayerEventDispatcher; |
|
40 |
|
41 // CLASS DEFINITIONS |
|
42 |
|
43 /** |
|
44 Mixin class to allow notification that the timed silence has finished. |
|
45 */ |
|
46 class MRepeatTrailingSilenceTimerObs |
|
47 { |
|
48 public: |
|
49 virtual void RepeatTrailingSilenceTimerComplete() = 0; |
|
50 }; |
|
51 |
|
52 |
|
53 /** |
|
54 CTimer-based active object that waits the requested time before notifying its observer. |
|
55 */ |
|
56 class CRepeatTrailingSilenceTimer : public CTimer |
|
57 { |
|
58 public: |
|
59 static CRepeatTrailingSilenceTimer* NewL(MRepeatTrailingSilenceTimerObs& aObs); |
|
60 void RunL(); |
|
61 private: |
|
62 CRepeatTrailingSilenceTimer(MRepeatTrailingSilenceTimerObs& aObs); |
|
63 private: |
|
64 MRepeatTrailingSilenceTimerObs& iObs; |
|
65 }; |
|
66 |
|
67 |
|
68 /** |
|
69 * This class defines the common S60 audio player functions. |
|
70 * |
|
71 * @lib S60AudioPlayer.lib |
|
72 * @since 3.1 |
|
73 */ |
|
74 class CS60AudioPlayer: public CBase, |
|
75 public MMMFControllerEventMonitorObserver, |
|
76 public MRepeatTrailingSilenceTimerObs, |
|
77 public MMMFFindAndOpenControllerObserver, |
|
78 public MCustomInterface |
|
79 { |
|
80 |
|
81 public: // Constructors and destructor |
|
82 |
|
83 IMPORT_C static CS60AudioPlayer* NewL( MS60AudioPlayerObserver& aObserver, |
|
84 TInt aPriority = EMdaPriorityNormal, |
|
85 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); |
|
86 |
|
87 /** |
|
88 * Destructor |
|
89 */ |
|
90 virtual ~CS60AudioPlayer(); |
|
91 |
|
92 public: // New functions |
|
93 |
|
94 /** |
|
95 Begins playback of the initialised audio sample at the current volume |
|
96 and priority levels. |
|
97 |
|
98 When playing of the audio sample is complete, successfully or |
|
99 otherwise, the callback function |
|
100 MS60AudioPlayerObserver::StateChanged() is |
|
101 called. |
|
102 |
|
103 @since 3.1 |
|
104 @lib "S60Audio.lib" |
|
105 */ |
|
106 IMPORT_C virtual TInt Play(); |
|
107 |
|
108 /** |
|
109 Stops playback of the audio sample as soon as possible. |
|
110 |
|
111 If the audio sample is playing, playback is stopped as soon as |
|
112 possible. If playback is already complete, nothing further happens as |
|
113 a result of calling this function. The callback function |
|
114 MS60AudioPlayerObserver::StateChanged() is called. |
|
115 |
|
116 @since 3.1 |
|
117 @lib "S60Audio.lib" |
|
118 */ |
|
119 IMPORT_C virtual TInt Stop(); |
|
120 |
|
121 /** |
|
122 * |
|
123 * Pauses playback of the audio clip |
|
124 * @returns One of the system-wide error codes |
|
125 * @since 3.1 |
|
126 * @lib "S60Audio.lib" |
|
127 */ |
|
128 IMPORT_C virtual TInt Pause(); |
|
129 |
|
130 /** |
|
131 Sets the priority for playback. This is used to arbitrate between multiple |
|
132 objects trying to access a single sound device. |
|
133 |
|
134 @param aPriority |
|
135 The priority level to apply, EMdaPriorityMin client can be interrupted by any |
|
136 other client, EMdaPriorityNormal client can only be interrupted by a client |
|
137 with a higher priority or EMdaPriorityMax client cannot be interrupted by other |
|
138 clients. |
|
139 @param aPref |
|
140 The quality/time preferences to apply. |
|
141 |
|
142 @return An error code indicating if the function call was successful. KErrNone on success, otherwise |
|
143 another of the system-wide error codes. |
|
144 |
|
145 @since 3.1 |
|
146 |
|
147 @capability MultimediaDD |
|
148 For applications that do not have the MultimediaDD capability, any supplied priority level |
|
149 (aPriority) or priority preference (aPref) will be ignored. |
|
150 */ |
|
151 IMPORT_C virtual TInt SetPriority(TInt aPriority, TMdaPriorityPreference aPref); |
|
152 |
|
153 /** |
|
154 * |
|
155 * Sets the FastForward step for the file |
|
156 * |
|
157 * @param "TTimeIntervalMicroSeconds aStep" |
|
158 * The duration to move forward in microseconds from the current position in the file. |
|
159 * If aPosition is greater than the file duration, the position is set to the |
|
160 * end of the file. |
|
161 * |
|
162 * @since 3.1 |
|
163 * @lib "S60Audio.lib" |
|
164 */ |
|
165 IMPORT_C virtual TInt FastForward(TTimeIntervalMicroSeconds& aStep); |
|
166 |
|
167 /** |
|
168 * |
|
169 * Sets the Rewind step for the file |
|
170 * |
|
171 * @param "TTimeIntervalMicroSeconds aStep" |
|
172 * The duration to move backward in microseconds from the current position in the file. |
|
173 * If aPosition is greater than the file duration, the position is set to the |
|
174 * beginning of the file. |
|
175 * |
|
176 * @since 3.1 |
|
177 * @lib "S60Audio.lib" |
|
178 */ |
|
179 IMPORT_C virtual TInt Rewind(TTimeIntervalMicroSeconds& aStep); |
|
180 |
|
181 /** |
|
182 Returns an integer representing the maximum volume. |
|
183 |
|
184 This is the maximum value which can be passed to |
|
185 CMdaAudioPlayerUtility::SetVolume(). This value is platform |
|
186 independent, but is always greater than or equal to one. |
|
187 |
|
188 @return The maximum volume setting. |
|
189 |
|
190 @since 3.1 |
|
191 */ |
|
192 IMPORT_C virtual TInt GetMaxVolume(); |
|
193 |
|
194 /** |
|
195 Changes the current playback volume to a specified value. |
|
196 |
|
197 The volume can be changed before or during playback and is effective |
|
198 immediately. |
|
199 |
|
200 @param aVolume |
|
201 The volume setting. This can be any value from zero to |
|
202 the value returned by a call to |
|
203 S60AudioPlayer::GetMaxVolume(). |
|
204 Setting a zero value mutes the sound. Setting the |
|
205 maximum value results in the loudest possible sound. |
|
206 |
|
207 @return A System Wide Error code |
|
208 |
|
209 @since 3.1 |
|
210 @lib "S60Audio.lib"*/ |
|
211 IMPORT_C virtual TInt SetVolume(TInt aVolume); |
|
212 |
|
213 /** |
|
214 Returns the current playback volume. |
|
215 |
|
216 @param aVolume |
|
217 A value between 0 and the maximum volume settings returned by GetMaxVolume(). |
|
218 |
|
219 @return An error code indicating if the function call was successful. KErrNone on success, otherwise |
|
220 another of the system-wide error codes. |
|
221 |
|
222 @since 3.1 |
|
223 */ |
|
224 IMPORT_C virtual TInt GetVolume(TInt& aVolume); |
|
225 |
|
226 |
|
227 /** |
|
228 Returns the duration of the audio sample in microseconds. |
|
229 |
|
230 @return The duration of the sample in microseconds. |
|
231 |
|
232 @since 3.1 |
|
233 */ |
|
234 IMPORT_C virtual TTimeIntervalMicroSeconds GetDuration(); |
|
235 |
|
236 /** |
|
237 Returns the bit rate of the audio clip. |
|
238 |
|
239 @param aBitRate |
|
240 Bit rate of the audio clip. |
|
241 |
|
242 @return One of the global error codes. |
|
243 |
|
244 @since 3.1 |
|
245 @lib "S60Audio.lib" |
|
246 */ |
|
247 IMPORT_C virtual TUint GetBitRate(); |
|
248 |
|
249 /** |
|
250 * |
|
251 * Returns the current playback position in microseconds |
|
252 * |
|
253 * @retval "TTimeIntervalMicroSeconds& aPosition" |
|
254 * The current time position in microseconds from the start of the file |
|
255 * @returns "TInt" One of the global error codes |
|
256 * |
|
257 * @since 3.1 |
|
258 * @lib "S60Audio.lib" |
|
259 */ |
|
260 IMPORT_C virtual TTimeIntervalMicroSeconds GetPosition(); |
|
261 |
|
262 /** |
|
263 * |
|
264 * Set the current playback position in microseconds from the start of the file |
|
265 * |
|
266 * @param "TTimeIntervalMicroSeconds& aPosition" |
|
267 * The position to move to in microseconds from the start of the file. |
|
268 * If aPosition is negative, the position is set to the start of the file. |
|
269 * If aPosition is greater than the file duration, the position is set to the |
|
270 * end of the file. |
|
271 * |
|
272 * @since 3.1 |
|
273 * @lib "S60Audio.lib" |
|
274 */ |
|
275 IMPORT_C virtual void SetPosition(TTimeIntervalMicroSeconds& aPosition); |
|
276 |
|
277 /** |
|
278 * |
|
279 * Set the current playback window |
|
280 * |
|
281 * @param "const TTimeIntervalMicroSeconds& aStart" |
|
282 * Start time of playback window relative to start of file |
|
283 * @param "const TTimeIntervalMicroSeconds& aEnd" |
|
284 * End time of playback window relative to start of file |
|
285 * |
|
286 * @returns "TInt" One of the global error codes |
|
287 * |
|
288 * @since 3.1 |
|
289 * @lib "S60Audio.lib" |
|
290 */ |
|
291 IMPORT_C virtual void SetPlayWindow(TTimeIntervalMicroSeconds& aStart, TTimeIntervalMicroSeconds& aEnd); |
|
292 |
|
293 /** |
|
294 * |
|
295 * Gets the current playback window |
|
296 * |
|
297 * @param "const TTimeIntervalMicroSeconds& aStart" |
|
298 * Start time of playback window relative to start of file |
|
299 * @param "const TTimeIntervalMicroSeconds& aEnd" |
|
300 * End time of playback window relative to start of file |
|
301 * |
|
302 * @returns "TInt" One of the global error codes |
|
303 * |
|
304 * @since 3.1 |
|
305 * @lib "S60Audio.lib" |
|
306 */ |
|
307 |
|
308 IMPORT_C virtual void GetPlayWindow(TTimeIntervalMicroSeconds& aStart, TTimeIntervalMicroSeconds& aEnd); |
|
309 |
|
310 /** |
|
311 * |
|
312 * Clear the current playback window |
|
313 * |
|
314 * @returns "TInt" One of the global error codes |
|
315 * |
|
316 * @since 3.1 |
|
317 * @lib "S60Audio.lib" |
|
318 */ |
|
319 IMPORT_C virtual TInt ResetPlayWindow(); |
|
320 |
|
321 /** |
|
322 Sets the number of times the audio sample is to be repeated during the |
|
323 playback operation. |
|
324 |
|
325 A period of silence can follow each playing of the sample. The audio |
|
326 sample can be repeated indefinitely. |
|
327 |
|
328 @param aRepeatNumberOfTimes |
|
329 The number of times the audio sample, together with |
|
330 the trailing silence, is to be repeated. If this is |
|
331 set to KMdaRepeatForever, then the audio |
|
332 sample, together with the trailing silence, is |
|
333 repeated indefinitely or until Stop() is |
|
334 called. If this is set to zero, then the audio sample |
|
335 is not repeated. |
|
336 @param aTrailingSilence |
|
337 The time interval of the trailing silence in microseconds. |
|
338 |
|
339 @since 3.1 |
|
340 */ |
|
341 IMPORT_C virtual void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence); |
|
342 |
|
343 /** |
|
344 Returns the current playback balance |
|
345 |
|
346 @return A value between KMMFBalanceMaxLeft and KMMFBalanceMaxRight |
|
347 |
|
348 @since 3.1 |
|
349 @lib "S60Audio.lib" |
|
350 */ |
|
351 IMPORT_C virtual TInt GetBalance(); |
|
352 |
|
353 /** |
|
354 Sets the current playback balance |
|
355 |
|
356 @param aBalance |
|
357 A value between KMMFBalanceMaxLeft and KMMFBalanceMaxRight. The default value is |
|
358 KMMFBalanceCenter. |
|
359 |
|
360 @return One of the global error codes. |
|
361 |
|
362 @since 3.1 |
|
363 @lib "S60Audio.lib" |
|
364 */ |
|
365 IMPORT_C virtual TInt SetBalance(TInt& aBalance); |
|
366 |
|
367 /** |
|
368 Returns the current Seeking Capability |
|
369 |
|
370 @return ETrue/EFalse depending on the Seeking Support |
|
371 |
|
372 @since 3.1 |
|
373 @lib "S60Audio.lib" |
|
374 */ |
|
375 IMPORT_C virtual TBool IsSeekingSupported(); |
|
376 |
|
377 /** |
|
378 Returns the current Random Seeking Capability |
|
379 |
|
380 @return ETrue/EFalse depending on the Random Seeking Support |
|
381 |
|
382 @since 3.1 |
|
383 @lib "S60Audio.lib" |
|
384 */ |
|
385 IMPORT_C virtual TBool IsRandomSeekingSupported(); |
|
386 |
|
387 /** |
|
388 * Add a data source to be used as input to the audio player. |
|
389 * @since 3.1 |
|
390 */ |
|
391 IMPORT_C virtual void AddDataSource( CS60AudioBaseSource& aDataSource ); |
|
392 |
|
393 |
|
394 // from MCustomInterface |
|
395 |
|
396 IMPORT_C virtual TAny* CustomInterface(TUid aInterfaceId); |
|
397 |
|
398 protected: |
|
399 |
|
400 |
|
401 // from MMMFControllerEventMonitorObserver |
|
402 virtual void HandleEvent(const TMMFEvent& aEvent); |
|
403 |
|
404 // from MRepeatTrailingSilenceTimerObs |
|
405 virtual void RepeatTrailingSilenceTimerComplete(); |
|
406 |
|
407 // from MMMFFindAndOpenControllerObserver |
|
408 virtual void MfaocComplete(TInt& aError, RMMFController* aController, TUid aControllerUid, |
|
409 TMMFMessageDestination* aSourceHandle, TMMFMessageDestination* aSinkHandle); |
|
410 |
|
411 private: |
|
412 |
|
413 /** |
|
414 * Private C++ constructor for this class. |
|
415 * @since 3.1 |
|
416 * @return - |
|
417 */ |
|
418 CS60AudioPlayer(MS60AudioPlayerObserver& aObserver, TInt aPriority, TMdaPriorityPreference aPref); |
|
419 |
|
420 void ConstructL(); |
|
421 |
|
422 TInt DoPlay(); |
|
423 |
|
424 protected: // Data |
|
425 |
|
426 MS60AudioPlayerObserver& iObserver; |
|
427 |
|
428 TPlayerState iState; |
|
429 |
|
430 CS60AudioBaseSource* iSource; |
|
431 |
|
432 MAudioLoadingObserver* iLoadingObserver; |
|
433 MMMFAudioResourceNotificationCallback* iAudioResourceNotificationCallBack; |
|
434 |
|
435 CMMFFindAndOpenController* iFindAndOpenController; |
|
436 CMMFControllerEventMonitor* iControllerEventMonitor; |
|
437 |
|
438 TTimeIntervalMicroSeconds iTrailingSilence; |
|
439 CRepeatTrailingSilenceTimer* iRepeatTrailingSilenceTimer; |
|
440 |
|
441 CPlayerEventDispatcher* iDispatcher; |
|
442 TMMFPrioritySettings iPrioritySettings; |
|
443 RMMFController iController; |
|
444 RMMFAudioPlayDeviceCustomCommands iAudioPlayDeviceCommands; |
|
445 |
|
446 // Playback indicators |
|
447 TTimeIntervalMicroSeconds iPosition; |
|
448 TUid iControllerUid; |
|
449 TMMFMessageDestination iSourceHandle; |
|
450 |
|
451 }; |
|
452 |
|
453 #endif // __CS60AUDIOPLAYER_H__ |
|
454 |
|
455 // End of File |