|
1 /* |
|
2 * Copyright (c) 2005-2006 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: DRM Client AudioPlay Utility |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __MMFCLIENTAUDIOPLAY_H__ |
|
21 #define __MMFCLIENTAUDIOPLAY_H__ |
|
22 |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <mdaaudiosampleplayer.h> |
|
26 #include <mmf/common/mmfcontroller.h> |
|
27 #include <mmf/server/mmffile.h> |
|
28 #include <mmf/server/mmfdes.h> |
|
29 #include <mmfcontrollerimplementationuids.hrh> |
|
30 #include <mmf/common/mmfstandardcustomcommands.h> |
|
31 #include "mmfdrm.h" |
|
32 //#include "MmfClientUtility.h" |
|
33 |
|
34 static const TUid KUidMmfAudioController = {KMmfUidControllerAudio}; |
|
35 |
|
36 /** |
|
37 Mixin class to allow notification that the timed silence has finished. |
|
38 */ |
|
39 class MRepeatTrailingSilenceTimerObs |
|
40 { |
|
41 public: |
|
42 virtual void RepeatTrailingSilenceTimerComplete() = 0; |
|
43 }; |
|
44 |
|
45 /** |
|
46 CTimer-based active object that waits the requested time before notifying its observer. |
|
47 */ |
|
48 class CRepeatTrailingSilenceTimer : public CTimer |
|
49 { |
|
50 public: |
|
51 static CRepeatTrailingSilenceTimer* NewL(MRepeatTrailingSilenceTimerObs& aObs); |
|
52 void RunL(); |
|
53 private: |
|
54 CRepeatTrailingSilenceTimer(MRepeatTrailingSilenceTimerObs& aObs); |
|
55 private: |
|
56 MRepeatTrailingSilenceTimerObs& iObs; |
|
57 }; |
|
58 |
|
59 |
|
60 |
|
61 /** |
|
62 Concrete implementation of the CDRMPlayerUtility API. |
|
63 @see CDRMPlayerUtility |
|
64 */ |
|
65 class CMMFDrmAudioPlayerUtility : public CActive |
|
66 { |
|
67 enum TDRMUtilityState { |
|
68 EIdle, |
|
69 EInitializing, |
|
70 EPlaying, |
|
71 EPaused |
|
72 }; |
|
73 |
|
74 friend class CDrmPlayerUtility; |
|
75 |
|
76 public: |
|
77 static CMMFDrmAudioPlayerUtility* NewFilePlayerL(const TDesC& aFileName, |
|
78 MDrmAudioPlayerCallback& aCallback, |
|
79 TInt aPriority = EMdaPriorityNormal, |
|
80 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); |
|
81 static CMMFDrmAudioPlayerUtility* NewDesPlayerL(const TDesC8& aData, |
|
82 MDrmAudioPlayerCallback& aCallback, |
|
83 TInt aPriority = EMdaPriorityNormal, |
|
84 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); |
|
85 static CMMFDrmAudioPlayerUtility* NewDesPlayerReadOnlyL(const TDesC8& aData, |
|
86 MDrmAudioPlayerCallback& aCallback, |
|
87 TInt aPriority = EMdaPriorityNormal, |
|
88 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); |
|
89 |
|
90 static CMMFDrmAudioPlayerUtility* NewL(MDrmAudioPlayerCallback& aCallback, |
|
91 TInt aPriority = EMdaPriorityNormal, |
|
92 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); |
|
93 |
|
94 ~CMMFDrmAudioPlayerUtility(); |
|
95 void Play(); |
|
96 void Stop(); |
|
97 void SetVolume(TInt aVolume); |
|
98 void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence); |
|
99 void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration); |
|
100 const TTimeIntervalMicroSeconds& Duration(); |
|
101 TInt MaxVolume(); |
|
102 void OpenFileL(const TDesC& aFileName); |
|
103 void OpenFileL(const RFile& aFile); |
|
104 void OpenFileL(const TMMSource& aSource); |
|
105 void OpenDesL(const TDesC8& aDescriptor); |
|
106 void OpenUrlL(const TDesC& aUrl, TInt aIapId = KUseDefaultIap, const TDesC8& aMimeType=KNullDesC8); |
|
107 |
|
108 // API Additions since version 7.0 |
|
109 TInt Pause(); |
|
110 void Close(); |
|
111 TInt GetPosition(TTimeIntervalMicroSeconds& aPosition); |
|
112 void SetPosition(const TTimeIntervalMicroSeconds& aPosition); |
|
113 |
|
114 TInt SetPriority(TInt aPriority, TMdaPriorityPreference aPref); |
|
115 TInt GetVolume(TInt& aVolume); |
|
116 TInt GetNumberOfMetaDataEntries(TInt& aNumEntries); |
|
117 CMMFMetaDataEntry* GetMetaDataEntryL(TInt aMetaDataIndex); |
|
118 TInt SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, |
|
119 const TTimeIntervalMicroSeconds& aEnd); |
|
120 TInt ClearPlayWindow(); |
|
121 TInt SetBalance(TInt aBalance = KMMFBalanceCenter); |
|
122 TInt GetBalance(TInt& aBalance); |
|
123 TInt GetBitRate(TUint& aBitRate); |
|
124 |
|
125 void RegisterForAudioLoadingNotification(MAudioLoadingObserver& aLoadingObserver); |
|
126 |
|
127 void GetAudioLoadingProgressL(TInt& aPercentageProgress); |
|
128 const CMMFControllerImplementationInformation& ControllerImplementationInformationL(); |
|
129 |
|
130 TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom); |
|
131 TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2); |
|
132 void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus); |
|
133 void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus); |
|
134 |
|
135 |
|
136 protected: |
|
137 CMMFDrmAudioPlayerUtility(MDrmAudioPlayerCallback& aCallback, TInt aActivePriority); |
|
138 void DoPlay(); |
|
139 void RunL(); |
|
140 void DoCancel(); |
|
141 |
|
142 private: |
|
143 void ConstructL(TInt aPriority = EMdaPriorityNormal, |
|
144 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); |
|
145 |
|
146 void ConstructL(const TDesC& aFileName, |
|
147 TInt aPriority = EMdaPriorityNormal, |
|
148 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); |
|
149 |
|
150 void ConstructL(const TDesC8& aData, |
|
151 TInt aPriority = EMdaPriorityNormal, |
|
152 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); |
|
153 |
|
154 void ConstructReadOnlyL(const TDesC8& aData, |
|
155 TInt aPriority = EMdaPriorityNormal, |
|
156 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); |
|
157 |
|
158 void ConnectL(); |
|
159 |
|
160 //Returns True if Destination CustomCommand needs to be blocked |
|
161 TBool IsValidCustomCommandDestination(TUid aDestinationUid, const TDesC8& aParam); |
|
162 TBool CheckCustomInterfaceBuilderImplL(const TDesC8& aParam); |
|
163 |
|
164 // last play window command |
|
165 enum TPlayWindowCommand |
|
166 { |
|
167 ENone, |
|
168 ESet, |
|
169 EClear |
|
170 }; |
|
171 |
|
172 MDrmAudioPlayerCallback& iCallback; |
|
173 TDRMUtilityState iState; |
|
174 TTimeIntervalMicroSeconds iDuration; // Needed because of api "Duration()" that returns a reference |
|
175 |
|
176 |
|
177 CMMFControllerImplementationInformation* iControllerImplementationInformation; |
|
178 CDrm* iDrm; |
|
179 RDrmSession* iDrmSession; |
|
180 TInt iError; |
|
181 TFileName iFileName; |
|
182 CBufFlat* iMetaDataBuffer; |
|
183 MAudioLoadingObserver* iLoadingObserver; |
|
184 TAsyncCallbackStatePckgBuf iAsyncCallback; |
|
185 TErrorDurationStructPckgBuf iErrorDurationStruct; |
|
186 TRequestStatus* iRequestStatus; |
|
187 TDes8* iDataPointer; |
|
188 TDRMCustomCommand iCustomCommand; |
|
189 TPckgCustomCommand iCustomCommandPckg; |
|
190 |
|
191 struct TCustomCommands |
|
192 { |
|
193 const TMMFMessageDestinationPckg* iDestination; |
|
194 TInt iFunction; |
|
195 const TDesC8* iDataTo1; |
|
196 const TDesC8* iDataTo2; |
|
197 const TDes8* iDataFrom; |
|
198 |
|
199 TCustomCommands(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2,TDes8& aDataFrom) |
|
200 { |
|
201 iDestination = &aDestination; |
|
202 iFunction = aFunction; |
|
203 iDataTo1 = &aDataTo1; |
|
204 iDataTo2 = &aDataTo2; |
|
205 iDataFrom = &aDataFrom; |
|
206 }; |
|
207 }; |
|
208 struct TCustomCommandsAsync |
|
209 { |
|
210 const TMMFMessageDestinationPckg* iDestination; |
|
211 TInt iFunction; |
|
212 const TDesC8* iDataTo1; |
|
213 const TDesC8* iDataTo2; |
|
214 TDes8* iDataFrom; |
|
215 TRequestStatus* iRequestStatus; |
|
216 |
|
217 TCustomCommandsAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2, TDes8& aDataFrom,TRequestStatus& aStatus) |
|
218 { |
|
219 iDestination = &aDestination; |
|
220 iFunction = aFunction; |
|
221 iDataTo1 = &aDataTo1; |
|
222 iDataTo2 = &aDataTo2; |
|
223 iDataFrom = &aDataFrom; |
|
224 iRequestStatus = &aStatus; |
|
225 }; |
|
226 }; |
|
227 struct TCustomCommandsAsyncNoData |
|
228 { |
|
229 const TMMFMessageDestinationPckg* iDestination; |
|
230 TInt iFunction; |
|
231 const TDesC8* iDataTo1; |
|
232 const TDesC8* iDataTo2; |
|
233 TRequestStatus* iRequestStatus; |
|
234 |
|
235 TCustomCommandsAsyncNoData(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2,TRequestStatus& aStatus) |
|
236 { |
|
237 iDestination = &aDestination; |
|
238 iFunction = aFunction; |
|
239 iDataTo1 = &aDataTo1; |
|
240 iDataTo2 = &aDataTo2; |
|
241 iRequestStatus = &aStatus; |
|
242 }; |
|
243 }; |
|
244 |
|
245 typedef TPckg<TCustomCommands> TPckgTCustomCommandStructure; |
|
246 }; |
|
247 |
|
248 #endif |