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 __MMFCLIENTTONEPLAY_H__
|
sl@0
|
18 |
#define __MMFCLIENTTONEPLAY_H__
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
#include <e32std.h>
|
sl@0
|
22 |
#include <e32base.h>
|
sl@0
|
23 |
#include <mdaaudiotoneplayer.h>
|
sl@0
|
24 |
#include <mmf/server/sounddevice.h>
|
sl@0
|
25 |
#include <caf/data.h>
|
sl@0
|
26 |
#include <caf/content.h>
|
sl@0
|
27 |
//Panic category and codes
|
sl@0
|
28 |
_LIT(KMMFMdaAudioToneUtilityPanicCategory, "MMFMdaAudioToneUtility");
|
sl@0
|
29 |
enum TMMFMdaAudioToneUtilityPanicCodes
|
sl@0
|
30 |
{
|
sl@0
|
31 |
EMMFMdaAudioToneUtilityAlreadyPrepared,
|
sl@0
|
32 |
EMMFMdaAudioToneUtilityBadToneConfig,
|
sl@0
|
33 |
EMMFMdaAudioToneUtilityBadMixinCall
|
sl@0
|
34 |
};
|
sl@0
|
35 |
|
sl@0
|
36 |
/**
|
sl@0
|
37 |
Active object utility class to allow the callback to be called asynchronously.
|
sl@0
|
38 |
This should help prevent re-entrant code in clients of the mediaframework.
|
sl@0
|
39 |
*/
|
sl@0
|
40 |
class CMMFMdaAudioToneObserverCallback : public CActive, public MMdaAudioToneObserver, public MMdaAudioTonePlayStartObserver
|
sl@0
|
41 |
{
|
sl@0
|
42 |
public:
|
sl@0
|
43 |
static CMMFMdaAudioToneObserverCallback* NewL(MMdaAudioToneObserver& aCallback, MMdaAudioTonePlayStartObserver& aPlayStartCallback);
|
sl@0
|
44 |
~CMMFMdaAudioToneObserverCallback();
|
sl@0
|
45 |
// From MMdaAudioToneObserver
|
sl@0
|
46 |
virtual void MatoPrepareComplete(TInt aError);
|
sl@0
|
47 |
virtual void MatoPlayComplete(TInt aError);
|
sl@0
|
48 |
// From MMdaAudioTonePlayStartObserver
|
sl@0
|
49 |
virtual void MatoPlayStarted(TInt aError);
|
sl@0
|
50 |
private:
|
sl@0
|
51 |
CMMFMdaAudioToneObserverCallback(MMdaAudioToneObserver& aCallback, MMdaAudioTonePlayStartObserver& aPlayStartCallback);
|
sl@0
|
52 |
void RunL();
|
sl@0
|
53 |
void DoCancel();
|
sl@0
|
54 |
private:
|
sl@0
|
55 |
enum TMMFAudioToneObserverCallbackAction {EPrepareComplete, EPlayComplete, EPlayStarted};
|
sl@0
|
56 |
MMdaAudioToneObserver& iCallback;
|
sl@0
|
57 |
MMdaAudioTonePlayStartObserver& iPlayStartCallback;
|
sl@0
|
58 |
TMMFAudioToneObserverCallbackAction iAction;
|
sl@0
|
59 |
TInt iErrorCode;
|
sl@0
|
60 |
RArray <TInt> iCallBackQueue;
|
sl@0
|
61 |
RArray <TInt> iCallBackQueueError;
|
sl@0
|
62 |
};
|
sl@0
|
63 |
|
sl@0
|
64 |
class CMMFToneConfig;
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
Concrete implementation of the CMdaAudioToneUtility API.
|
sl@0
|
68 |
@see CMdaAudioToneUtility
|
sl@0
|
69 |
*/
|
sl@0
|
70 |
class CMMFMdaAudioToneUtility;
|
sl@0
|
71 |
NONSHARABLE_CLASS( CMMFMdaAudioToneUtility ): public CBase,
|
sl@0
|
72 |
public MMdaAudioToneObserver,
|
sl@0
|
73 |
public MDevSoundObserver,
|
sl@0
|
74 |
public MMdaAudioTonePlayStartObserver
|
sl@0
|
75 |
{
|
sl@0
|
76 |
friend class CMdaAudioToneUtility;
|
sl@0
|
77 |
// only for testing purposes
|
sl@0
|
78 |
friend class CTestStepUnitMMFAudClient;
|
sl@0
|
79 |
|
sl@0
|
80 |
public:
|
sl@0
|
81 |
static CMMFMdaAudioToneUtility* NewL(MMdaAudioToneObserver& aObserver, CMdaServer* aServer = NULL,
|
sl@0
|
82 |
TInt aPriority = EMdaPriorityNormal,
|
sl@0
|
83 |
TInt aPref = EMdaPriorityPreferenceTimeAndQuality);
|
sl@0
|
84 |
|
sl@0
|
85 |
~CMMFMdaAudioToneUtility();
|
sl@0
|
86 |
|
sl@0
|
87 |
TMdaAudioToneUtilityState State();
|
sl@0
|
88 |
TInt MaxVolume();
|
sl@0
|
89 |
TInt Volume();
|
sl@0
|
90 |
void SetVolume(TInt aVolume);
|
sl@0
|
91 |
void SetPriority(TInt aPriority, TInt aPref);
|
sl@0
|
92 |
void SetDTMFLengths(TTimeIntervalMicroSeconds32 aToneLength,
|
sl@0
|
93 |
TTimeIntervalMicroSeconds32 aToneOffLength,
|
sl@0
|
94 |
TTimeIntervalMicroSeconds32 aPauseLength);
|
sl@0
|
95 |
void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
|
sl@0
|
96 |
void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
|
sl@0
|
97 |
TInt FixedSequenceCount();
|
sl@0
|
98 |
const TDesC& FixedSequenceName(TInt aSequenceNumber);
|
sl@0
|
99 |
void PrepareToPlayTone(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
|
sl@0
|
100 |
void PrepareToPlayDualTone(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration);
|
sl@0
|
101 |
void PrepareToPlayDTMFString(const TDesC& aDTMF);
|
sl@0
|
102 |
void PrepareToPlayDesSequence(const TDesC8& aSequence);
|
sl@0
|
103 |
void PrepareToPlayFileSequence(const TDesC& aFileName);
|
sl@0
|
104 |
void PrepareToPlayFileSequence(RFile& aFile);
|
sl@0
|
105 |
void PrepareToPlayFixedSequence(TInt aSequenceNumber);
|
sl@0
|
106 |
void CancelPrepare();
|
sl@0
|
107 |
void Play();
|
sl@0
|
108 |
void CancelPlay();
|
sl@0
|
109 |
TInt Pause();
|
sl@0
|
110 |
TInt Resume();
|
sl@0
|
111 |
|
sl@0
|
112 |
void SetBalanceL(TInt aBalance=KMMFBalanceCenter);
|
sl@0
|
113 |
TInt GetBalanceL();
|
sl@0
|
114 |
// From MMdaAudioToneObserver
|
sl@0
|
115 |
void MatoPrepareComplete(TInt aError);
|
sl@0
|
116 |
void MatoPlayComplete(TInt aError);
|
sl@0
|
117 |
|
sl@0
|
118 |
// From DevSoundObserver
|
sl@0
|
119 |
void InitializeComplete(TInt aError);
|
sl@0
|
120 |
void ToneFinished(TInt aError);
|
sl@0
|
121 |
void BufferToBeFilled(CMMFBuffer* /*aBuffer*/) {User::Panic(KMMFMdaAudioToneUtilityPanicCategory,EMMFMdaAudioToneUtilityBadMixinCall);}
|
sl@0
|
122 |
void PlayError(TInt /*aError*/) {User::Panic(KMMFMdaAudioToneUtilityPanicCategory,EMMFMdaAudioToneUtilityBadMixinCall);}
|
sl@0
|
123 |
void BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) {User::Panic(KMMFMdaAudioToneUtilityPanicCategory,EMMFMdaAudioToneUtilityBadMixinCall);}
|
sl@0
|
124 |
void RecordError(TInt /*aError*/) {User::Panic(KMMFMdaAudioToneUtilityPanicCategory,EMMFMdaAudioToneUtilityBadMixinCall);}
|
sl@0
|
125 |
void ConvertError(TInt /*aError*/) {User::Panic(KMMFMdaAudioToneUtilityPanicCategory,EMMFMdaAudioToneUtilityBadMixinCall);}
|
sl@0
|
126 |
void DeviceMessage(TUid /*aMessageId*/, const TDesC8& /*aMsg*/) {User::Panic(KMMFMdaAudioToneUtilityPanicCategory,EMMFMdaAudioToneUtilityBadMixinCall);}
|
sl@0
|
127 |
void SendEventToClient(const TMMFEvent& /*aEvent*/);
|
sl@0
|
128 |
|
sl@0
|
129 |
TAny* CustomInterface(TUid aInterfaceId);
|
sl@0
|
130 |
|
sl@0
|
131 |
void PlayAfterInitialized();
|
sl@0
|
132 |
|
sl@0
|
133 |
void RegisterPlayStartCallback(MMdaAudioTonePlayStartObserver& aObserver);
|
sl@0
|
134 |
|
sl@0
|
135 |
// From MMdaAudioTonePlayStartObserver
|
sl@0
|
136 |
void MatoPlayStarted(TInt aError);
|
sl@0
|
137 |
|
sl@0
|
138 |
protected:
|
sl@0
|
139 |
CMMFMdaAudioToneUtility(MMdaAudioToneObserver& aCallback, TInt aPriority, TInt aPref);
|
sl@0
|
140 |
void ConstructL();
|
sl@0
|
141 |
private:
|
sl@0
|
142 |
// functions to convert between MediaServer Balance and SoundDev balance
|
sl@0
|
143 |
void CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const;
|
sl@0
|
144 |
void CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const;
|
sl@0
|
145 |
|
sl@0
|
146 |
private:
|
sl@0
|
147 |
CMMFDevSound* iDevSound;
|
sl@0
|
148 |
MMdaAudioToneObserver& iCallback;
|
sl@0
|
149 |
CMMFMdaAudioToneObserverCallback* iAsyncCallback;
|
sl@0
|
150 |
|
sl@0
|
151 |
CMMFToneConfig* iToneConfig;
|
sl@0
|
152 |
// Devsound doesn't take copies of descriptors we pass to it, so we
|
sl@0
|
153 |
// need to cache the config info until it has finished playing.
|
sl@0
|
154 |
CMMFToneConfig* iPlayingToneConfig; //unused remove when BC break allowed
|
sl@0
|
155 |
|
sl@0
|
156 |
TMdaAudioToneUtilityState iState;
|
sl@0
|
157 |
|
sl@0
|
158 |
TMMFPrioritySettings iPrioritySettings;
|
sl@0
|
159 |
|
sl@0
|
160 |
TInt iInitializeState;
|
sl@0
|
161 |
|
sl@0
|
162 |
TInt iSequenceNumber;
|
sl@0
|
163 |
TBool iPlayCalled;
|
sl@0
|
164 |
|
sl@0
|
165 |
TBool iInitialized;
|
sl@0
|
166 |
|
sl@0
|
167 |
MMdaAudioTonePlayStartObserver* iPlayStartObserver;
|
sl@0
|
168 |
|
sl@0
|
169 |
#ifdef _DEBUG
|
sl@0
|
170 |
TBool iPlayCalledBeforeInitialized;
|
sl@0
|
171 |
#endif
|
sl@0
|
172 |
};
|
sl@0
|
173 |
|
sl@0
|
174 |
|
sl@0
|
175 |
// Tone configurations
|
sl@0
|
176 |
class CMMFToneConfig : public CBase
|
sl@0
|
177 |
{
|
sl@0
|
178 |
public:
|
sl@0
|
179 |
enum TMMFToneType
|
sl@0
|
180 |
{
|
sl@0
|
181 |
EMmfToneTypeSimple,
|
sl@0
|
182 |
EMmfToneTypeDTMF,
|
sl@0
|
183 |
EMmfToneTypeDesSeq,
|
sl@0
|
184 |
EMmfToneTypeFileSeq,
|
sl@0
|
185 |
EMmfToneTypeFixedSeq,
|
sl@0
|
186 |
EMmfToneTypeDual,
|
sl@0
|
187 |
};
|
sl@0
|
188 |
virtual ~CMMFToneConfig() {}
|
sl@0
|
189 |
TMMFToneType Type() {return iType;}
|
sl@0
|
190 |
protected:
|
sl@0
|
191 |
CMMFToneConfig(TMMFToneType aType) : iType(aType) {}
|
sl@0
|
192 |
private:
|
sl@0
|
193 |
TMMFToneType iType;
|
sl@0
|
194 |
};
|
sl@0
|
195 |
|
sl@0
|
196 |
class CMMFSimpleToneConfig : public CMMFToneConfig
|
sl@0
|
197 |
{
|
sl@0
|
198 |
public:
|
sl@0
|
199 |
static CMMFToneConfig* NewL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
|
sl@0
|
200 |
virtual ~CMMFSimpleToneConfig();
|
sl@0
|
201 |
TInt Frequency();
|
sl@0
|
202 |
const TTimeIntervalMicroSeconds& Duration();
|
sl@0
|
203 |
protected:
|
sl@0
|
204 |
CMMFSimpleToneConfig(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
|
sl@0
|
205 |
private:
|
sl@0
|
206 |
TInt iFrequency;
|
sl@0
|
207 |
TTimeIntervalMicroSeconds iDuration;
|
sl@0
|
208 |
};
|
sl@0
|
209 |
|
sl@0
|
210 |
class CMMFDualToneConfig : public CMMFToneConfig
|
sl@0
|
211 |
{
|
sl@0
|
212 |
public:
|
sl@0
|
213 |
static CMMFToneConfig* NewL(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration);
|
sl@0
|
214 |
virtual ~CMMFDualToneConfig();
|
sl@0
|
215 |
TInt FrequencyOne();
|
sl@0
|
216 |
TInt FrequencyTwo();
|
sl@0
|
217 |
const TTimeIntervalMicroSeconds& Duration();
|
sl@0
|
218 |
protected:
|
sl@0
|
219 |
CMMFDualToneConfig(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration);
|
sl@0
|
220 |
private:
|
sl@0
|
221 |
TInt iFrequencyOne;
|
sl@0
|
222 |
TInt iFrequencyTwo;
|
sl@0
|
223 |
TTimeIntervalMicroSeconds iDuration;
|
sl@0
|
224 |
};
|
sl@0
|
225 |
|
sl@0
|
226 |
class CMMFDTMFStringToneConfig : public CMMFToneConfig
|
sl@0
|
227 |
{
|
sl@0
|
228 |
public:
|
sl@0
|
229 |
static CMMFToneConfig* NewL(const TDesC& aDTMF);
|
sl@0
|
230 |
static CMMFToneConfig* NewL(RFile& aFile);
|
sl@0
|
231 |
virtual ~CMMFDTMFStringToneConfig();
|
sl@0
|
232 |
const TDesC& DTMF();
|
sl@0
|
233 |
protected:
|
sl@0
|
234 |
CMMFDTMFStringToneConfig();
|
sl@0
|
235 |
void ConstructL(const TDesC& aDTMF);
|
sl@0
|
236 |
private:
|
sl@0
|
237 |
HBufC* iDTMF;
|
sl@0
|
238 |
};
|
sl@0
|
239 |
|
sl@0
|
240 |
class CMMFDesSeqToneConfig : public CMMFToneConfig
|
sl@0
|
241 |
{
|
sl@0
|
242 |
public:
|
sl@0
|
243 |
static CMMFToneConfig* NewL(const TDesC8& aDesSeq);
|
sl@0
|
244 |
virtual ~CMMFDesSeqToneConfig();
|
sl@0
|
245 |
const TDesC8& DesSeq();
|
sl@0
|
246 |
protected:
|
sl@0
|
247 |
CMMFDesSeqToneConfig();
|
sl@0
|
248 |
void ConstructL(const TDesC8& aDesSeq);
|
sl@0
|
249 |
private:
|
sl@0
|
250 |
HBufC8* iDesSeq;
|
sl@0
|
251 |
};
|
sl@0
|
252 |
|
sl@0
|
253 |
|
sl@0
|
254 |
class CMMFFileSeqToneConfig : public CMMFToneConfig
|
sl@0
|
255 |
{
|
sl@0
|
256 |
public:
|
sl@0
|
257 |
static CMMFToneConfig* NewL(const TDesC& aFileSeq);
|
sl@0
|
258 |
static CMMFToneConfig* NewL(RFile& aFile);
|
sl@0
|
259 |
virtual ~CMMFFileSeqToneConfig();
|
sl@0
|
260 |
const TDesC8& FileSeq();
|
sl@0
|
261 |
|
sl@0
|
262 |
// CAF support for Tone Utility
|
sl@0
|
263 |
void ExecuteIntentL();
|
sl@0
|
264 |
protected:
|
sl@0
|
265 |
CMMFFileSeqToneConfig();
|
sl@0
|
266 |
void ConstructL(const TDesC& aFileSeq);
|
sl@0
|
267 |
void ConstructL(RFile& aFile);
|
sl@0
|
268 |
private:
|
sl@0
|
269 |
ContentAccess::CContent* iCAFContent;
|
sl@0
|
270 |
ContentAccess::CData* iCAFData;
|
sl@0
|
271 |
HBufC8* iDesSeq;
|
sl@0
|
272 |
};
|
sl@0
|
273 |
|
sl@0
|
274 |
class CMMFFixedSeqToneConfig : public CMMFToneConfig
|
sl@0
|
275 |
{
|
sl@0
|
276 |
public:
|
sl@0
|
277 |
static CMMFToneConfig* NewL(TInt aSeqNo);
|
sl@0
|
278 |
virtual ~CMMFFixedSeqToneConfig();
|
sl@0
|
279 |
TInt SequenceNumber();
|
sl@0
|
280 |
protected:
|
sl@0
|
281 |
CMMFFixedSeqToneConfig(TInt aSeqNo);
|
sl@0
|
282 |
private:
|
sl@0
|
283 |
TInt iSequenceNumber;
|
sl@0
|
284 |
};
|
sl@0
|
285 |
|
sl@0
|
286 |
#endif
|