sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#ifndef MMFCLIENTAUDIOPLAY_H
|
sl@0
|
18 |
#define MMFCLIENTAUDIOPLAY_H
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <e32std.h>
|
sl@0
|
21 |
#include <e32base.h>
|
sl@0
|
22 |
#include <mdaaudiosampleplayer.h>
|
sl@0
|
23 |
#include <mmf/common/mmfcontroller.h>
|
sl@0
|
24 |
#include <mmf/server/mmffile.h>
|
sl@0
|
25 |
#include <mmf/server/mmfdes.h>
|
sl@0
|
26 |
#include <mmfcontrollerimplementationuids.hrh>
|
sl@0
|
27 |
#include <mmf/common/mmfstandardcustomcommands.h>
|
sl@0
|
28 |
#include <mmf/common/mmfdrmcustomcommands.h>
|
sl@0
|
29 |
#include "mmfclientutility.h"
|
sl@0
|
30 |
#include <mmf/common/mmfdurationinfocustomcommands.h>
|
sl@0
|
31 |
|
sl@0
|
32 |
static const TUid KUidMmfAudioController = {KMmfUidControllerAudio};
|
sl@0
|
33 |
|
sl@0
|
34 |
/**
|
sl@0
|
35 |
Mixin class to allow notification that the timed silence has finished.
|
sl@0
|
36 |
*/
|
sl@0
|
37 |
class MRepeatTrailingSilenceTimerObs
|
sl@0
|
38 |
{
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
virtual void RepeatTrailingSilenceTimerComplete() = 0;
|
sl@0
|
41 |
};
|
sl@0
|
42 |
|
sl@0
|
43 |
/**
|
sl@0
|
44 |
CTimer-based active object that waits the requested time before notifying its observer.
|
sl@0
|
45 |
*/
|
sl@0
|
46 |
class CRepeatTrailingSilenceTimer : public CTimer
|
sl@0
|
47 |
{
|
sl@0
|
48 |
public:
|
sl@0
|
49 |
static CRepeatTrailingSilenceTimer* NewL(MRepeatTrailingSilenceTimerObs& aObs);
|
sl@0
|
50 |
void RunL();
|
sl@0
|
51 |
private:
|
sl@0
|
52 |
CRepeatTrailingSilenceTimer(MRepeatTrailingSilenceTimerObs& aObs);
|
sl@0
|
53 |
private:
|
sl@0
|
54 |
MRepeatTrailingSilenceTimerObs& iObs;
|
sl@0
|
55 |
};
|
sl@0
|
56 |
|
sl@0
|
57 |
/**
|
sl@0
|
58 |
Active object utility class to allow the callback to be called asynchronously.
|
sl@0
|
59 |
This should help prevent re-entrant code in clients of the mediaframework.
|
sl@0
|
60 |
*/
|
sl@0
|
61 |
class CMMFMdaAudioPlayerCallBack : public CActive
|
sl@0
|
62 |
{
|
sl@0
|
63 |
public:
|
sl@0
|
64 |
enum TCallbackState {
|
sl@0
|
65 |
ECallbackInitComplete,
|
sl@0
|
66 |
ECallbackPlayComplete
|
sl@0
|
67 |
};
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
public:
|
sl@0
|
71 |
static CMMFMdaAudioPlayerCallBack* NewL(MMdaAudioPlayerCallback& aCallback);
|
sl@0
|
72 |
~CMMFMdaAudioPlayerCallBack();
|
sl@0
|
73 |
void InitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
|
sl@0
|
74 |
void PlayComplete(TInt aError);
|
sl@0
|
75 |
private:
|
sl@0
|
76 |
CMMFMdaAudioPlayerCallBack(MMdaAudioPlayerCallback& aCallback);
|
sl@0
|
77 |
void RunL();
|
sl@0
|
78 |
void DoCancel();
|
sl@0
|
79 |
private:
|
sl@0
|
80 |
MMdaAudioPlayerCallback& iCallback;
|
sl@0
|
81 |
TInt iError;
|
sl@0
|
82 |
TTimeIntervalMicroSeconds iDuration;
|
sl@0
|
83 |
TCallbackState iState;
|
sl@0
|
84 |
};
|
sl@0
|
85 |
|
sl@0
|
86 |
/**
|
sl@0
|
87 |
Concrete implementation of the CMdaAudioPlayerUtility API.
|
sl@0
|
88 |
@see CMdaAudioPlayerUtility
|
sl@0
|
89 |
*/
|
sl@0
|
90 |
class CMMFMdaAudioPlayerUtility;
|
sl@0
|
91 |
NONSHARABLE_CLASS( CMMFMdaAudioPlayerUtility ): public CBase,
|
sl@0
|
92 |
public MMMFControllerEventMonitorObserver,
|
sl@0
|
93 |
public MRepeatTrailingSilenceTimerObs,
|
sl@0
|
94 |
public MMMFFindAndOpenControllerObserver
|
sl@0
|
95 |
{
|
sl@0
|
96 |
friend class CMdaAudioPlayerUtility;
|
sl@0
|
97 |
// friends for Unit testing only
|
sl@0
|
98 |
friend class CTestStepUnitMMFAudClient;
|
sl@0
|
99 |
|
sl@0
|
100 |
public:
|
sl@0
|
101 |
enum TMMFAudioPlayerState
|
sl@0
|
102 |
{
|
sl@0
|
103 |
EStopped,
|
sl@0
|
104 |
EOpening,
|
sl@0
|
105 |
EPaused,
|
sl@0
|
106 |
EPlaying
|
sl@0
|
107 |
};
|
sl@0
|
108 |
public:
|
sl@0
|
109 |
static CMMFMdaAudioPlayerUtility* NewFilePlayerL(const TDesC& aFileName,
|
sl@0
|
110 |
MMdaAudioPlayerCallback& aCallback,
|
sl@0
|
111 |
TInt aPriority = EMdaPriorityNormal,
|
sl@0
|
112 |
TInt aPref = EMdaPriorityPreferenceTimeAndQuality,
|
sl@0
|
113 |
CMdaServer* aServer = NULL);
|
sl@0
|
114 |
static CMMFMdaAudioPlayerUtility* NewDesPlayerL(const TDesC8& aData,
|
sl@0
|
115 |
MMdaAudioPlayerCallback& aCallback,
|
sl@0
|
116 |
TInt aPriority = EMdaPriorityNormal,
|
sl@0
|
117 |
TInt aPref = EMdaPriorityPreferenceTimeAndQuality,
|
sl@0
|
118 |
CMdaServer* aServer = NULL);
|
sl@0
|
119 |
static CMMFMdaAudioPlayerUtility* NewDesPlayerReadOnlyL(const TDesC8& aData,
|
sl@0
|
120 |
MMdaAudioPlayerCallback& aCallback,
|
sl@0
|
121 |
TInt aPriority = EMdaPriorityNormal,
|
sl@0
|
122 |
TInt aPref = EMdaPriorityPreferenceTimeAndQuality,
|
sl@0
|
123 |
CMdaServer* aServer = NULL);
|
sl@0
|
124 |
|
sl@0
|
125 |
static CMMFMdaAudioPlayerUtility* NewL(MMdaAudioPlayerCallback& aCallback,
|
sl@0
|
126 |
TInt aPriority = EMdaPriorityNormal,
|
sl@0
|
127 |
TInt aPref = EMdaPriorityPreferenceTimeAndQuality);
|
sl@0
|
128 |
|
sl@0
|
129 |
/**
|
sl@0
|
130 |
Destructor
|
sl@0
|
131 |
*/
|
sl@0
|
132 |
~CMMFMdaAudioPlayerUtility();
|
sl@0
|
133 |
|
sl@0
|
134 |
void UseSharedHeap();
|
sl@0
|
135 |
|
sl@0
|
136 |
void OpenFileL(const TDesC& aFileName);
|
sl@0
|
137 |
void OpenFileL(const RFile& aFile);
|
sl@0
|
138 |
void OpenFileL(const TMMSource& aSource);
|
sl@0
|
139 |
|
sl@0
|
140 |
void OpenDesL(const TDesC8& aDescriptor);
|
sl@0
|
141 |
void OpenUrlL(const TDesC& aUrl, TInt aIapId=KUseDefaultIap, const TDesC8& aMimeType = KNullDesC8);
|
sl@0
|
142 |
void Play();
|
sl@0
|
143 |
void Stop();
|
sl@0
|
144 |
TInt SetVolume(TInt aVolume);
|
sl@0
|
145 |
void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
|
sl@0
|
146 |
void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
|
sl@0
|
147 |
const TTimeIntervalMicroSeconds& Duration();
|
sl@0
|
148 |
TInt MaxVolume();
|
sl@0
|
149 |
|
sl@0
|
150 |
// API Additions since version 7.0
|
sl@0
|
151 |
TInt Pause();
|
sl@0
|
152 |
void Close();
|
sl@0
|
153 |
TInt GetPosition(TTimeIntervalMicroSeconds& aPosition);
|
sl@0
|
154 |
void SetPosition(const TTimeIntervalMicroSeconds& aPosition);
|
sl@0
|
155 |
|
sl@0
|
156 |
TInt SetPriority(TInt aPriority, TInt aPref);
|
sl@0
|
157 |
TInt GetVolume(TInt& aVolume);
|
sl@0
|
158 |
TInt GetNumberOfMetaDataEntries(TInt& aNumEntries);
|
sl@0
|
159 |
CMMFMetaDataEntry* GetMetaDataEntryL(TInt aMetaDataIndex);
|
sl@0
|
160 |
TInt SetPlayWindow(const TTimeIntervalMicroSeconds& aStart,
|
sl@0
|
161 |
const TTimeIntervalMicroSeconds& aEnd);
|
sl@0
|
162 |
TInt ClearPlayWindow();
|
sl@0
|
163 |
TInt SetBalance(TInt aBalance = KMMFBalanceCenter);
|
sl@0
|
164 |
TInt GetBalance(TInt& aBalance);
|
sl@0
|
165 |
TInt GetBitRate(TUint& aBitRate);
|
sl@0
|
166 |
|
sl@0
|
167 |
void RegisterForAudioLoadingNotification(MAudioLoadingObserver& aCallback);
|
sl@0
|
168 |
void GetAudioLoadingProgressL(TInt& aPercentageProgress);
|
sl@0
|
169 |
const CMMFControllerImplementationInformation& ControllerImplementationInformationL();
|
sl@0
|
170 |
|
sl@0
|
171 |
TInt RegisterAudioResourceNotification(MMMFAudioResourceNotificationCallback& aCallback,TUid aNotificationEventUid,const TDesC8& aNotificationRegistrationData = KNullDesC8);
|
sl@0
|
172 |
TInt CancelRegisterAudioResourceNotification(TUid aNotificationEventId);
|
sl@0
|
173 |
TInt WillResumePlay();
|
sl@0
|
174 |
TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
|
sl@0
|
175 |
TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
|
sl@0
|
176 |
void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
|
sl@0
|
177 |
void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
|
sl@0
|
178 |
|
sl@0
|
179 |
MMMFDRMCustomCommand* GetDRMCustomCommand();
|
sl@0
|
180 |
|
sl@0
|
181 |
TInt SetThreadPriority(const TThreadPriority& aThreadPriority) const;
|
sl@0
|
182 |
|
sl@0
|
183 |
TMMFDurationInfo Duration(TTimeIntervalMicroSeconds& aDuration);
|
sl@0
|
184 |
|
sl@0
|
185 |
// from MMMFControllerEventMonitorObserver
|
sl@0
|
186 |
virtual void HandleEvent(const TMMFEvent& aEvent);
|
sl@0
|
187 |
// from MRepeatTrailingSilenceTimerObs
|
sl@0
|
188 |
virtual void RepeatTrailingSilenceTimerComplete();
|
sl@0
|
189 |
|
sl@0
|
190 |
// from MMMFFindAndOpenControllerObserver
|
sl@0
|
191 |
virtual void MfaocComplete(
|
sl@0
|
192 |
TInt& aError,
|
sl@0
|
193 |
RMMFController* aController,
|
sl@0
|
194 |
TUid aControllerUid,
|
sl@0
|
195 |
TMMFMessageDestination* aSourceHandle,
|
sl@0
|
196 |
TMMFMessageDestination* aSinkHandle);
|
sl@0
|
197 |
|
sl@0
|
198 |
protected:
|
sl@0
|
199 |
CMMFMdaAudioPlayerUtility(MMdaAudioPlayerCallback& aCallback, TInt aPriority, TInt aPref);
|
sl@0
|
200 |
void ConstructL();
|
sl@0
|
201 |
void DoPlay();
|
sl@0
|
202 |
|
sl@0
|
203 |
private:
|
sl@0
|
204 |
void PlaySilence();
|
sl@0
|
205 |
|
sl@0
|
206 |
private:
|
sl@0
|
207 |
// last play window command
|
sl@0
|
208 |
enum TPlayWindowCommand
|
sl@0
|
209 |
{
|
sl@0
|
210 |
ENone,
|
sl@0
|
211 |
ESet,
|
sl@0
|
212 |
EClear
|
sl@0
|
213 |
};
|
sl@0
|
214 |
|
sl@0
|
215 |
MMdaAudioPlayerCallback& iCallback;
|
sl@0
|
216 |
CMMFMdaAudioPlayerCallBack* iAsyncCallBack;
|
sl@0
|
217 |
MAudioLoadingObserver* iLoadingObserver;
|
sl@0
|
218 |
MMMFAudioResourceNotificationCallback* iAudioResourceNotificationCallBack;
|
sl@0
|
219 |
RMMFController iController;
|
sl@0
|
220 |
CMMFControllerEventMonitor* iControllerEventMonitor;
|
sl@0
|
221 |
TMMFAudioPlayerState iState;
|
sl@0
|
222 |
TTimeIntervalMicroSeconds iDuration; // Needed because of api "Duration()" that returns a reference
|
sl@0
|
223 |
TMMFPrioritySettings iPrioritySettings;
|
sl@0
|
224 |
|
sl@0
|
225 |
TInt iNumberOfTimesPlayed;
|
sl@0
|
226 |
TInt iNumberOfTimesToRepeat;
|
sl@0
|
227 |
TTimeIntervalMicroSeconds iTrailingSilence;
|
sl@0
|
228 |
TTimeIntervalMicroSeconds iTrailingSilenceLeftToPlay;
|
sl@0
|
229 |
CRepeatTrailingSilenceTimer* iRepeatTrailingSilenceTimer;
|
sl@0
|
230 |
|
sl@0
|
231 |
// Source and sink handle info
|
sl@0
|
232 |
TMMFMessageDestination iSourceHandle;
|
sl@0
|
233 |
TMMFMessageDestination iSinkHandle;
|
sl@0
|
234 |
|
sl@0
|
235 |
// Custom command handlers
|
sl@0
|
236 |
RMMFAudioPlayDeviceCustomCommands iAudioPlayDeviceCommands;
|
sl@0
|
237 |
RMMFAudioPlayControllerCustomCommands iAudioPlayControllerCommands;
|
sl@0
|
238 |
RMMFResourceNotificationCustomCommands iNotificationRegistrationCommands;
|
sl@0
|
239 |
RMMFDRMCustomCommands iDRMCustomCommands;
|
sl@0
|
240 |
RMMFAudioPlayControllerSetRepeatsCustomCommands iAudioPlayControllerSetRepeatsCommands;
|
sl@0
|
241 |
|
sl@0
|
242 |
// Current playback time so we can resume from where we were stopped
|
sl@0
|
243 |
TTimeIntervalMicroSeconds iPosition;
|
sl@0
|
244 |
|
sl@0
|
245 |
// Play window start and end times and whether it has been set
|
sl@0
|
246 |
TTimeIntervalMicroSeconds iPlayStart;
|
sl@0
|
247 |
TTimeIntervalMicroSeconds iPlayEnd;
|
sl@0
|
248 |
TPlayWindowCommand iPlayWindowSet;
|
sl@0
|
249 |
RArray<TUid> iMediaIds;
|
sl@0
|
250 |
|
sl@0
|
251 |
CMMFControllerImplementationInformation* iControllerImplementationInformation;
|
sl@0
|
252 |
TUid iControllerUid;
|
sl@0
|
253 |
|
sl@0
|
254 |
// utility class to find and open a suitable controller asynchronously
|
sl@0
|
255 |
CMMFFindAndOpenController* iFindAndOpenController;
|
sl@0
|
256 |
TUid iEventHolder;
|
sl@0
|
257 |
TBuf8<256> iNotificationDataHolder;
|
sl@0
|
258 |
TBool iRepeatCancelled;
|
sl@0
|
259 |
};
|
sl@0
|
260 |
|
sl@0
|
261 |
#endif
|