|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __MIDICLIENTUTILITYBODY_H__ |
|
17 #define __MIDICLIENTUTILITYBODY_H__ |
|
18 |
|
19 #include <midiclientutility.h> |
|
20 #include <mmf/common/midistandardcustomcommands.h> |
|
21 #include <mmf/server/mmffile.h> |
|
22 #include <mmf/server/mmfdes.h> |
|
23 #include "mmfclientutility.h" |
|
24 |
|
25 |
|
26 /** |
|
27 Mixin class to allow notification that the timed silence has finished. |
|
28 */ |
|
29 class MRepeatTrailingSilenceTimerObs |
|
30 { |
|
31 public: |
|
32 virtual void RepeatTrailingSilenceTimerComplete() = 0; |
|
33 }; |
|
34 |
|
35 /** |
|
36 CTimer-based active object that waits the requested time before notifying its observer. |
|
37 */ |
|
38 class CRepeatTrailingSilenceTimer : public CTimer |
|
39 { |
|
40 public: |
|
41 static CRepeatTrailingSilenceTimer* NewL(MRepeatTrailingSilenceTimerObs& aObs); |
|
42 void RunL(); |
|
43 private: |
|
44 CRepeatTrailingSilenceTimer(MRepeatTrailingSilenceTimerObs& aObs); |
|
45 private: |
|
46 MRepeatTrailingSilenceTimerObs& iObs; |
|
47 }; |
|
48 |
|
49 |
|
50 class MMidiControllerEventMonitorObserver |
|
51 { |
|
52 public: |
|
53 virtual void HandleMidiEvent(const CMMFMidiEvent& aEvent) = 0; |
|
54 }; |
|
55 |
|
56 |
|
57 class CMidiControllerEventMonitor : public CActive |
|
58 { |
|
59 public: |
|
60 static CMidiControllerEventMonitor* NewL(MMidiControllerEventMonitorObserver& aMidiObserver, |
|
61 RMidiControllerCustomCommands& aMidiControllerCustomCommands, |
|
62 const CMidiClientUtility& aParent); |
|
63 ~CMidiControllerEventMonitor(); |
|
64 void Start(); |
|
65 void SelfComplete(TInt aError); |
|
66 private: |
|
67 void ConstructL(); |
|
68 void RunL(); |
|
69 void DoCancel(); |
|
70 TInt RunError(TInt aError); |
|
71 CMidiControllerEventMonitor(MMidiControllerEventMonitorObserver& aObserver, |
|
72 RMidiControllerCustomCommands& aMidiControllerCustomCommands, const CMidiClientUtility& aParent); |
|
73 private: |
|
74 MMidiControllerEventMonitorObserver& iMidiObserver; |
|
75 RMidiControllerCustomCommands& iMidiControllerCustomCommands; |
|
76 TPckgBuf<TInt> iSizeOfEvent; |
|
77 const CMidiClientUtility& iParent; |
|
78 CMMFMidiEvent* iMidiEvent; |
|
79 }; |
|
80 |
|
81 |
|
82 class CMidiEventMonitor : public CActive |
|
83 { |
|
84 public: |
|
85 static CMidiEventMonitor* NewL(MMidiControllerEventMonitorObserver& aMidiObserver, |
|
86 const CMidiClientUtility& aParent); |
|
87 ~CMidiEventMonitor(); |
|
88 void SelfComplete(TInt aError); |
|
89 private: |
|
90 void ConstructL(); |
|
91 void RunL(); |
|
92 void DoCancel(); |
|
93 TInt RunError(TInt aError); |
|
94 CMidiEventMonitor(MMidiControllerEventMonitorObserver& aObserver, |
|
95 const CMidiClientUtility& aParent); |
|
96 private: |
|
97 MMidiControllerEventMonitorObserver& iMidiObserver; |
|
98 const CMidiClientUtility& iParent; |
|
99 CMMFMidiEvent* iMidiEvent; |
|
100 }; |
|
101 |
|
102 |
|
103 class CContent; |
|
104 class CData; |
|
105 /** |
|
106 */ |
|
107 class CMidiClientUtility::CBody : public CBase, |
|
108 public MMidiControllerEventMonitorObserver, |
|
109 public MRepeatTrailingSilenceTimerObs, |
|
110 public MMMFAddDataSourceSinkAsyncObserver |
|
111 { |
|
112 public: |
|
113 static CMidiClientUtility::CBody* NewL(CMidiClientUtility* aParent, |
|
114 MMidiClientUtilityObserver& aObserver, |
|
115 TInt aPriority, |
|
116 TInt aPref, |
|
117 TBool aUseSharedHeap); |
|
118 |
|
119 |
|
120 /** |
|
121 Destructor |
|
122 */ |
|
123 ~CBody(); |
|
124 |
|
125 void OpenFile(const TDesC& aFileSource); |
|
126 void OpenFile(RFile& aFile); |
|
127 void OpenFile(const TMMSource& aFileSource); |
|
128 void OpenDes(const TDesC8& aDescriptor); |
|
129 void OpenUrl(const TDesC& aUrl,TInt aIapId = KUseDefaultIap,const TDesC8& aMimeType=KNullDesC8); |
|
130 void Close(); |
|
131 void Play(); |
|
132 void Stop(const TTimeIntervalMicroSeconds& aFadeOutDuration); |
|
133 TMidiState State() const; |
|
134 void PlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity); |
|
135 void PlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity); |
|
136 void StopNotes(TInt aChannel); |
|
137 void NoteOnL(TInt aChannel,TInt aNote,TInt aVelocity); |
|
138 void NoteOffL(TInt aChannel,TInt aNote,TInt aVelocity); |
|
139 TInt PlaybackRateL() const; |
|
140 void SetPlaybackRateL(TInt aRate); |
|
141 TInt MaxPlaybackRateL() const; |
|
142 TInt MinPlaybackRateL() const; |
|
143 TInt TempoMicroBeatsPerMinuteL() const; |
|
144 void SetTempoL(TInt aMicroBeatsPerMinute); |
|
145 TInt PitchTranspositionCentsL() const; |
|
146 TInt SetPitchTranspositionL(TInt aCents); |
|
147 TTimeIntervalMicroSeconds DurationMicroSecondsL() const; |
|
148 TInt64 DurationMicroBeatsL() const; |
|
149 TInt NumTracksL() const; |
|
150 void SetTrackMuteL(TInt aTrack,TBool aMuted) const; |
|
151 const TDesC8& MimeTypeL(); |
|
152 TTimeIntervalMicroSeconds PositionMicroSecondsL() const; |
|
153 void SetPositionMicroSecondsL(const TTimeIntervalMicroSeconds& aPosition); |
|
154 TInt64 PositionMicroBeatsL() const; |
|
155 void SetPositionMicroBeatsL(TInt64 aMicroBeats); |
|
156 void SetSyncUpdateCallbackIntervalL(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats=0); |
|
157 TInt SendMessageL(const TDesC8& aMidiMessage); |
|
158 TInt SendMessageL(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime); |
|
159 void SendMipMessageL(const RArray<TMipMessageEntry>& aEntry); |
|
160 TInt NumberOfBanksL(TBool aCustom) const; |
|
161 TInt GetBankIdL(TBool aCustom,TInt aBankIndex) const; |
|
162 void LoadCustomBankL(const TDesC& aFileName,TInt& aBankCollectionIndex); |
|
163 void UnloadCustomBankL(TInt aBankCollectionIndex); |
|
164 TBool CustomBankLoadedL(TInt aBankCollectionIndex) const; |
|
165 void UnloadAllCustomBanksL(); |
|
166 TInt NumberOfInstrumentsL(TInt aBankId,TBool aCustom) const; |
|
167 TInt GetInstrumentIdL(TInt aBankId,TBool aCustom,TInt aInstrumentIndex) const; |
|
168 HBufC* InstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId) const; |
|
169 void SetInstrumentL(TInt aChannel,TInt aBankId,TInt aInstrumentId); |
|
170 void LoadCustomInstrumentL(const TDesC& aFileName,TInt aFileBankId,TInt aFileInstrumentId,TInt aMemoryBankId,TInt aMemoryInstrumentId); |
|
171 void UnloadCustomInstrumentL(TInt aCustomBankId,TInt aInstrumentId); |
|
172 HBufC* PercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId) const; |
|
173 void StopTimeL(TTimeIntervalMicroSeconds& aStopTime) const; |
|
174 void SetStopTimeL(const TTimeIntervalMicroSeconds& aStopTime); |
|
175 void SetRepeatsL(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence); |
|
176 TInt PolyphonyL() const; |
|
177 TInt ChannelsSupportedL() const; |
|
178 TReal32 ChannelVolumeL(TInt aChannel) const; |
|
179 TReal32 MaxChannelVolumeL() const; |
|
180 void SetChannelVolumeL(TInt aChannel,TReal32 aVolume); |
|
181 void SetChannelMuteL(TInt aChannel,TBool aMuted); |
|
182 TInt VolumeL() const; |
|
183 TInt MaxVolumeL() const; |
|
184 void SetVolumeL(TInt aVolume); |
|
185 void SetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration); |
|
186 TInt GetBalanceL() const; |
|
187 void SetBalanceL(TInt aBalance = KMMFBalanceCenter); |
|
188 void SetPriorityL(TInt aPriority, TInt aPref); |
|
189 TInt NumberOfMetaDataEntriesL() const; |
|
190 CMMFMetaDataEntry* GetMetaDataEntryL(TInt aMetaDataIndex) const; |
|
191 void SetMaxPolyphonyL(TInt aMaxVoices); |
|
192 TInt GetRepeats(); |
|
193 void LoadCustomBankDataL(const TDesC8& aBankData,TInt& aBankCollectionIndex); |
|
194 void LoadCustomInstrumentDataL(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId); |
|
195 void SetBankL(TBool aCustom); |
|
196 TBool IsTrackMuteL(TInt aTrack) const; |
|
197 TBool IsChannelMuteL(TInt aChannel) const; |
|
198 void GetInstrumentL(TInt aChannel, TInt& aInstrumentId, TInt& aBankId); |
|
199 TInt MaxPolyphonyL() const; |
|
200 void CustomCommandSyncL(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom); |
|
201 void CustomCommandSyncL(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2); |
|
202 void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus); |
|
203 void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus); |
|
204 |
|
205 MMMFDRMCustomCommand* GetDRMCustomCommand(); |
|
206 |
|
207 virtual void RepeatTrailingSilenceTimerComplete(); |
|
208 //From MMMFControllerEventMonitorObserver |
|
209 virtual void HandleMidiEvent(const CMMFMidiEvent& aEvent); |
|
210 |
|
211 // from MMMFAddDataSourceSinkAsyncObserver |
|
212 virtual void MadssaoAddDataSourceSinkAsyncComplete(TInt aError, const TMMFMessageDestination& aHandle); |
|
213 |
|
214 private: |
|
215 CBody(CMidiClientUtility* aParent, MMidiClientUtilityObserver& aObserver, TInt aPriority, TInt aPref); |
|
216 void ConstructL(TBool aUseSharedHeap); |
|
217 TInt DoOpen(const RMMFControllerImplInfoArray& aControllers, TUid aSinkUid, const TDesC8& aSinkData, TBool aUseSharedHeap); |
|
218 void ExternalizeToCBufFlatL(CBufFlat*& aCfgBuffer, const CMMFUrlParams* aUrlParams) const; |
|
219 void DoOpenFileL(const TMMSource& aSource); |
|
220 void DoOpenUrlL(const TDesC& aUrl, TInt aIapId); |
|
221 private: |
|
222 CMidiClientUtility* iParent; |
|
223 MMidiClientUtilityObserver& iObserver; |
|
224 RMMFController iController; |
|
225 CMidiControllerEventMonitor* iMidiControllerEventMonitor; |
|
226 TMidiState iState; |
|
227 TMMFPrioritySettings iPrioritySettings; |
|
228 CRepeatTrailingSilenceTimer* iRepeatTrailingSilenceTimer; |
|
229 |
|
230 // Source and sink handle info |
|
231 TMMFMessageDestination iSourceHandle; |
|
232 TMMFMessageDestination iSinkHandle; |
|
233 |
|
234 // Custom command handlers |
|
235 RMidiControllerCustomCommands iMidiControllerCommands; |
|
236 |
|
237 RMMFDRMCustomCommands iDRMCustomCommands; |
|
238 |
|
239 //Stop position |
|
240 TTimeIntervalMicroSeconds iStopPosition; |
|
241 |
|
242 HBufC8* iMimeType; |
|
243 TBool iIntervalSec; |
|
244 CMMFAddDataSourceSinkAsync* iAddDataSourceSinkAsync; |
|
245 CMMSourceSink* iSource; |
|
246 |
|
247 ContentAccess::CContent* iContent; |
|
248 ContentAccess::CData* iData; |
|
249 }; |
|
250 |
|
251 #endif |