1 // Copyright (c) 2002-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MDAAUDIOTONEPLAYER_H__
17 #define __MDAAUDIOTONEPLAYER_H__
21 #include <mmf/common/mmfbase.h>
22 #include <mmf/common/mmfstandardcustomcommands.h>
23 #include <mmfclntutility.h>
32 The state of the audio tone utility.
34 enum TMdaAudioToneUtilityState
36 /** The audio tone utility has not been prepared to play a tone.
38 EMdaAudioToneUtilityNotReady=0,
39 /** The audio tone utility has been prepared to play a tone and is ready.
41 EMdaAudioToneUtilityPrepared,
42 /** The audio tone utility is currently playing a tone.
44 EMdaAudioToneUtilityPlaying,
45 /** The audio tone utility is currently paused.
46 This state is only reached if underlying DevSound implementations supports resume.
48 EMdaAudioToneUtilityPaused
51 const TInt KMdaInfiniteDurationDTMFToneOnLength = -1;
52 const TInt KMdaAudioToneRepeatForever = -2;
58 An interface to a set of audio tone player callback functions.
60 The class is a mixin and is intended to be inherited by the client
61 class which is observing the audio tone playing operation. The
62 functions encapsulated by this class are called when specific events
63 occur in the process of preparing to play a tone and during the
64 playing of a tone. A reference to this object is passed as a
65 parameter when constructing an audio tone player utility, using the
66 CMdaAudioToneUtility interface.
70 class MMdaAudioToneObserver
75 Defines required client behaviour when an attempt to configure the
76 audio tone player utility has completed, successfully or otherwise.
79 KErrNone if successful. One of the system
80 wide error codes if the attempt failed. The possible
81 values depend on the EPOC platform.
83 virtual void MatoPrepareComplete(TInt aError) = 0;
86 Defines required client behaviour when the tone playing operation has
87 completed, successfully or otherwise.
90 KErrNone if successful. One of the system
91 wide error codes if the attempt failed. The possible
92 values depend on the EPOC platform.
94 virtual void MatoPlayComplete(TInt aError) = 0;
98 class MMdaAudioTonePlayStartObserver
102 Defines required client behaviour when the tone playing operation has
103 started, successfully or otherwise.
106 KErrNone if successful. One of the system
107 wide error codes if the attempt failed. The possible
108 values depend on the EPOC platform.
110 virtual void MatoPlayStarted(TInt aError) = 0;
114 class CMMFMdaAudioToneUtility;
120 Generates tones on an audio capable EPOC device.
122 The class offers an interface for generating tones on all audio
123 capable EPOC devices.
125 To use the tone utility:
127 1. Create an instance by calling NewL().
129 2. Call the appropriate PrepareToPlay variant for the required tone type
130 and wait for the callback indicating success.
132 3. Call Play and either wait for the callback to indicate completion,
133 or call CancelPlay to end playback early.
135 4. Delete the instance.
137 It is possible to call Play before calling any PrepareToPlay variant. This
138 will result in a default fixed sequence tone being played.
142 class CMdaAudioToneUtility : public CBase,
143 public MMMFClientUtility
147 IMPORT_C static CMdaAudioToneUtility* NewL(MMdaAudioToneObserver& aObserver, CMdaServer* aServer = NULL);
149 IMPORT_C static CMdaAudioToneUtility* NewL(MMdaAudioToneObserver& aObserver, CMdaServer* aServer,
151 TInt aPref = EMdaPriorityPreferenceTimeAndQuality);
153 ~CMdaAudioToneUtility();
155 virtual TMdaAudioToneUtilityState State();
157 virtual TInt MaxVolume();
159 virtual TInt Volume();
161 virtual void SetVolume(TInt aVolume);
163 virtual void SetPriority(TInt aPriority, TInt aPref);
165 virtual void SetDTMFLengths(TTimeIntervalMicroSeconds32 aToneLength,
166 TTimeIntervalMicroSeconds32 aToneOffLength,
167 TTimeIntervalMicroSeconds32 aPauseLength);
169 virtual void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
171 virtual void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
173 virtual TInt FixedSequenceCount();
175 virtual const TDesC& FixedSequenceName(TInt aSequenceNumber);
177 virtual void PrepareToPlayTone(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
179 virtual void PrepareToPlayDTMFString(const TDesC& aDTMF);
181 virtual void PrepareToPlayDesSequence(const TDesC8& aSequence);
183 virtual void PrepareToPlayFileSequence(const TDesC& aFileName);
185 virtual void PrepareToPlayFixedSequence(TInt aSequenceNumber);
187 virtual void CancelPrepare();
191 virtual void CancelPlay();
193 IMPORT_C TInt Pause();
195 IMPORT_C TInt Resume();
197 IMPORT_C void SetBalanceL(TInt aBalance=KMMFBalanceCenter);
199 IMPORT_C TInt GetBalanceL();
201 IMPORT_C void PrepareToPlayDualTone(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration);
203 IMPORT_C void PrepareToPlayFileSequence(RFile& aFile);
205 IMPORT_C TAny* CustomInterface(TUid aInterfaceId);
207 IMPORT_C void RegisterPlayStartCallback(MMdaAudioTonePlayStartObserver& aObserver);
211 This member is internal and not intended for use.
213 CMMFMdaAudioToneUtility* iProperties;