|
1 /* |
|
2 * Copyright (c) 2002 - 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: |
|
15 * This class acts as a high level wrapper around the media server |
|
16 * playback and recording functionalities. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef __CVRMDARECORDER_H__ |
|
22 #define __CVRMDARECORDER_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32property.h> |
|
26 #include <mdaaudiosampleeditor.h> |
|
27 #include <hwrmlight.h> |
|
28 |
|
29 #include "MVRMdaRecorder.h" |
|
30 #include "MVRUpdateEventProvider.h" |
|
31 |
|
32 #include <AudioInput.h> |
|
33 // FORWARD DECLARATIONS |
|
34 class CVRSystemEventHandler; |
|
35 class CAknGlobalNote; |
|
36 class CMdaAudioRecorderUtility; |
|
37 class CVRMemo; |
|
38 class MVRObserver; |
|
39 class CErrorUI; |
|
40 class CAudioOutput; |
|
41 class CVRTonePlayer; |
|
42 class CVRDiskSpaceWatcher; |
|
43 class CAudioInput; |
|
44 |
|
45 // CLASS DEFINITION |
|
46 /** |
|
47 * This class acts as a high level wrapper around the media server |
|
48 * playback and recording functionalities. |
|
49 */ |
|
50 NONSHARABLE_CLASS( CVRMdaRecorder ) |
|
51 : public CBase, public MVRMdaRecorder, |
|
52 public MMdaObjectStateChangeObserver, |
|
53 public MVRUpdateEventProvider, |
|
54 public MHWRMLightObserver // for light control |
|
55 { |
|
56 public: // Constructors and destructor |
|
57 |
|
58 /** |
|
59 * Default constructor |
|
60 */ |
|
61 CVRMdaRecorder(); |
|
62 |
|
63 /** |
|
64 * Destructor |
|
65 */ |
|
66 ~CVRMdaRecorder(); |
|
67 |
|
68 /** |
|
69 * 2nd phase constructor |
|
70 */ |
|
71 void ConstructL(); |
|
72 |
|
73 public: // from MMdaObjectStateChangeObserver |
|
74 |
|
75 /** |
|
76 * Encapsulates the interface for handling the change of state of |
|
77 * an audio data sample object. |
|
78 * @param aObject A pointer to the audio sample object that has |
|
79 * changed state. |
|
80 * @param aPreviousState The state before the change |
|
81 * @param aCurrentState The state after the change |
|
82 * @param aErrorCode If not KErrNone, then the error that |
|
83 * caused the state change |
|
84 */ |
|
85 void MoscoStateChangeEvent( CBase* aObject, TInt aPreviousState, |
|
86 TInt aCurrentState, TInt aErrorCode ); |
|
87 |
|
88 /** |
|
89 * Registers an observer for receiving update notifications. |
|
90 * @param aObserver The observer object. |
|
91 */ |
|
92 void RegisterObserver( MVRObserver* aObserver ); |
|
93 |
|
94 /** |
|
95 * Unregisters a previously registered observer |
|
96 * @param aObserver The observer object. |
|
97 */ |
|
98 void UnregisterObserver( MVRObserver* aObserver ); |
|
99 |
|
100 /** |
|
101 * Registers an observer for receiving auto stop notifications. |
|
102 * @param aObserver The observer object. |
|
103 */ |
|
104 void SetAutoStopObserver( MVRObserver* aObserver ); |
|
105 |
|
106 /** |
|
107 * Attachs this recorder to a memo file, i.e. opens it |
|
108 * and initialises media server. |
|
109 * @param aMemo Specifies the file to be attached to. |
|
110 */ |
|
111 void AttachToMemoL( CVRMemo* aMemo ); |
|
112 |
|
113 /** |
|
114 * Creates a new memo file and attachs to it. |
|
115 * @param aMemo Specifies the file to be created. |
|
116 */ |
|
117 void CreateNewMemoL( CVRMemo* aMemo ); |
|
118 |
|
119 /** |
|
120 * Detachs from the current memo, i.e. closes the file. |
|
121 */ |
|
122 void DetachMemo(); |
|
123 |
|
124 /** |
|
125 * Sets playback volume. |
|
126 * @param aStep Volume level in steps |
|
127 * @param aMaxSteps How many steps there are (10 usually). |
|
128 */ |
|
129 void SetVolume( TInt aStep, TInt aMaxSteps ); |
|
130 |
|
131 /** |
|
132 * Starts playback. |
|
133 * @return System wide error code |
|
134 */ |
|
135 TInt PlayL(); |
|
136 |
|
137 /** |
|
138 * Starts recording. |
|
139 * @return System wide error code |
|
140 */ |
|
141 TInt RecordL(); |
|
142 |
|
143 /** |
|
144 * Stops playback or recording. |
|
145 */ |
|
146 void Stop(); |
|
147 |
|
148 /** |
|
149 * Pauses playback or recording. |
|
150 */ |
|
151 void Pause(); |
|
152 |
|
153 /** |
|
154 * Moves the playing position forward 5 seconds. |
|
155 * @return System wide error code. KErrOverflow if the |
|
156 * position was forwarded past the end. |
|
157 */ |
|
158 TInt ForwardL(); |
|
159 |
|
160 /** |
|
161 * Moves the playing position backward 5 seconds. |
|
162 * @return System wide error code |
|
163 */ |
|
164 TInt RewindL(); |
|
165 |
|
166 /** |
|
167 * Indicates if we are in a state that can accept |
|
168 * more commands (i.e. all async calls have completed). |
|
169 * @return ETrue if it's ok to proceed calling methods. |
|
170 */ |
|
171 TBool CanAcceptCommands() const; |
|
172 |
|
173 /** |
|
174 * Set active speaker if feature is supported |
|
175 * @param aEnabled ETrue if playback should be routed to IHF |
|
176 * @return Error code returned by routing operation |
|
177 */ |
|
178 TInt SetIhf( TBool aEnabled ); |
|
179 |
|
180 /** |
|
181 * Set the audio recorder position to a new value |
|
182 * @param aSeconds The position to set |
|
183 */ |
|
184 void SetPositionL( TInt aSeconds ); |
|
185 |
|
186 /** |
|
187 * From MBacklightControlObserver. |
|
188 * Callback for change in backlight status |
|
189 * |
|
190 * @since S60 ?S60_version |
|
191 * @param aTarget The target of light change event; keypad, screen or both |
|
192 * @param aTarget New status of the target |
|
193 */ |
|
194 void LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus); |
|
195 |
|
196 /** |
|
197 * Returns iInRecording flag |
|
198 * @return True or False |
|
199 */ |
|
200 TBool GetInRecordingFlag(); |
|
201 |
|
202 /** |
|
203 * set iInRecording flag |
|
204 * |
|
205 */ |
|
206 void SetInRecordingFlag(TBool); |
|
207 |
|
208 /** |
|
209 * Returns ifStopCalled flag |
|
210 * @return True or False |
|
211 */ |
|
212 TBool GetIfStopCalled(); |
|
213 |
|
214 /** |
|
215 * set ifStopCalled flag |
|
216 * |
|
217 */ |
|
218 void SetIfStopCalled(TBool); |
|
219 |
|
220 /** |
|
221 * return the iIsAttachToMemo flag |
|
222 * |
|
223 */ |
|
224 TBool IsAttachedToMemo(); |
|
225 /** |
|
226 * Sets the AudioInput. |
|
227 * |
|
228 * Leaves on error. |
|
229 */ |
|
230 void SetAudioInputL(CAudioInput::TAudioInputPreference aAudioInput); |
|
231 |
|
232 /** |
|
233 * set sample rate during voice call |
|
234 * |
|
235 */ |
|
236 void ConfigSampleRateOfVoiceCallL(); |
|
237 |
|
238 public: |
|
239 friend class CVRDiskSpaceWatcher; |
|
240 |
|
241 private: // new methods |
|
242 |
|
243 /** |
|
244 * Moves the playing position to beginning. |
|
245 */ |
|
246 void ResetPosition(); |
|
247 |
|
248 /** |
|
249 * Stops playing or recording and notifies the observer |
|
250 * registered with SetAutoStopObserver(). |
|
251 */ |
|
252 void StopAndNotify(); |
|
253 |
|
254 /** |
|
255 * Updates duration and position fields in CVRMemo |
|
256 * and notifies the observer registered with SetObserver(); |
|
257 */ |
|
258 void SyncAndNotify(); |
|
259 |
|
260 /** |
|
261 * Creates and starts a CPeriodic timer object |
|
262 * with a resolution of one second. |
|
263 */ |
|
264 void StartTimerL(); |
|
265 |
|
266 /** |
|
267 * Stops and deletes the timer object. |
|
268 */ |
|
269 void StopTimer(); |
|
270 |
|
271 /** |
|
272 * Called by the CPeriodic timer to handle a tick. |
|
273 * Uses HandleTick() to do the actual work. |
|
274 * @param aMdaRecorder Always a valid pointer to CVRMdaRecorder object |
|
275 * @return ETrue to indicate that the timer should continue. |
|
276 */ |
|
277 static TInt TimerCallBack( TAny* aMdaRecorder ); |
|
278 |
|
279 /** |
|
280 * Non-static variant of TimerCallBack (more convinient to implement). |
|
281 */ |
|
282 void HandleTick(); |
|
283 |
|
284 /** |
|
285 * Moves the playing position forward or backward. |
|
286 * @param aSeconds Negative for bacward, positive for forward |
|
287 * @return EFalse if the position moved past the end |
|
288 */ |
|
289 TBool MovePositionL( TInt aSeconds ); |
|
290 |
|
291 /** |
|
292 * Configures the memo to be recorded. |
|
293 * |
|
294 * This function reads configuration data (bitrate, sampling rate, |
|
295 * mono/stereo information from utility and configures the clip opened |
|
296 * recording. |
|
297 * |
|
298 * Leaves on error. |
|
299 * |
|
300 */ |
|
301 void ConfigureMemoL(); |
|
302 |
|
303 |
|
304 /** |
|
305 * Creates the AudioInput. |
|
306 * |
|
307 * Leaves on error. |
|
308 */ |
|
309 void CreateAudioInputL(); |
|
310 |
|
311 |
|
312 /** |
|
313 * Deletes the AudioInput. |
|
314 * |
|
315 */ |
|
316 void DeleteAudioInput(); |
|
317 |
|
318 |
|
319 |
|
320 private: // data |
|
321 |
|
322 /** |
|
323 * For listening call events. Owned. |
|
324 */ |
|
325 CVRSystemEventHandler* iCurrentCallHandler; |
|
326 |
|
327 /** |
|
328 * Pointer to the media server audio recorder object. Owned. |
|
329 */ |
|
330 CMdaAudioRecorderUtility* iAudioRecorder; |
|
331 |
|
332 /** |
|
333 * Pointer to the voice memo object. Not owned. |
|
334 */ |
|
335 CVRMemo* iMemo; |
|
336 |
|
337 /** |
|
338 * Pointer to the timer object. Owned. |
|
339 */ |
|
340 CPeriodic* iTimer; |
|
341 |
|
342 /** |
|
343 * Pointers to the memo status observers. Not owned. |
|
344 */ |
|
345 RPointerArray<MVRObserver> iObservers; |
|
346 |
|
347 /** |
|
348 * Pointer to the auto stop (non-user initiated) observer. Not owned. |
|
349 */ |
|
350 MVRObserver* iAutoStopObserver; |
|
351 |
|
352 |
|
353 /** |
|
354 * ETrue if a memo is currently attached. |
|
355 */ |
|
356 TBool iIsAttachedToMemo; |
|
357 |
|
358 /** |
|
359 * Identifies the last media server error, or KErrNone. |
|
360 */ |
|
361 TInt iMediaServerError; |
|
362 |
|
363 /** |
|
364 * CActiveScheduler wrapper object. Owned. |
|
365 */ |
|
366 CActiveSchedulerWait iActiveWait; |
|
367 |
|
368 /** |
|
369 * Pointer to the generic error note object. Owned. |
|
370 */ |
|
371 CAknGlobalNote* iGlobalNote; |
|
372 |
|
373 /** |
|
374 * Pointer to a Error UI object. Owned. |
|
375 * Used for showing system error notes |
|
376 */ |
|
377 CErrorUI* iErrorUI; |
|
378 |
|
379 /** |
|
380 * Pub&Sub property. |
|
381 * For notifying voice dialing about the state of voice recorder |
|
382 */ |
|
383 RProperty iPropVRState; |
|
384 |
|
385 /** |
|
386 * Pub&Sub property. |
|
387 * For checking and setting the state of the screen saver. |
|
388 */ |
|
389 RProperty iPropScreenSaver; |
|
390 |
|
391 /** |
|
392 * Fix for pause problem |
|
393 */ |
|
394 TBool iPause; |
|
395 |
|
396 /** |
|
397 * For storing current position |
|
398 */ |
|
399 TTimeIntervalMicroSeconds iPosition; |
|
400 |
|
401 /** |
|
402 * For playing the recording start and stop tones. Owned. |
|
403 */ |
|
404 CVRTonePlayer* iTonePlayer; |
|
405 |
|
406 /** |
|
407 * Pointer to the CHWRMLight. owned. |
|
408 */ |
|
409 CHWRMLight* iLight; |
|
410 |
|
411 /** |
|
412 * State of the Light. If EFalse the dimmed light is set as off |
|
413 * causes no action. |
|
414 */ |
|
415 TBool iDimLight; |
|
416 |
|
417 // Boolean to maintain attaching to memo state. |
|
418 TBool iAttachingToMemo; |
|
419 |
|
420 /** |
|
421 * Returns if Voice Recorder start to record new file (real recording not necessary started) . |
|
422 * @return True or False |
|
423 */ |
|
424 TBool ifInRecording; |
|
425 |
|
426 |
|
427 /** |
|
428 * Returns if Voice Recorder has called stoped, if so should not handle Pause . |
|
429 * @return True or False |
|
430 */ |
|
431 TBool ifStopCalled; |
|
432 |
|
433 |
|
434 CVRDiskSpaceWatcher* iDiskSpaceWatcher; |
|
435 CAudioInput* iAudioInput; |
|
436 CAudioInput::TAudioInputPreference iCurrentAudioInput; |
|
437 |
|
438 |
|
439 }; |
|
440 |
|
441 #endif // __CVRMDARECORDER_H__ |