|
1 /* |
|
2 * Copyright (c) 2007 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: Handles the playing of sounds and tones for the Camera App* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 #ifndef CAMSOUNDPLAYER_H |
|
20 #define CAMSOUNDPLAYER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <MdaAudioTonePlayer.h> |
|
24 #include <MdaAudioSamplePlayer.h> |
|
25 #include "Cam.hrh" // For TCamSoundId |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // DATA TYPES |
|
32 |
|
33 // FUNCTION PROTOTYPES |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CAknKeySoundSystem; |
|
37 |
|
38 // CLASS DECLARATION |
|
39 |
|
40 |
|
41 /** |
|
42 * Observer class for getting notified when sound playback completes. |
|
43 */ |
|
44 class MCamSoundPlayerObserver |
|
45 { |
|
46 public: |
|
47 /** |
|
48 * CCamSoundPlayer has finished sound playback |
|
49 * and callback was requested (aEnableCallback was true |
|
50 * in CCamSoundPlayer::PlaySound()). |
|
51 * @since 2.8 |
|
52 */ |
|
53 virtual void PlaySoundComplete() = 0; |
|
54 }; |
|
55 |
|
56 /** |
|
57 * This class is used to play sounds and tones for the Camera app |
|
58 * |
|
59 * @since 2.8 |
|
60 */ |
|
61 class CCamSoundPlayer : public CBase, |
|
62 public MMdaAudioPlayerCallback, |
|
63 public MMdaAudioToneObserver |
|
64 { |
|
65 public: // Constructors and destructor |
|
66 |
|
67 /** |
|
68 * Two-phased constructor. |
|
69 * @param aObs Observer to be informed when sound playback is complete. |
|
70 */ |
|
71 static CCamSoundPlayer* NewL( MCamSoundPlayerObserver* aObs ); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 virtual ~CCamSoundPlayer(); |
|
77 |
|
78 public: // New functions |
|
79 |
|
80 /** |
|
81 * Initialises the sound player. |
|
82 * @since 2.8 |
|
83 */ |
|
84 void InitialiseL(); |
|
85 |
|
86 /** |
|
87 * Starts procedure to play the specified sound |
|
88 * @since 2.8 |
|
89 * @param aSound The sound to play |
|
90 * @param aEnableCallback Whether to call back when play complete |
|
91 */ |
|
92 void PlaySound( TCamSoundId aSound, TBool aEnableCallback ); |
|
93 |
|
94 /** |
|
95 * Initiates the playing of the specified tone |
|
96 * @since 2.8 |
|
97 * @param aToneHz The frequency of the tone to play in Hertz |
|
98 * @param aLenMicSec The length of tone to play in microseconds |
|
99 * @param aVolume The volume of the tone, range 0.0 to 1.0 |
|
100 * @param aEnableCallback Whether to be called back when playback complete |
|
101 */ |
|
102 void PlayTone( TInt aToneHz, TInt aLenMicSec, TReal32 aVolume, TBool aEnableCallback ); |
|
103 |
|
104 /** |
|
105 * Called to disable certain key press clicks |
|
106 * @since 2.8 |
|
107 */ |
|
108 void DisableSelectionKeySoundL(); |
|
109 |
|
110 /** |
|
111 * Called to enable certain key press clicks |
|
112 * @since 2.8 |
|
113 */ |
|
114 void EnableSelectionKeySound(); |
|
115 |
|
116 /** |
|
117 * Called to disable all key sounds, usually when video recording |
|
118 * is active |
|
119 * @since 2.8 |
|
120 */ |
|
121 void DisableAllKeySoundsL(); |
|
122 |
|
123 /** |
|
124 * Called to enable all key sounds, usually when video recording |
|
125 * is has stopped |
|
126 * @since 2.8 |
|
127 */ |
|
128 void EnableAllKeySounds(); |
|
129 |
|
130 /** |
|
131 * Cancels any outstanding tone player activity |
|
132 * @since 3.0 |
|
133 */ |
|
134 void CancelTonePlayer(); |
|
135 |
|
136 public: // Functions from base classes |
|
137 /** |
|
138 * From MMdaAudioPlayerCallback. |
|
139 * @since 2.8 |
|
140 */ |
|
141 void MapcInitComplete( TInt aError, |
|
142 const TTimeIntervalMicroSeconds& aDuration ); |
|
143 |
|
144 /** |
|
145 * From MMdaAudioPlayerCallback. |
|
146 * @since 2.8 |
|
147 */ |
|
148 void MapcPlayComplete( TInt aError ); |
|
149 |
|
150 /** |
|
151 * From MMdaAudioToneObserver. |
|
152 * @since 2.8 |
|
153 */ |
|
154 void MatoPrepareComplete( TInt aError ); |
|
155 |
|
156 /** |
|
157 * From MMdaAudioToneObserver. |
|
158 * @since 2.8 |
|
159 */ |
|
160 void MatoPlayComplete( TInt aError ); |
|
161 |
|
162 private: |
|
163 |
|
164 /** |
|
165 * C++ default constructor. |
|
166 * @since 2.8 |
|
167 * @param aObs Observer to be informed when sound playback is complete. |
|
168 */ |
|
169 CCamSoundPlayer( MCamSoundPlayerObserver* aObs ); |
|
170 |
|
171 /** |
|
172 * By default Symbian 2nd phase constructor is private. |
|
173 */ |
|
174 void ConstructL(); |
|
175 |
|
176 /** |
|
177 * Starts procedure to play audio (WAV) files. Internal function |
|
178 * @since 2.8 |
|
179 * @param aFile The file to open |
|
180 * @param aEnableCallback Whether to call back when play complete |
|
181 */ |
|
182 void StartPlaySound( const TDesC& aFile, const TBool aEnableCallback ); |
|
183 |
|
184 /** |
|
185 * Starts procedure to play audio Tone (and RNG) files. Internal function |
|
186 * @since 2.8 |
|
187 * @param aFile The file to open |
|
188 * @param aEnableCallback Whether to call back when play complete |
|
189 */ |
|
190 void StartPlayTone( const TDesC& aFile, const TBool aEnableCallback ); |
|
191 |
|
192 public: // Data |
|
193 |
|
194 // Audio player utility for WAV sounds (eg Video Recording) |
|
195 CMdaAudioPlayerUtility* iAudioPlayer; |
|
196 |
|
197 // Tone player for TONES (eg Video recording when in call) |
|
198 CMdaAudioToneUtility* iTonePlayer; |
|
199 |
|
200 // Key sound system for Self-timer sound and camera shutter. |
|
201 CAknKeySoundSystem* iKeySoundSystem; |
|
202 |
|
203 // Observer to notify when playback completes |
|
204 MCamSoundPlayerObserver* iObserver; |
|
205 |
|
206 // Whether file open is still in progress |
|
207 TBool iOpenFileInProgress; |
|
208 |
|
209 // Whether a callback for current sound has been requested |
|
210 TBool iEnableCallback; |
|
211 |
|
212 // Whether this class has been initialised yet |
|
213 TBool iInitialised; |
|
214 |
|
215 // Whether selection keys have been silenced |
|
216 TBool iSelectionKeySilent; |
|
217 |
|
218 // Whether all keys have been silenced |
|
219 TBool iAllKeysSilent; |
|
220 |
|
221 // Whether a tone is currently playing |
|
222 TBool iTonePlayInProgress; |
|
223 }; |
|
224 |
|
225 #endif // CAMSOUNDPLAYER_H |
|
226 |
|
227 // End of File |