author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:34:59 +0300 | |
branch | RCL_3 |
changeset 29 | c9b63fff5abf |
parent 25 | c6bafb5162d8 |
permissions | -rw-r--r-- |
25 | 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 |
// INCLUDE FILES |
|
22 |
#include "CVRSystemEventHandler.h" |
|
23 |
#include <ctsydomainpskeys.h> |
|
24 |
||
25 |
#include <e32svr.h> |
|
26 |
#include <bautils.h> |
|
27 |
#include <eikenv.h> |
|
28 |
#include <aknappui.h> |
|
29 |
#include <e32property.h> |
|
30 |
#include <AudioPreference.h> |
|
31 |
#include <aknsoundsystem.h> |
|
32 |
#include <ScreensaverInternalPSKeys.h> |
|
33 |
#include <AknGlobalNote.h> |
|
34 |
#include <StringLoader.h> |
|
35 |
#include <ErrorUI.h> |
|
36 |
#include <sysutil.h> |
|
37 |
||
38 |
#include <featmgr.h> // Feature manager |
|
39 |
||
40 |
#include <voicerecorder.rsg> |
|
41 |
#include <VoiceRecorderUID.h> |
|
42 |
#include "VoiceRecorderPrivatePSKeys.h" |
|
43 |
#include "CVRMemo.h" |
|
44 |
#include "MVRObserver.h" |
|
45 |
#include "VRConsts.h" |
|
46 |
#include "VRUtils.h" |
|
47 |
#include "CVRTonePlayer.h" |
|
48 |
#include "CVRMdaRecorder.h" |
|
49 |
#include "CVRDiskSpaceWatcher.h" |
|
50 |
#include "CVRRecViewModel.h" |
|
51 |
#include <AudioInput.h> |
|
52 |
||
53 |
||
54 |
// MACROS |
|
55 |
#ifdef _DEBUG |
|
56 |
#define DEB_PRN_0(str) RDebug::Print(str) |
|
57 |
#else |
|
58 |
#define DEB_PRN_0(str) |
|
59 |
#endif |
|
60 |
||
61 |
// CONSTANTS |
|
62 |
const TInt KVRMdaRecorderDefaultStep( 5 ); |
|
63 |
const TInt KVRObserverArrayGranularity( 2 ); |
|
64 |
const TInt KVRMaxNoteLabelLength( 256 ); |
|
65 |
||
66 |
||
67 |
// ================= MEMBER FUNCTIONS ======================================== |
|
68 |
||
69 |
// --------------------------------------------------------------------------- |
|
70 |
// CVRMdaRecorder::CVRMdaRecorder |
|
71 |
// |
|
72 |
// --------------------------------------------------------------------------- |
|
73 |
// |
|
74 |
CVRMdaRecorder::CVRMdaRecorder() : |
|
75 |
iObservers( KVRObserverArrayGranularity ), |
|
76 |
iIsAttachedToMemo( EFalse ), |
|
77 |
iMediaServerError( KErrNone ), |
|
78 |
iDimLight (EFalse), |
|
79 |
iAttachingToMemo(EFalse), |
|
80 |
ifInRecording(EFalse), |
|
81 |
ifStopCalled(EFalse) |
|
82 |
{ |
|
83 |
} |
|
84 |
||
85 |
||
86 |
// --------------------------------------------------------------------------- |
|
87 |
// CVRMdaRecorder::~CVRMdaRecorder |
|
88 |
// |
|
89 |
// --------------------------------------------------------------------------- |
|
90 |
// |
|
91 |
CVRMdaRecorder::~CVRMdaRecorder() |
|
92 |
{ |
|
93 |
||
94 |
delete iGlobalNote; |
|
95 |
delete iAudioInput; |
|
96 |
delete iAudioRecorder; |
|
97 |
delete iErrorUI; |
|
98 |
delete iTimer; |
|
99 |
delete iTonePlayer; |
|
100 |
delete iLight; |
|
101 |
delete iDiskSpaceWatcher; |
|
102 |
iObservers.Close(); |
|
103 |
||
104 |
if (iCurrentCallHandler) |
|
105 |
{ |
|
106 |
delete iCurrentCallHandler; |
|
107 |
} |
|
108 |
} |
|
109 |
||
110 |
||
111 |
// --------------------------------------------------------------------------- |
|
112 |
// CVRMdaRecorder::ConstructL |
|
113 |
// |
|
114 |
// --------------------------------------------------------------------------- |
|
115 |
// |
|
116 |
void CVRMdaRecorder::ConstructL() |
|
117 |
{ |
|
118 |
_LIT_SECURITY_POLICY_S0( KVRWritePolicy, KVoiceRecorderAppUID3 ); |
|
119 |
_LIT_SECURITY_POLICY_PASS( KVRReadPolicy ); |
|
120 |
// Connect to Pub&Sub: |
|
121 |
// Error ignored, key may be already defined which is ok for us |
|
122 |
iPropVRState.Define( KPSUidVoiceRecorder, KVoiceRecorderMode, 0, |
|
123 |
KVRReadPolicy, KVRWritePolicy ); |
|
124 |
||
125 |
User::LeaveIfError( |
|
126 |
iPropVRState.Attach( |
|
127 |
KPSUidVoiceRecorder, KVoiceRecorderMode ) ); |
|
128 |
||
129 |
// To allow/don't allow screensaver |
|
130 |
// Errors ignored, no actions needed if API is not available |
|
131 |
iPropScreenSaver.Attach( KPSUidScreenSaver, |
|
132 |
KScreenSaverAllowScreenSaver ); |
|
133 |
iAudioRecorder = CMdaAudioRecorderUtility::NewL( *this, NULL, |
|
134 |
KAudioPriorityRecording, TMdaPriorityPreference( |
|
135 |
KAudioPrefRealOneLocalPlayback ) ); |
|
136 |
||
137 |
iGlobalNote = CAknGlobalNote::NewL(); |
|
138 |
||
139 |
iErrorUI = CErrorUI::NewL(); |
|
140 |
||
141 |
iTonePlayer = CVRTonePlayer::NewL(); |
|
142 |
iTonePlayer->PrepareToneL( EAvkonSIDVoiceRecordingStartTone ); |
|
143 |
||
144 |
iLight = CHWRMLight::NewL(this); |
|
145 |
||
146 |
// start observe diskdrive |
|
147 |
RFs& fs( CEikonEnv::Static()->FsSession() ); |
|
148 |
||
149 |
iDiskSpaceWatcher = CVRDiskSpaceWatcher::NewL(*this, fs); |
|
150 |
||
151 |
} |
|
152 |
||
153 |
||
154 |
// --------------------------------------------------------------------------- |
|
155 |
// CVRMdaRecorder::MoscoStateChangeEvent |
|
156 |
// |
|
157 |
// --------------------------------------------------------------------------- |
|
158 |
// |
|
159 |
void CVRMdaRecorder::MoscoStateChangeEvent( CBase* /*aObject*/, |
|
160 |
TInt aPreviousState, |
|
161 |
TInt aCurrentState, |
|
162 |
TInt aErrorCode ) |
|
163 |
{ |
|
164 |
#ifdef _DEBUG |
|
165 |
RDebug::Print( _L( "VoiceRecorder: MoscoStateChangeEvent() prev: %d, current: %d, error: %d" ), |
|
166 |
aPreviousState, aCurrentState, aErrorCode ); |
|
167 |
#endif |
|
168 |
iMediaServerError = aErrorCode; |
|
169 |
||
170 |
TRAP_IGNORE(CreateAudioInputL()); |
|
171 |
||
172 |
||
173 |
// Stop the active scheduler wait (if present) |
|
174 |
if ( iActiveWait.IsStarted() ) |
|
175 |
{ |
|
176 |
iActiveWait.AsyncStop(); |
|
177 |
} |
|
178 |
||
179 |
if (iMediaServerError != KErrNone ) |
|
180 |
{ |
|
181 |
||
182 |
// when mmc card is used and unpluged, this error returned |
|
183 |
if (iMediaServerError == KErrCorrupt || iMediaServerError == KErrNotReady) |
|
184 |
{ |
|
185 |
CVRRecViewModel* iViewModel = NULL; |
|
186 |
//iAudioRecorder->Close(); |
|
187 |
iViewModel = dynamic_cast <CVRRecViewModel*>(iAutoStopObserver); |
|
188 |
if(iViewModel != NULL) |
|
189 |
{ |
|
190 |
TRAP_IGNORE( iViewModel->HandleCommandL(EEikCmdExit) ); |
|
191 |
} |
|
192 |
else |
|
193 |
{ |
|
194 |
TRAP_IGNORE( CEikonEnv::Static()->EikAppUi()->HandleCommandL( EAknSoftkeyExit) ); |
|
195 |
} |
|
196 |
} |
|
197 |
||
198 |
// Media server reports KErrDied if the playing was interrupted |
|
199 |
// by some other system sound triggered by for example incoming SMS |
|
200 |
||
201 |
if (aPreviousState == CMdaAudioClipUtility::ERecording || aPreviousState == CMdaAudioClipUtility::EPlaying ) |
|
202 |
{ |
|
203 |
||
204 |
//if ( iMediaServerError != KErrDied && iMediaServerError != KErrAccessDenied ) |
|
205 |
if ( iMediaServerError != KErrDied && |
|
206 |
iMediaServerError != KErrAccessDenied && |
|
207 |
iMediaServerError != KErrInUse ) |
|
208 |
{ |
|
209 |
TBuf< KVRMaxNoteLabelLength > label; |
|
210 |
||
211 |
// If showing of error note fails, then.. well it fails |
|
212 |
if ( iMediaServerError == KErrNotSupported ) |
|
213 |
{ |
|
214 |
CCoeEnv::Static()-> |
|
215 |
ReadResourceAsDes16( label, R_VR_UNSUPPORTED_INFONOTE_LABEL ); |
|
216 |
||
217 |
TRAP_IGNORE( iGlobalNote-> |
|
218 |
ShowNoteL( EAknGlobalErrorNote, label ) ); |
|
219 |
||
220 |
} |
|
221 |
else if ( iMediaServerError == KErrCorrupt ) |
|
222 |
{ |
|
223 |
CCoeEnv::Static()-> |
|
224 |
ReadResourceAsDes16( label, R_VR_CORRUPT_INFONOTE_LABEL ); |
|
225 |
||
226 |
TRAP_IGNORE( iGlobalNote->ShowNoteL( EAknGlobalErrorNote, |
|
227 |
label ) ); |
|
228 |
} |
|
229 |
||
230 |
else |
|
231 |
{ |
|
232 |
TRAP_IGNORE( iErrorUI->ShowGlobalErrorNoteL( iMediaServerError ) ); |
|
233 |
} |
|
234 |
||
235 |
} |
|
236 |
if(iMediaServerError == KErrInUse && aPreviousState == CMdaAudioClipUtility::EPlaying) |
|
237 |
{ |
|
238 |
CVRRecViewModel* iViewModel = NULL; |
|
239 |
iViewModel = dynamic_cast <CVRRecViewModel*>(iAutoStopObserver); |
|
240 |
if(iViewModel != NULL) |
|
241 |
{ |
|
242 |
iViewModel->HandleCommandL(ECmdPause); |
|
243 |
} |
|
244 |
return; |
|
245 |
} |
|
246 |
else |
|
247 |
{ |
|
248 |
StopAndNotify(); |
|
249 |
} |
|
250 |
} |
|
251 |
||
252 |
//it will happen when the openfile fails |
|
253 |
if (aPreviousState == CMdaAudioClipUtility::ENotReady && aCurrentState == CMdaAudioClipUtility::ENotReady ) |
|
254 |
{ |
|
255 |
#ifdef _DEBUG |
|
256 |
RDebug::Print( _L( "VoiceRecorder: callback stop called" ) ); |
|
257 |
#endif |
|
258 |
iAudioRecorder->Close(); |
|
259 |
} |
|
260 |
||
261 |
#ifdef _DEBUG |
|
262 |
if ( aCurrentState == CMdaAudioClipUtility::ERecording) |
|
263 |
{ |
|
264 |
RDebug::Print( _L( "VoiceRecorder: ERecording" ) ); |
|
265 |
} |
|
266 |
#endif |
|
267 |
||
268 |
} // if ( iMediaServerError != KErrNone ) |
|
269 |
||
270 |
if ( aCurrentState == CMdaAudioClipUtility::ERecording || |
|
271 |
aCurrentState == CMdaAudioClipUtility::EPlaying ) |
|
272 |
{ |
|
273 |
// Do not allow screen saver while playing |
|
274 |
// Errors ignored, no actions needed if API is not available |
|
275 |
iPropScreenSaver.Set( KPSUidScreenSaver, |
|
276 |
KScreenSaverAllowScreenSaver, EVRScreenSaverNotAllowed ); |
|
277 |
} |
|
278 |
||
279 |
if ( aCurrentState == CMdaAudioClipUtility::EOpen ) |
|
280 |
{ |
|
281 |
switch ( aPreviousState ) |
|
282 |
{ |
|
283 |
case CMdaAudioClipUtility::ENotReady: |
|
284 |
{ |
|
285 |
iMemo->UpdateModifiedDate(); |
|
286 |
if ( iAttachingToMemo ) |
|
287 |
{ |
|
288 |
iAttachingToMemo = EFalse; |
|
289 |
TRAP_IGNORE( ConfigureMemoL()); |
|
290 |
} |
|
291 |
break; |
|
292 |
} |
|
293 |
default: |
|
294 |
{ |
|
295 |
StopAndNotify(); |
|
296 |
break; |
|
297 |
} |
|
298 |
} |
|
299 |
} |
|
300 |
DEB_PRN_0( _L( "CVRMdaRecorder::MoscoStateChangeEvent::Exit")); |
|
301 |
} |
|
302 |
||
303 |
||
304 |
// --------------------------------------------------------------------------- |
|
305 |
// CVRMdaRecorder::RegisterObserver |
|
306 |
// |
|
307 |
// --------------------------------------------------------------------------- |
|
308 |
// |
|
309 |
void CVRMdaRecorder::RegisterObserver( MVRObserver* aObserver ) |
|
310 |
{ |
|
311 |
if ( aObserver && iObservers.Find( aObserver ) == KErrNotFound ) |
|
312 |
{ |
|
313 |
iObservers.Append( aObserver ); |
|
314 |
} |
|
315 |
} |
|
316 |
||
317 |
||
318 |
// --------------------------------------------------------------------------- |
|
319 |
// CVRMdaRecorder::UnregisterObserver |
|
320 |
// |
|
321 |
// --------------------------------------------------------------------------- |
|
322 |
// |
|
323 |
void CVRMdaRecorder::UnregisterObserver( MVRObserver* aObserver ) |
|
324 |
{ |
|
325 |
if ( !aObserver ) |
|
326 |
{ |
|
327 |
return; |
|
328 |
} |
|
329 |
||
330 |
TInt index( iObservers.Find( aObserver ) ); |
|
331 |
if ( index != KErrNotFound ) |
|
332 |
{ |
|
333 |
iObservers.Remove( index ); |
|
334 |
} |
|
335 |
} |
|
336 |
||
337 |
||
338 |
// --------------------------------------------------------------------------- |
|
339 |
// CVRMdaRecorder::SetAutoStopObserver |
|
340 |
// |
|
341 |
// --------------------------------------------------------------------------- |
|
342 |
// |
|
343 |
void CVRMdaRecorder::SetAutoStopObserver( MVRObserver* aObserver ) |
|
344 |
{ |
|
345 |
iAutoStopObserver = aObserver; |
|
346 |
} |
|
347 |
||
348 |
||
349 |
// --------------------------------------------------------------------------- |
|
350 |
// CVRMdaRecorder::AttachToMemoL |
|
351 |
// Opens a memo file. |
|
352 |
// If the specified file does not exist (yet), it is created. |
|
353 |
// --------------------------------------------------------------------------- |
|
354 |
// |
|
355 |
void CVRMdaRecorder::AttachToMemoL( CVRMemo* aMemo ) |
|
356 |
{ |
|
357 |
#ifdef _DEBUG |
|
358 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL -enter" )); |
|
359 |
#endif |
|
360 |
||
361 |
// if error happen, attach will fail |
|
362 |
||
363 |
if( iIsAttachedToMemo ) |
|
364 |
{ |
|
365 |
User::Panic( KVRPanic,EPanicAlreadyAttached ); |
|
366 |
} |
|
367 |
||
368 |
if( !aMemo ) |
|
369 |
{ |
|
370 |
User::Panic( KVRPanic, KErrNotFound ); |
|
371 |
} |
|
372 |
||
373 |
iMemo = aMemo; |
|
374 |
||
375 |
// if the mmc card is full, should not attach to it |
|
376 |
||
377 |
RFs& fs( CEikonEnv::Static()->FsSession() ); |
|
378 |
||
379 |
||
380 |
// old storage system |
|
381 |
#ifndef RD_MULTIPLE_DRIVE |
|
382 |
if ( iMemo->MemoStore() == EMemoStorePhoneMemory ) |
|
383 |
{ |
|
384 |
#ifdef __AAC_ENCODER_PLUGIN |
|
385 |
if (((iMemo->Quality() != EQualityHigh) && SysUtil::FFSSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf )) || |
|
386 |
((iMemo->Quality() == EQualityHigh) && SysUtil::FFSSpaceBelowCriticalLevelL( &fs, KVRAACCriticalMemoryLevel ))) |
|
387 |
#else |
|
388 |
// now AAC format is not enabled |
|
389 |
if (SysUtil::FFSSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf )) |
|
390 |
#endif |
|
391 |
{ |
|
392 |
VRUtils::ShowMemoryFullConfirmationQuery(); |
|
393 |
if(GetInRecordingFlag()) |
|
394 |
{ |
|
395 |
SetInRecordingFlag(EFalse); |
|
396 |
} |
|
397 |
} |
|
398 |
||
399 |
} |
|
400 |
||
401 |
// MMC card |
|
402 |
else |
|
403 |
{ |
|
404 |
#ifdef __AAC_ENCODER_PLUGIN |
|
405 |
if (((iMemo->Quality() != EQualityHigh) && SysUtil::MMCSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf )) || |
|
406 |
((iMemo->Quality() == EQualityHigh) && SysUtil::MMCSpaceBelowCriticalLevelL( &fs, KVRAACCriticalMemoryLevel ))) |
|
407 |
#else |
|
408 |
// now AAC format is not enabled |
|
409 |
if (SysUtil::FFSSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf )) |
|
410 |
#endif |
|
411 |
{ |
|
412 |
VRUtils::ShowMemoryFullConfirmationQuery(ETrue); |
|
413 |
||
414 |
if(GetInRecordingFlag()) |
|
415 |
{ |
|
416 |
SetInRecordingFlag(EFalse); |
|
417 |
} |
|
418 |
} |
|
419 |
} |
|
420 |
||
421 |
// now multiple drives |
|
422 |
#else |
|
423 |
||
424 |
#ifdef __AAC_ENCODER_PLUGIN |
|
425 |
if (((iMemo->Quality() != EQualityHigh) && SysUtil::DiskSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf, iMemo->StorageDrive())) || |
|
426 |
((iMemo->Quality() == EQualityHigh) && SysUtil::DiskSpaceBelowCriticalLevelL( &fs, KVRAACCriticalMemoryLevel, iMemo->StorageDrive()))) |
|
427 |
#else |
|
428 |
// now AAC format is not enabled |
|
429 |
if (SysUtil::DiskSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf, iMemo->StorageDrive())) |
|
430 |
#endif |
|
431 |
||
432 |
{ |
|
433 |
//mmc card |
|
434 |
if ( iMemo->StorageDrive() == VRUtils::GetRemovableMassStorageL()) |
|
435 |
{ |
|
436 |
VRUtils::ShowMemoryFullConfirmationQuery(ETrue); |
|
437 |
} |
|
438 |
else |
|
439 |
{ |
|
440 |
VRUtils::ShowMemoryFullConfirmationQuery(); |
|
441 |
} |
|
442 |
if(GetInRecordingFlag()) |
|
443 |
{ |
|
444 |
SetInRecordingFlag(EFalse); |
|
445 |
} |
|
446 |
} |
|
447 |
||
448 |
||
449 |
#endif |
|
450 |
||
451 |
// opens an existing file or creates new |
|
452 |
iAudioRecorder->OpenFileL( iMemo->File() ); |
|
453 |
||
454 |
iAttachingToMemo = ETrue; |
|
455 |
||
456 |
if( !iActiveWait.IsStarted() ) |
|
457 |
{ |
|
458 |
#ifdef _DEBUG |
|
459 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL::AWaitStarting...")); |
|
460 |
#endif |
|
461 |
iActiveWait.Start(); // CSI: 10 # |
|
462 |
||
463 |
#ifdef _DEBUG |
|
464 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL::AWResuming...[%d]"), iMediaServerError); |
|
465 |
#endif |
|
466 |
} |
|
467 |
||
468 |
User::LeaveIfError( iMediaServerError ); |
|
469 |
||
470 |
||
471 |
||
472 |
/* |
|
473 |
if( !iActiveWait.IsStarted() ) |
|
474 |
{ |
|
475 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL::AWaitStarting...")); |
|
476 |
iActiveWait.Start(); // CSI: 10 # |
|
477 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL::AWResuming...[%d]"), iMediaServerError); |
|
478 |
} |
|
479 |
||
480 |
User::LeaveIfError( iMediaServerError ); |
|
481 |
||
482 |
// Configure bitrate if recording an AMR clip. |
|
483 |
// Default bitrate is 12200 and it's used if codec doesn't support |
|
484 |
// the bitrate that is retrieved from Central Repository. |
|
485 |
if (iMemo->Quality() == EQualityMMSOptimized ) |
|
486 |
{ |
|
487 |
TUint configuredAmrBitrate( VRUtils::AMRBitrateL() ); |
|
488 |
TUint amrBitrate( KVRDefaultAmrBitrate ); |
|
489 |
||
490 |
// Fetch supported bitrates and find out if configured bitrate |
|
491 |
// is supported |
|
492 |
RArray<TUint> rates; |
|
493 |
iAudioRecorder->GetSupportedBitRatesL( rates ); |
|
494 |
TInt num = rates.Count(); |
|
495 |
if(num > 0) |
|
496 |
{ |
|
497 |
rates.Sort(); |
|
498 |
TInt found = rates.Find(configuredAmrBitrate); |
|
499 |
if (found == KErrNotFound) |
|
500 |
{ |
|
501 |
amrBitrate = rates[num-1]; |
|
502 |
} |
|
503 |
} |
|
504 |
rates.Reset(); // Clear array |
|
505 |
iAudioRecorder->SetDestinationBitRateL( amrBitrate ); |
|
506 |
} |
|
507 |
||
508 |
||
509 |
// added for supporting mp4 format |
|
510 |
#ifdef __AAC_ENCODER_PLUGIN |
|
511 |
else if (iMemo->Quality() == EQualityHigh) |
|
512 |
{ |
|
513 |
||
514 |
TInt configuredAacSamplerate( VRUtils::AACSamplerateL() ); |
|
515 |
TInt aacSampleRate( KVRDefaultSamplerateAac ); |
|
516 |
||
517 |
TInt configuredAacBitrate( VRUtils::AACBitrateL() ); |
|
518 |
TInt aacBitrate( KVRDefaultBitrateAac ); |
|
519 |
||
520 |
TInt configuredAudioMode( VRUtils::AACAudioModeL() ); |
|
521 |
||
522 |
// Sample rate |
|
523 |
RArray<TUint> supportedSampleRates; |
|
524 |
#ifdef _DEBUG |
|
525 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL-GetSupportedSampleRatesL -before" )); |
|
526 |
#endif |
|
527 |
iAudioRecorder->GetSupportedSampleRatesL(supportedSampleRates); |
|
528 |
||
529 |
#ifdef _DEBUG |
|
530 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL-GetSupportedSampleRatesL -after" )); |
|
531 |
#endif |
|
532 |
||
533 |
TInt num1 = supportedSampleRates.Count(); |
|
534 |
if(num1 > 0) |
|
535 |
{ |
|
536 |
supportedSampleRates.Sort(); |
|
537 |
TInt found1 = supportedSampleRates.Find(configuredAacSamplerate); |
|
538 |
if (found1 == KErrNotFound) |
|
539 |
{ |
|
540 |
aacSampleRate = supportedSampleRates[num1-1]; |
|
541 |
} |
|
542 |
} |
|
543 |
||
544 |
supportedSampleRates.Reset(); |
|
545 |
#ifdef _DEBUG |
|
546 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL-SetDestinationSampleRateL -before, sampleRate is %d"), aacSampleRate); |
|
547 |
#endif |
|
548 |
iAudioRecorder->SetDestinationSampleRateL(aacSampleRate); |
|
549 |
||
550 |
#ifdef _DEBUG |
|
551 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL-SetDestinationSampleRateL -after" )); |
|
552 |
#endif |
|
553 |
||
554 |
||
555 |
// Bit reate |
|
556 |
RArray<TUint> supportedBitRates; |
|
557 |
||
558 |
#ifdef _DEBUG |
|
559 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL-GetSupportedBitRatesL -before" )); |
|
560 |
#endif |
|
561 |
iAudioRecorder->GetSupportedBitRatesL(supportedBitRates); |
|
562 |
||
563 |
#ifdef _DEBUG |
|
564 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL-GetSupportedBitRatesL -after" )); |
|
565 |
#endif |
|
566 |
||
567 |
TInt num2 = supportedBitRates.Count(); |
|
568 |
if(num2 > 0) |
|
569 |
{ |
|
570 |
supportedBitRates.Sort(); |
|
571 |
TInt found2 = supportedBitRates.Find(configuredAacBitrate); |
|
572 |
if (found2 == KErrNotFound) |
|
573 |
{ |
|
574 |
aacBitrate = supportedBitRates[num2-1]; |
|
575 |
} |
|
576 |
} |
|
577 |
||
578 |
supportedBitRates.Reset(); |
|
579 |
||
580 |
#ifdef _DEBUG |
|
581 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL-SetDestinationBitRateL -before, bitrate is %d"), aacBitrate); |
|
582 |
#endif |
|
583 |
iAudioRecorder->SetDestinationBitRateL(aacBitrate); |
|
584 |
||
585 |
#ifdef _DEBUG |
|
586 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL-SetDestinationBitRateL -after" )); |
|
587 |
#endif |
|
588 |
||
589 |
// the audio mode flag |
|
590 |
||
591 |
#ifdef _DEBUG |
|
592 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL-GetSupportedNumberOfChannelsL -before" )); |
|
593 |
#endif |
|
594 |
RArray<TUint> supportedNumberOfChannels; |
|
595 |
iAudioRecorder->GetSupportedNumberOfChannelsL(supportedNumberOfChannels); |
|
596 |
TInt num3 = supportedNumberOfChannels.Count(); |
|
597 |
if (num3 > 0) |
|
598 |
{ |
|
599 |
supportedNumberOfChannels.Sort(); |
|
600 |
TInt ifFound = supportedNumberOfChannels.Find(configuredAudioMode); |
|
601 |
if (ifFound == KErrNotFound) |
|
602 |
{ |
|
603 |
configuredAudioMode = supportedNumberOfChannels [0]; |
|
604 |
} |
|
605 |
} |
|
606 |
supportedNumberOfChannels.Reset(); |
|
607 |
iAudioRecorder->SetDestinationNumberOfChannelsL(configuredAudioMode); |
|
608 |
||
609 |
} |
|
610 |
#endif |
|
611 |
iIsAttachedToMemo = ETrue; |
|
612 |
ResetPosition(); |
|
613 |
*/ |
|
614 |
||
615 |
#ifdef _DEBUG |
|
616 |
RDebug::Print( _L( "CVRMdaRecorder::AttachToMemoL -exit" )); |
|
617 |
#endif |
|
618 |
} |
|
619 |
||
620 |
||
621 |
// --------------------------------------------------------------------------- |
|
622 |
// CVRMdaRecorder::CreateNewMemoL |
|
623 |
// |
|
624 |
// --------------------------------------------------------------------------- |
|
625 |
// |
|
626 |
void CVRMdaRecorder::CreateNewMemoL( CVRMemo* aMemo ) |
|
627 |
{ |
|
628 |
iMemo = aMemo; |
|
629 |
iAudioRecorder->OpenFileL( aMemo->File() ); |
|
630 |
if ( !iActiveWait.IsStarted() ) |
|
631 |
{ |
|
632 |
iActiveWait.Start(); // CSI: 10 # |
|
633 |
} |
|
634 |
User::LeaveIfError( iMediaServerError ); |
|
635 |
} |
|
636 |
||
637 |
||
638 |
// --------------------------------------------------------------------------- |
|
639 |
// CVRMdaRecorder::DetachMemo |
|
640 |
// |
|
641 |
// --------------------------------------------------------------------------- |
|
642 |
// |
|
643 |
void CVRMdaRecorder::DetachMemo() |
|
644 |
{ |
|
645 |
if ( iIsAttachedToMemo ) |
|
646 |
{ |
|
647 |
Stop(); |
|
648 |
//Need to delete iAudioInput before close!!! |
|
649 |
DeleteAudioInput(); |
|
650 |
||
651 |
iAudioRecorder->Close(); |
|
652 |
||
653 |
iMemo = NULL; |
|
654 |
iIsAttachedToMemo = EFalse; |
|
655 |
} |
|
656 |
} |
|
657 |
||
658 |
||
659 |
// --------------------------------------------------------------------------- |
|
660 |
// CVRMdaRecorder::SetVolume |
|
661 |
// |
|
662 |
// --------------------------------------------------------------------------- |
|
663 |
// |
|
664 |
void CVRMdaRecorder::SetVolume( TInt aStep, TInt aMaxSteps ) |
|
665 |
{ |
|
666 |
if ( iIsAttachedToMemo ) |
|
667 |
{ |
|
668 |
// On device, MaxVolume() typically returns 9. |
|
669 |
TInt maxVolume( iAudioRecorder->MaxVolume() ); |
|
670 |
TInt volume = maxVolume * aStep / aMaxSteps; |
|
671 |
||
672 |
// Just to make sure that volume is between 0 .. MaxVolume |
|
673 |
if ( volume < 0) |
|
674 |
{ |
|
675 |
volume = 0; |
|
676 |
} |
|
677 |
else if ( volume > maxVolume ) |
|
678 |
{ |
|
679 |
volume = maxVolume; |
|
680 |
} |
|
681 |
||
682 |
#ifdef _DEBUG |
|
683 |
RDebug::Print( _L( "VoiceRecorder: Set volume: %d, max volume: %d" ), |
|
684 |
volume, maxVolume ); |
|
685 |
#endif |
|
686 |
iAudioRecorder->SetVolume( volume ); |
|
687 |
} |
|
688 |
} |
|
689 |
||
690 |
||
691 |
// --------------------------------------------------------------------------- |
|
692 |
// CVRMdaRecorder::PlayL |
|
693 |
// |
|
694 |
// --------------------------------------------------------------------------- |
|
695 |
// |
|
696 |
TInt CVRMdaRecorder::PlayL() |
|
697 |
{ |
|
698 |
__ASSERT_DEBUG( iIsAttachedToMemo, User::Panic( KVRPanic, |
|
699 |
EPanicNotAttached ) ); |
|
700 |
||
701 |
if( iPause ) |
|
702 |
{ |
|
703 |
iAudioRecorder->SetPosition( iPosition ); |
|
704 |
iPosition = 0; |
|
705 |
iPause = EFalse; |
|
706 |
} |
|
707 |
||
708 |
// This line was added to prevent MMF crash, remove it when play works |
|
709 |
// without this |
|
710 |
iAudioRecorder->SetPlaybackBalance( KMMFBalanceCenter ); |
|
711 |
||
712 |
SetIfStopCalled(EFalse); |
|
713 |
iAudioRecorder->PlayL(); |
|
714 |
||
715 |
User::LeaveIfError( iPropVRState.Set( KPSUidVoiceRecorder, |
|
716 |
KVoiceRecorderMode, EVRPlaying ) ); |
|
717 |
||
718 |
// Do not allow screen saver while playing |
|
719 |
// Errors ignored, no actions needed if API is not available |
|
720 |
iPropScreenSaver.Set( KPSUidScreenSaver, |
|
721 |
KScreenSaverAllowScreenSaver, EVRScreenSaverNotAllowed ); |
|
722 |
||
723 |
if( !iActiveWait.IsStarted() ) |
|
724 |
{ |
|
725 |
iActiveWait.Start(); // CSI: 10 # |
|
726 |
} |
|
727 |
StartTimerL(); |
|
728 |
return iMediaServerError; |
|
729 |
} |
|
730 |
||
731 |
// --------------------------------------------------------------------------- |
|
732 |
// CVRMdaRecorder::RecordL |
|
733 |
// Starts the recording of a sound clip. Checks the memory space situation |
|
734 |
// and plays start tone before starting recording. |
|
735 |
// --------------------------------------------------------------------------- |
|
736 |
// |
|
737 |
TInt CVRMdaRecorder::RecordL() |
|
738 |
{ |
|
739 |
// If we receive record command and file is not opened yet. wait for file |
|
740 |
// to be opened and then resume. |
|
741 |
if ( !iIsAttachedToMemo && iAttachingToMemo && !iActiveWait.IsStarted() ) |
|
742 |
{ |
|
743 |
iActiveWait.Start(); |
|
744 |
User::LeaveIfError( iMediaServerError ); |
|
745 |
} |
|
746 |
||
747 |
__ASSERT_DEBUG( iIsAttachedToMemo, User::Panic( KVRPanic, |
|
748 |
EPanicNotAttached ) ); |
|
749 |
TBool wasPaused( iPause ); |
|
750 |
iPause = EFalse; |
|
751 |
||
752 |
// Check if available memory is/goes below critical level |
|
753 |
// in that case record is not performed |
|
754 |
// KVRRecStartMemBuf should be size of 60 sec AMR and 5 sec WAV |
|
755 |
// New max time estimation for WAV is calculated after 5 secs |
|
756 |
RFs& fs( CEikonEnv::Static()->FsSession() ); |
|
757 |
||
758 |
TBool critical( EFalse ); |
|
759 |
||
760 |
// the current storage system (phone memory and mmc card) |
|
761 |
#ifndef RD_MULTIPLE_DRIVE |
|
762 |
if ( iMemo->MemoStore() == EMemoStorePhoneMemory ) |
|
763 |
{ |
|
764 |
#ifdef __AAC_ENCODER_PLUGIN |
|
765 |
if (((iMemo->Quality() != EQualityHigh) && SysUtil::FFSSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf )) || |
|
766 |
((iMemo->Quality() == EQualityHigh) && SysUtil::FFSSpaceBelowCriticalLevelL( &fs, KVRAACCriticalMemoryLevel ))) |
|
767 |
#else |
|
768 |
// now AAC format is not enabled |
|
769 |
if (SysUtil::FFSSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf )) |
|
770 |
#endif |
|
771 |
{ |
|
772 |
VRUtils::ShowMemoryFullConfirmationQuery(); |
|
773 |
critical = ETrue; |
|
774 |
} |
|
775 |
} |
|
776 |
||
777 |
// MMC card |
|
778 |
else |
|
779 |
{ |
|
780 |
#ifdef __AAC_ENCODER_PLUGIN |
|
781 |
if (((iMemo->Quality() != EQualityHigh) && SysUtil::MMCSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf )) || |
|
782 |
((iMemo->Quality() == EQualityHigh) && SysUtil::MMCSpaceBelowCriticalLevelL( &fs, KVRAACCriticalMemoryLevel ))) |
|
783 |
#else |
|
784 |
// now AAC format is not enabled |
|
785 |
if (SysUtil::MMCSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf )) |
|
786 |
#endif |
|
787 |
{ |
|
788 |
VRUtils::ShowMemoryFullConfirmationQuery( ETrue ); |
|
789 |
critical = ETrue; |
|
790 |
} |
|
791 |
||
792 |
} |
|
793 |
||
794 |
// now for multiple drives |
|
795 |
#else |
|
796 |
#ifdef __AAC_ENCODER_PLUGIN |
|
797 |
if (((iMemo->Quality() != EQualityHigh) && SysUtil::DiskSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf, iMemo->StorageDrive())) || |
|
798 |
((iMemo->Quality() == EQualityHigh) && SysUtil::DiskSpaceBelowCriticalLevelL( &fs, KVRAACCriticalMemoryLevel, iMemo->StorageDrive()))) |
|
799 |
#else |
|
800 |
// now AAC format is not enabled |
|
801 |
if (SysUtil::DiskSpaceBelowCriticalLevelL( &fs, KVRRecStartMemBuf, iMemo->StorageDrive())) |
|
802 |
#endif |
|
803 |
{ |
|
804 |
if ( iMemo->StorageDrive() == VRUtils::GetRemovableMassStorageL()) |
|
805 |
{ |
|
806 |
VRUtils::ShowMemoryFullConfirmationQuery(ETrue); |
|
807 |
} |
|
808 |
else |
|
809 |
{ |
|
810 |
VRUtils::ShowMemoryFullConfirmationQuery(); |
|
811 |
} |
|
812 |
critical = ETrue; |
|
813 |
} |
|
814 |
||
815 |
||
816 |
#endif |
|
817 |
||
818 |
if( critical ) |
|
819 |
{ |
|
820 |
User::Leave( KErrDiskFull ); |
|
821 |
} |
|
822 |
||
823 |
||
824 |
if ( !wasPaused ) |
|
825 |
{ |
|
826 |
iTonePlayer->PlayTone( EAvkonSIDVoiceRecordingStartTone ); |
|
827 |
iTonePlayer->PrepareToneL( EAvkonSIDVoiceRecordingStopTone ); |
|
828 |
} |
|
829 |
||
830 |
// start monitor disk space |
|
831 |
#ifdef __AAC_ENCODER_PLUGIN |
|
832 |
if (iMemo->Quality() == EQualityHigh) |
|
833 |
{ |
|
834 |
TInt drive (0); |
|
835 |
#ifndef RD_MULTIPLE_DRIVE |
|
836 |
if ( iMemo->MemoStore() == EMemoStorePhoneMemory ) |
|
837 |
{ |
|
838 |
drive = EDriveC; |
|
839 |
} |
|
840 |
else |
|
841 |
{ |
|
842 |
drive = EDriveE; |
|
843 |
} |
|
844 |
// multiple drives |
|
845 |
#else |
|
846 |
drive = iMemo->StorageDrive(); |
|
847 |
#endif |
|
848 |
||
849 |
iDiskSpaceWatcher->RequestNotification(KVRAACCriticalMemoryLevel,drive); |
|
850 |
} |
|
851 |
#endif |
|
852 |
||
853 |
// Set recording preference |
|
854 |
iAudioRecorder->SetPriority( KAudioPriorityRecording, |
|
855 |
TMdaPriorityPreference( KAudioPrefVoiceRec ) ); |
|
856 |
iAudioRecorder->SetGain( iAudioRecorder->MaxGain() ); |
|
857 |
||
858 |
SetIfStopCalled(EFalse); |
|
859 |
||
860 |
iAudioRecorder->RecordL(); |
|
861 |
||
862 |
// Sets the indication that recording has started -> |
|
863 |
// Current file's handle can't be reused for next file |
|
864 |
iMemo->SetRecorded( ETrue ); |
|
865 |
||
866 |
||
867 |
User::LeaveIfError( iPropVRState.Set( KPSUidVoiceRecorder, |
|
868 |
KVoiceRecorderMode, EVRRecording ) ); |
|
869 |
||
870 |
// Do not allow screen saver while recording |
|
871 |
// Errors ignored, no actions needed if API is not available |
|
872 |
iPropScreenSaver.Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, |
|
873 |
EVRScreenSaverNotAllowed ); |
|
874 |
||
875 |
if( !iActiveWait.IsStarted() ) |
|
876 |
{ |
|
877 |
iActiveWait.Start(); // CSI: 10 # |
|
878 |
} |
|
879 |
StartTimerL(); |
|
880 |
||
881 |
return iMediaServerError; |
|
882 |
} |
|
883 |
||
884 |
||
885 |
// --------------------------------------------------------------------------- |
|
886 |
// CVRMdaRecorder::Stop |
|
887 |
// |
|
888 |
// --------------------------------------------------------------------------- |
|
889 |
// |
|
890 |
void CVRMdaRecorder::Stop() |
|
891 |
{ |
|
892 |
if ( iIsAttachedToMemo ) |
|
893 |
{ |
|
894 |
TBool reallyStopping( iPause ); |
|
895 |
#ifdef _DEBUG |
|
896 |
RDebug::Print( _L( "VoiceRecorder: Stop error: %d" ), |
|
897 |
iMediaServerError ); |
|
898 |
#endif |
|
899 |
iPause = EFalse; |
|
900 |
||
901 |
if( iAudioRecorder->State() == CMdaAudioRecorderUtility::ERecording ) |
|
902 |
{ |
|
903 |
reallyStopping = ETrue; |
|
904 |
||
905 |
// if the dim light is on, turn off it. |
|
906 |
if(iDimLight) |
|
907 |
{ |
|
908 |
||
909 |
iLight->ReleaseLight (CHWRMLight::EPrimaryDisplay); |
|
910 |
User::ResetInactivityTime(); |
|
911 |
iDimLight = EFalse; |
|
912 |
} |
|
913 |
||
914 |
} |
|
915 |
// it will tell VRecorder not pause because it has been stopped. |
|
916 |
SetIfStopCalled(ETrue); |
|
917 |
iAudioRecorder->Stop(); |
|
918 |
||
919 |
// if error does not happen in recording, change the file to visible |
|
920 |
iMemo->File().SetAtt( KEntryAttNormal, KEntryAttHidden); |
|
921 |
||
922 |
iTonePlayer->PlayTone( EAvkonSIDVoiceRecordingStopTone ); |
|
923 |
iTonePlayer->PrepareTone( EAvkonSIDVoiceRecordingStartTone ); |
|
924 |
||
29
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
925 |
if( reallyStopping ) |
25 | 926 |
{ |
927 |
// Set lower preference to ensure other sounds will |
|
928 |
// be played correctly |
|
929 |
iAudioRecorder->SetPriority( KAudioPriorityRecording, |
|
930 |
TMdaPriorityPreference( KAudioPrefRealOneLocalPlayback ) ); |
|
931 |
} |
|
932 |
||
933 |
// Error value ignored if PS key is not available |
|
934 |
iPropVRState.Set( KPSUidVoiceRecorder, KVoiceRecorderMode, EVRIdle ); |
|
935 |
// Used to check the state of a phone call if any |
|
936 |
||
937 |
if ( iCurrentCallHandler ) |
|
938 |
{ |
|
939 |
delete iCurrentCallHandler; |
|
940 |
iCurrentCallHandler = NULL; |
|
941 |
} |
|
942 |
||
943 |
TRAP_IGNORE( iCurrentCallHandler = CVRSystemEventHandler::NewL() ); |
|
944 |
TInt currentState( 0 ); |
|
945 |
TRAP_IGNORE( currentState = iCurrentCallHandler->StateL( KPSUidCtsyCallInformation, KCTsyCallState ) ); |
|
946 |
||
947 |
// Do not allow screen saver if there is an active phone call |
|
948 |
if(currentState == EPSCTsyCallStateRinging) |
|
949 |
{ |
|
950 |
// Do not allow screen saver |
|
951 |
// Errors ignored, no actions needed if API is not available |
|
952 |
iPropScreenSaver.Set( KPSUidScreenSaver, |
|
953 |
KScreenSaverAllowScreenSaver, EVRScreenSaverNotAllowed ); |
|
954 |
} |
|
955 |
else |
|
956 |
{ |
|
957 |
// Allow screen saver |
|
958 |
// Errors ignored, no actions needed if API is not available |
|
959 |
iPropScreenSaver.Set( KPSUidScreenSaver, |
|
960 |
KScreenSaverAllowScreenSaver, EVRScreenSaverAllowed ); |
|
961 |
} |
|
962 |
||
963 |
StopTimer(); |
|
964 |
ResetPosition(); |
|
965 |
iMemo->UpdateModifiedDate(); |
|
966 |
} |
|
967 |
} |
|
968 |
||
969 |
||
970 |
// --------------------------------------------------------------------------- |
|
971 |
// CVRMdaRecorder::StopAndNotify |
|
972 |
// |
|
973 |
// --------------------------------------------------------------------------- |
|
974 |
// |
|
975 |
void CVRMdaRecorder::StopAndNotify() |
|
976 |
{ |
|
977 |
Stop(); |
|
978 |
if ( iAutoStopObserver ) |
|
979 |
{ |
|
980 |
#ifdef _DEBUG |
|
981 |
RDebug::Print( _L( "VoiceRecorder: StopAndNotify AutoStopObserver: %d" ), |
|
982 |
iMediaServerError ); |
|
983 |
#endif |
|
984 |
iAutoStopObserver->Update(); |
|
985 |
#ifdef _DEBUG |
|
986 |
RDebug::Print( _L( "VoiceRecorder: StopAndNotify AutoStopObserver: %d" ), |
|
987 |
iMediaServerError ); |
|
988 |
#endif |
|
989 |
} |
|
990 |
} |
|
991 |
||
992 |
||
993 |
// --------------------------------------------------------------------------- |
|
994 |
// CVRMdaRecorder::Pause |
|
995 |
// |
|
996 |
// --------------------------------------------------------------------------- |
|
997 |
void CVRMdaRecorder::Pause() |
|
998 |
{ |
|
999 |
__ASSERT_DEBUG( iIsAttachedToMemo, User::Panic( KVRPanic, |
|
1000 |
EPanicNotAttached ) ); |
|
1001 |
||
1002 |
iPause = ETrue; |
|
1003 |
||
1004 |
#ifdef _DEBUG |
|
1005 |
RDebug::Print( _L("VoiceRecorder: Pause called. Position: %d:%d"), |
|
1006 |
I64HIGH( iPosition.Int64() ), I64LOW( iPosition.Int64() ) ); |
|
1007 |
#endif |
|
1008 |
||
1009 |
iAudioRecorder->Stop(); |
|
1010 |
||
1011 |
// Error value ignored if PS key is not available |
|
1012 |
iPropVRState.Set( KPSUidVoiceRecorder, KVoiceRecorderMode, EVRIdle ); |
|
1013 |
||
1014 |
// Don't allow screen saver |
|
1015 |
// Errors ignored, no actions needed if API is not available |
|
1016 |
iPropScreenSaver.Set( KPSUidScreenSaver, |
|
1017 |
KScreenSaverAllowScreenSaver, EVRScreenSaverAllowed ); |
|
1018 |
||
1019 |
StopTimer(); |
|
1020 |
SyncAndNotify(); |
|
1021 |
} |
|
1022 |
||
1023 |
||
1024 |
// --------------------------------------------------------------------------- |
|
1025 |
// CVRMdaRecorder::ForwardL |
|
1026 |
// |
|
1027 |
// --------------------------------------------------------------------------- |
|
1028 |
// |
|
1029 |
TInt CVRMdaRecorder::ForwardL() |
|
1030 |
{ |
|
1031 |
if ( !MovePositionL( KVRMdaRecorderDefaultStep ) ) |
|
1032 |
{ |
|
1033 |
return KErrOverflow; |
|
1034 |
} |
|
1035 |
return iMediaServerError; |
|
1036 |
} |
|
1037 |
||
1038 |
||
1039 |
// --------------------------------------------------------------------------- |
|
1040 |
// CVRMdaRecorder::RewindL |
|
1041 |
// |
|
1042 |
// --------------------------------------------------------------------------- |
|
1043 |
// |
|
1044 |
TInt CVRMdaRecorder::RewindL() |
|
1045 |
{ |
|
1046 |
MovePositionL( -KVRMdaRecorderDefaultStep ); |
|
1047 |
return iMediaServerError; |
|
1048 |
} |
|
1049 |
||
1050 |
||
1051 |
// --------------------------------------------------------------------------- |
|
1052 |
// CVRMdaRecorder::CanAcceptCommands |
|
1053 |
// |
|
1054 |
// --------------------------------------------------------------------------- |
|
1055 |
// |
|
1056 |
TBool CVRMdaRecorder::CanAcceptCommands() const |
|
1057 |
{ |
|
1058 |
return !iActiveWait.IsStarted(); |
|
1059 |
} |
|
1060 |
||
1061 |
||
1062 |
// --------------------------------------------------------------------------- |
|
1063 |
// CVRMdaRecorder::MovePositionL |
|
1064 |
// |
|
1065 |
// --------------------------------------------------------------------------- |
|
1066 |
// |
|
1067 |
TBool CVRMdaRecorder::MovePositionL( TInt aSeconds ) |
|
1068 |
{ |
|
1069 |
__ASSERT_DEBUG( iIsAttachedToMemo, User::Panic( KVRPanic, |
|
1070 |
EPanicNotAttached ) ); |
|
1071 |
||
1072 |
#ifdef _DEBUG |
|
1073 |
RDebug::Print( _L("VoiceRecorder: MovePosition called. Base position: %d:%d"), |
|
1074 |
I64HIGH( iAudioRecorder->Position().Int64() ), |
|
1075 |
I64LOW( iAudioRecorder->Position().Int64() ) ); |
|
1076 |
#endif |
|
1077 |
||
1078 |
TInt64 interval; |
|
1079 |
if (iPause) |
|
1080 |
{ |
|
1081 |
interval = iPosition.Int64() + aSeconds * KVRSecondAsMicroSeconds; |
|
1082 |
} |
|
1083 |
// Not sure if iPosition value is valid other than when paused, so do as |
|
1084 |
// previous for all other states: |
|
1085 |
else |
|
1086 |
{ |
|
1087 |
interval = iAudioRecorder->Position().Int64() + |
|
1088 |
aSeconds * |
|
1089 |
KVRSecondAsMicroSeconds; |
|
1090 |
} |
|
1091 |
||
1092 |
// Truncated to integer values |
|
1093 |
TInt integerInterval( interval / KVRSecondAsMicroSeconds ); |
|
1094 |
TInt integerDuration( iAudioRecorder->Duration().Int64() / |
|
1095 |
KVRSecondAsMicroSeconds ); |
|
1096 |
if ( interval < 0 ) |
|
1097 |
{ |
|
1098 |
interval = 0; |
|
1099 |
} |
|
1100 |
// if gone past the end or integer values are the same |
|
1101 |
// in duration and position |
|
1102 |
else if ( interval > iAudioRecorder->Duration().Int64() || |
|
1103 |
integerInterval == integerDuration ) |
|
1104 |
{ |
|
1105 |
interval = iAudioRecorder->Duration().Int64(); |
|
1106 |
} |
|
1107 |
||
1108 |
#ifdef _DEBUG |
|
1109 |
RDebug::Print( _L("VoiceRecorder: MovePosition called. Interval: %d:%d"), |
|
1110 |
I64HIGH( interval ), I64LOW( interval ) ); |
|
1111 |
#endif |
|
1112 |
||
1113 |
TTimeIntervalMicroSeconds newPosition( interval ); |
|
1114 |
||
1115 |
if (iPause) |
|
1116 |
{ |
|
1117 |
iPosition = newPosition; |
|
1118 |
} |
|
1119 |
else if ( iAudioRecorder->State() == CMdaAudioClipUtility::EOpen ) |
|
1120 |
{ |
|
1121 |
// not playing, recording or paused. |
|
1122 |
#ifdef _DEBUG |
|
1123 |
RDebug::Print( _L("VoiceRecorder. Idle.: MovePosition called. New Position: %d:%d"), |
|
1124 |
I64HIGH( newPosition.Int64() ), I64LOW( newPosition.Int64() ) ); |
|
1125 |
#endif |
|
1126 |
iAudioRecorder->SetPosition( newPosition ); |
|
1127 |
} |
|
1128 |
else |
|
1129 |
{ |
|
1130 |
||
1131 |
#ifdef _DEBUG |
|
1132 |
RDebug::Print( _L("VoiceRecorder. Playing.: MovePosition called. New Position: %d:%d"), |
|
1133 |
I64HIGH( newPosition.Int64() ), I64LOW( newPosition.Int64() ) ); |
|
1134 |
#endif |
|
1135 |
||
1136 |
iAudioRecorder->Stop(); |
|
1137 |
iAudioRecorder->SetPosition( newPosition ); |
|
1138 |
iAudioRecorder->PlayL(); |
|
1139 |
if( !iActiveWait.IsStarted() ) |
|
1140 |
{ |
|
1141 |
iActiveWait.Start(); // CSI: 10 # |
|
1142 |
} |
|
1143 |
} |
|
1144 |
SyncAndNotify(); |
|
1145 |
return ETrue; |
|
1146 |
} |
|
1147 |
||
1148 |
// --------------------------------------------------------------------------- |
|
1149 |
// CVRMdaRecorder::ConfigureMemoL() |
|
1150 |
// |
|
1151 |
// --------------------------------------------------------------------------- |
|
1152 |
// |
|
1153 |
void CVRMdaRecorder::ConfigureMemoL() |
|
1154 |
{ |
|
1155 |
DEB_PRN_0( _L( "CVRMdaRecorder::ConfigureMemoL-Enter" )); |
|
1156 |
||
1157 |
// Configure bitrate if recording an AMR clip. |
|
1158 |
// Default bitrate is 12200 and it's used if codec doesn't support |
|
1159 |
// the bitrate that is retrieved from Central Repository. |
|
1160 |
if (iMemo->Quality() == EQualityMMSOptimized ) |
|
1161 |
{ |
|
1162 |
TUint configuredAmrBitrate( VRUtils::AMRBitrateL() ); |
|
1163 |
TUint amrBitrate( KVRDefaultAmrBitrate ); |
|
1164 |
||
1165 |
// Fetch supported bitrates and find out if configured bitrate |
|
1166 |
// is supported |
|
1167 |
RArray<TUint> rates; |
|
1168 |
iAudioRecorder->GetSupportedBitRatesL( rates ); |
|
1169 |
TInt num = rates.Count(); |
|
1170 |
if(num > 0) |
|
1171 |
{ |
|
1172 |
rates.Sort(); |
|
1173 |
TInt found = rates.Find(configuredAmrBitrate); |
|
1174 |
if (found == KErrNotFound) |
|
1175 |
{ |
|
1176 |
amrBitrate = rates[num-1]; |
|
1177 |
} |
|
1178 |
} |
|
1179 |
rates.Reset(); // Clear array |
|
1180 |
iAudioRecorder->SetDestinationBitRateL( amrBitrate ); |
|
1181 |
||
1182 |
DEB_PRN_0( _L( "CVRMdaRecorder::ConfigureMemoL-Configured MMSOpt bitrate" )); |
|
1183 |
} |
|
1184 |
||
1185 |
||
1186 |
// added for supporting mp4 format |
|
1187 |
#ifdef __AAC_ENCODER_PLUGIN |
|
1188 |
else if (iMemo->Quality() == EQualityHigh) |
|
1189 |
{ |
|
1190 |
TInt configuredAacSamplerate( VRUtils::AACSamplerateL() ); |
|
1191 |
TInt aacSampleRate( KVRDefaultSamplerateAac ); |
|
1192 |
||
1193 |
TInt configuredAacBitrate( VRUtils::AACBitrateL() ); |
|
1194 |
TInt aacBitrate( KVRDefaultBitrateAac ); |
|
1195 |
||
1196 |
TInt configuredAudioMode( VRUtils::AACAudioModeL() ); |
|
1197 |
||
1198 |
// Sample rate |
|
1199 |
RArray<TUint> supportedSampleRates; |
|
1200 |
iAudioRecorder->GetSupportedSampleRatesL(supportedSampleRates); |
|
1201 |
||
1202 |
TInt num1 = supportedSampleRates.Count(); |
|
1203 |
if(num1 > 0) |
|
1204 |
{ |
|
1205 |
supportedSampleRates.Sort(); |
|
1206 |
TInt found1 = supportedSampleRates.Find(configuredAacSamplerate); |
|
1207 |
if (found1 == KErrNotFound) |
|
1208 |
{ |
|
1209 |
aacSampleRate = supportedSampleRates[num1-1]; |
|
1210 |
} |
|
1211 |
} |
|
1212 |
supportedSampleRates.Reset(); |
|
1213 |
iAudioRecorder->SetDestinationSampleRateL(aacSampleRate); |
|
1214 |
||
1215 |
DEB_PRN_0( _L( "CVRMdaRecorder::ConfigureMemoL-Configured HiQ sampling rate" )); |
|
1216 |
||
1217 |
// Bit reate |
|
1218 |
RArray<TUint> supportedBitRates; |
|
1219 |
iAudioRecorder->GetSupportedBitRatesL(supportedBitRates); |
|
1220 |
TInt num2 = supportedBitRates.Count(); |
|
1221 |
if(num2 > 0) |
|
1222 |
{ |
|
1223 |
supportedBitRates.Sort(); |
|
1224 |
TInt found2 = supportedBitRates.Find(configuredAacBitrate); |
|
1225 |
if (found2 == KErrNotFound) |
|
1226 |
{ |
|
1227 |
aacBitrate = supportedBitRates[num2-1]; |
|
1228 |
} |
|
1229 |
} |
|
1230 |
supportedBitRates.Reset(); |
|
1231 |
iAudioRecorder->SetDestinationBitRateL(aacBitrate); |
|
1232 |
DEB_PRN_0( _L( "CVRMdaRecorder::ConfigureMemoL-Configured HiQ bit rate" )); |
|
1233 |
||
1234 |
// the audio mode flag |
|
1235 |
RArray<TUint> supportedNumberOfChannels; |
|
1236 |
iAudioRecorder->GetSupportedNumberOfChannelsL(supportedNumberOfChannels); |
|
1237 |
TInt num3 = supportedNumberOfChannels.Count(); |
|
1238 |
if (num3 > 0) |
|
1239 |
{ |
|
1240 |
supportedNumberOfChannels.Sort(); |
|
1241 |
TInt ifFound = supportedNumberOfChannels.Find(configuredAudioMode); |
|
1242 |
if (ifFound == KErrNotFound) |
|
1243 |
{ |
|
1244 |
configuredAudioMode = supportedNumberOfChannels [0]; |
|
1245 |
} |
|
1246 |
} |
|
1247 |
supportedNumberOfChannels.Reset(); |
|
1248 |
iAudioRecorder->SetDestinationNumberOfChannelsL(configuredAudioMode); |
|
1249 |
||
1250 |
DEB_PRN_0( _L( "CVRMdaRecorder::ConfigureMemoL-Configured HiQ channel" )); |
|
1251 |
} |
|
1252 |
#endif // __AAC_ENCODER_PLUGIN |
|
1253 |
iIsAttachedToMemo = ETrue; |
|
1254 |
ResetPosition(); |
|
1255 |
DEB_PRN_0( _L( "CVRMdaRecorder::ConfigureMemoL-Exit" )); |
|
1256 |
} |
|
1257 |
||
1258 |
// --------------------------------------------------------------------------- |
|
1259 |
// CVRMdaRecorder::ResetPosition |
|
1260 |
// |
|
1261 |
// --------------------------------------------------------------------------- |
|
1262 |
// |
|
1263 |
void CVRMdaRecorder::ResetPosition() |
|
1264 |
{ |
|
1265 |
if ( iIsAttachedToMemo ) |
|
1266 |
{ |
|
1267 |
iAudioRecorder->SetPosition( TTimeIntervalMicroSeconds( 0 ) ); |
|
1268 |
SyncAndNotify(); |
|
1269 |
} |
|
1270 |
} |
|
1271 |
||
1272 |
||
1273 |
// --------------------------------------------------------------------------- |
|
1274 |
// CVRMdaRecorder::StartTimerL |
|
1275 |
// Create and start a timer with initial delay of 0 |
|
1276 |
// and a frequency of one second |
|
1277 |
// --------------------------------------------------------------------------- |
|
1278 |
// |
|
1279 |
void CVRMdaRecorder::StartTimerL() |
|
1280 |
{ |
|
1281 |
StopTimer(); // stop if already running |
|
1282 |
||
1283 |
TCallBack cb( TimerCallBack, this ); |
|
1284 |
iTimer = CPeriodic::NewL( 1 ); // priority = EPriorityNormal + 1 = 1 |
|
1285 |
iTimer->Start( 0, KVRDisplayUpdateDelay, cb ); |
|
1286 |
} |
|
1287 |
||
1288 |
||
1289 |
// --------------------------------------------------------------------------- |
|
1290 |
// CVRMdaRecorder::StopTimer |
|
1291 |
// Stop the timer by deleting the CPeriodic object |
|
1292 |
// --------------------------------------------------------------------------- |
|
1293 |
// |
|
1294 |
void CVRMdaRecorder::StopTimer() |
|
1295 |
{ |
|
1296 |
delete iTimer; |
|
1297 |
iTimer = NULL; |
|
1298 |
} |
|
1299 |
||
1300 |
||
1301 |
// --------------------------------------------------------------------------- |
|
1302 |
// CVRMdaRecorder::SyncAndNotify |
|
1303 |
// |
|
1304 |
// --------------------------------------------------------------------------- |
|
1305 |
// |
|
1306 |
void CVRMdaRecorder::SyncAndNotify() |
|
1307 |
{ |
|
1308 |
if(!iPause) |
|
1309 |
{ |
|
1310 |
iPosition = iAudioRecorder->Position(); |
|
1311 |
} |
|
1312 |
iMemo->SetPosition( iPosition ); |
|
1313 |
||
1314 |
iMemo->SetDuration( iAudioRecorder->Duration() ); |
|
1315 |
||
1316 |
for ( int i = 0; i < iObservers.Count(); i++ ) |
|
1317 |
{ |
|
1318 |
TVRUpdateCommand command( EVRUpdate ); |
|
1319 |
if ( ( iMemo->Position().Int64() / KVRSecondAsMicroSeconds ) == 1 ) |
|
1320 |
{ |
|
1321 |
command = EVRUpdate1Second; |
|
1322 |
} |
|
1323 |
iObservers[ i ]->Update( command ); |
|
1324 |
} |
|
1325 |
} |
|
1326 |
||
1327 |
||
1328 |
// --------------------------------------------------------------------------- |
|
1329 |
// CVRMdaRecorder::TimerCallBack |
|
1330 |
// |
|
1331 |
// --------------------------------------------------------------------------- |
|
1332 |
// |
|
1333 |
TInt CVRMdaRecorder::TimerCallBack( TAny* aMdaRecorder ) |
|
1334 |
{ |
|
1335 |
CVRMdaRecorder* recorder = reinterpret_cast< CVRMdaRecorder* >( |
|
1336 |
aMdaRecorder ); |
|
1337 |
recorder->HandleTick(); |
|
1338 |
return ETrue; |
|
1339 |
} |
|
1340 |
||
1341 |
||
1342 |
// --------------------------------------------------------------------------- |
|
1343 |
// CVRMdaRecorder::HandleTick |
|
1344 |
// |
|
1345 |
// --------------------------------------------------------------------------- |
|
1346 |
// |
|
1347 |
void CVRMdaRecorder::HandleTick() |
|
1348 |
{ |
|
1349 |
SyncAndNotify(); |
|
1350 |
||
1351 |
if ( iAudioRecorder->State() == CMdaAudioClipUtility::ERecording ) |
|
1352 |
{ |
|
1353 |
||
1354 |
TTimeIntervalMicroSeconds position( 0 ); |
|
1355 |
TTimeIntervalMicroSeconds duration( 0 ); |
|
1356 |
TTimeIntervalMicroSeconds maxDuration( 0 ); |
|
1357 |
||
1358 |
position = iMemo->Position(); |
|
1359 |
duration = iMemo->Duration(); |
|
1360 |
maxDuration = iMemo->MaxDuration(); |
|
1361 |
||
1362 |
// Position value is used for comparison because it gives more accurate |
|
1363 |
// value than Duration value |
|
1364 |
if ( position >= maxDuration ) |
|
1365 |
{ |
|
1366 |
#ifdef _DEBUG |
|
1367 |
RDebug::Print( _L("VoiceRecorder: Max duration passed. Position: %d:%d"), |
|
1368 |
I64HIGH( position.Int64() ), I64LOW( position.Int64() ) ); |
|
1369 |
#endif |
|
1370 |
||
1371 |
#ifdef _DEBUG |
|
1372 |
RDebug::Print( _L("VoiceRecorder: Max duration passed. Duration: %d:%d"), |
|
1373 |
I64HIGH( duration.Int64() ), I64LOW( duration.Int64() ) ); |
|
1374 |
#endif |
|
1375 |
||
1376 |
#ifdef _DEBUG |
|
1377 |
RDebug::Print( _L("VoiceRecorder: Max duration passed. MaxDuration: %d:%d"), |
|
1378 |
I64HIGH( maxDuration.Int64() ), I64LOW( maxDuration.Int64() ) ); |
|
1379 |
#endif |
|
1380 |
// Note that some data cropping is possible after stopping |
|
1381 |
// ->Duration decreases |
|
1382 |
StopAndNotify(); |
|
1383 |
} |
|
1384 |
} |
|
1385 |
} |
|
1386 |
||
1387 |
||
1388 |
// --------------------------------------------------------------------------- |
|
1389 |
// CVRMdaRecorder::SetIhf |
|
1390 |
// |
|
1391 |
// --------------------------------------------------------------------------- |
|
1392 |
// |
|
1393 |
TInt CVRMdaRecorder::SetIhf( TBool /*aEnabled*/ ) |
|
1394 |
{ |
|
1395 |
return KErrNotSupported; |
|
1396 |
} |
|
1397 |
||
1398 |
||
1399 |
// --------------------------------------------------------------------------- |
|
1400 |
// CVRMdaRecorder::SetPositionL |
|
1401 |
// |
|
1402 |
// --------------------------------------------------------------------------- |
|
1403 |
// |
|
1404 |
void CVRMdaRecorder::SetPositionL( TInt aSeconds ) |
|
1405 |
{ |
|
1406 |
__ASSERT_DEBUG( iIsAttachedToMemo, User::Panic( KVRPanic, |
|
1407 |
EPanicNotAttached ) ); |
|
1408 |
||
1409 |
if( iAudioRecorder->State() == CMdaAudioClipUtility::ERecording || |
|
1410 |
iAudioRecorder->State() == CMdaAudioClipUtility::ENotReady ) |
|
1411 |
{ |
|
1412 |
return; |
|
1413 |
} |
|
1414 |
||
1415 |
TInt64 interval ( TInt64( aSeconds ) * KVRSecondAsMicroSeconds ); |
|
1416 |
||
1417 |
// Truncated to integer values |
|
1418 |
TInt integerInterval( interval / KVRSecondAsMicroSeconds ); |
|
1419 |
TInt integerDuration( iAudioRecorder->Duration().Int64() / |
|
1420 |
KVRSecondAsMicroSeconds ); |
|
1421 |
||
1422 |
if ( interval < 0 || integerDuration == 0 ) |
|
1423 |
{ |
|
1424 |
interval = 0; |
|
1425 |
} |
|
1426 |
// if gone past the end or integer values are the same in |
|
1427 |
// duration and position |
|
1428 |
else if ( interval > iAudioRecorder->Duration().Int64() || |
|
1429 |
integerInterval == integerDuration ) |
|
1430 |
{ |
|
1431 |
interval = iAudioRecorder->Duration().Int64(); |
|
1432 |
} |
|
1433 |
||
1434 |
TTimeIntervalMicroSeconds newPosition( interval ); |
|
1435 |
||
1436 |
if ( iPause ) |
|
1437 |
{ |
|
1438 |
iPosition = newPosition; |
|
1439 |
} |
|
1440 |
else if ( iAudioRecorder->State() == CMdaAudioClipUtility::EOpen ) |
|
1441 |
{ |
|
1442 |
iAudioRecorder->SetPosition( newPosition ); |
|
1443 |
} |
|
1444 |
else |
|
1445 |
{ |
|
1446 |
iAudioRecorder->Stop(); |
|
1447 |
iAudioRecorder->SetPosition( newPosition ); |
|
1448 |
iAudioRecorder->PlayL(); |
|
1449 |
if( !iActiveWait.IsStarted() ) |
|
1450 |
{ |
|
1451 |
iActiveWait.Start(); // CSI: 10 # |
|
1452 |
} |
|
1453 |
} |
|
1454 |
SyncAndNotify(); |
|
1455 |
} |
|
1456 |
||
1457 |
// --------------------------------------------------------- |
|
1458 |
// From class MBacklightControlObserver. |
|
1459 |
// CNTExternalEventObserver::LightStatusChanged |
|
1460 |
// --------------------------------------------------------- |
|
1461 |
// |
|
1462 |
void CVRMdaRecorder::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus) |
|
1463 |
{ |
|
1464 |
||
1465 |
if(aTarget == CHWRMLight::EPrimaryDisplayAndKeyboard || aTarget == CHWRMLight::EPrimaryDisplay) |
|
1466 |
{ |
|
1467 |
if(aStatus == CHWRMLight::ELightOff) |
|
1468 |
{ |
|
1469 |
if (iAudioRecorder) |
|
1470 |
{ |
|
1471 |
if (iAudioRecorder->State() == CMdaAudioClipUtility::ERecording ) // set light to dimmed |
|
1472 |
{ |
|
1473 |
||
1474 |
TRAPD(err, iLight->LightOnL(CHWRMLight::EPrimaryDisplay, KHWRMInfiniteDuration, 10, ETrue)); |
|
1475 |
if ( err == KErrNone ) |
|
1476 |
{ |
|
1477 |
iDimLight = ETrue; |
|
1478 |
} |
|
1479 |
||
1480 |
} |
|
1481 |
} |
|
1482 |
||
1483 |
return; |
|
1484 |
} |
|
1485 |
||
1486 |
if((aStatus == CHWRMLight::ELightOn) && (aTarget == CHWRMLight::EPrimaryKeyboard)) |
|
1487 |
{ |
|
1488 |
||
1489 |
if (iLight) |
|
1490 |
{ |
|
1491 |
||
1492 |
CHWRMLight::TLightStatus status = iLight->LightStatus(CHWRMLight::EPrimaryDisplay); |
|
1493 |
||
1494 |
if( (status == CHWRMLight::ELightOn) && iDimLight ) |
|
1495 |
{ |
|
1496 |
User::ResetInactivityTime(); |
|
1497 |
iDimLight = EFalse; |
|
1498 |
} |
|
1499 |
} |
|
1500 |
return; |
|
1501 |
} |
|
1502 |
||
1503 |
} |
|
1504 |
} |
|
1505 |
||
1506 |
||
1507 |
// --------------------------------------------------------- |
|
1508 |
// GetInRecordingFlag |
|
1509 |
// |
|
1510 |
// --------------------------------------------------------- |
|
1511 |
// |
|
1512 |
TBool CVRMdaRecorder::GetInRecordingFlag() |
|
1513 |
{ |
|
1514 |
return ifInRecording; |
|
1515 |
} |
|
1516 |
||
1517 |
||
1518 |
// --------------------------------------------------------- |
|
1519 |
// SetInRecordingFlag |
|
1520 |
// --------------------------------------------------------- |
|
1521 |
// |
|
1522 |
void CVRMdaRecorder::SetInRecordingFlag(TBool aFlag) |
|
1523 |
{ |
|
1524 |
ifInRecording = aFlag; |
|
1525 |
} |
|
1526 |
||
1527 |
||
1528 |
// --------------------------------------------------------- |
|
1529 |
// GetInRecordingFlag |
|
1530 |
// |
|
1531 |
// --------------------------------------------------------- |
|
1532 |
// |
|
1533 |
TBool CVRMdaRecorder::GetIfStopCalled() |
|
1534 |
{ |
|
1535 |
return ifStopCalled; |
|
1536 |
} |
|
1537 |
||
1538 |
||
1539 |
// --------------------------------------------------------- |
|
1540 |
// SetInRecordingFlag |
|
1541 |
// --------------------------------------------------------- |
|
1542 |
// |
|
1543 |
void CVRMdaRecorder::SetIfStopCalled(TBool aFlag) |
|
1544 |
{ |
|
1545 |
ifStopCalled = aFlag; |
|
1546 |
} |
|
1547 |
||
1548 |
// --------------------------------------------------------- |
|
1549 |
// IsAttachedToMemo |
|
1550 |
// --------------------------------------------------------- |
|
1551 |
// |
|
1552 |
TBool CVRMdaRecorder::IsAttachedToMemo() |
|
1553 |
{ |
|
1554 |
return iIsAttachedToMemo; |
|
1555 |
} |
|
1556 |
||
1557 |
||
1558 |
// --------------------------------------------------------- |
|
1559 |
// CreateAudioInput |
|
1560 |
// --------------------------------------------------------- |
|
1561 |
// |
|
1562 |
void CVRMdaRecorder::CreateAudioInputL() |
|
1563 |
{ |
|
1564 |
CAudioInput::TAudioInputPreference audioInput = CAudioInput::EDefaultMic; |
|
1565 |
||
1566 |
if ((iAudioRecorder->State() == CMdaAudioClipUtility::EOpen)&& |
|
1567 |
(!iAudioInput)) |
|
1568 |
{ |
|
1569 |
iAudioInput = CAudioInput::NewL(*iAudioRecorder); |
|
1570 |
SetAudioInputL(audioInput); |
|
1571 |
iCurrentAudioInput = audioInput; |
|
1572 |
} |
|
1573 |
||
1574 |
} |
|
1575 |
// --------------------------------------------------------- |
|
1576 |
// SetAudioInputL |
|
1577 |
// --------------------------------------------------------- |
|
1578 |
// |
|
1579 |
void CVRMdaRecorder::SetAudioInputL(CAudioInput::TAudioInputPreference aAudioInput) |
|
1580 |
{ |
|
1581 |
if((iAudioInput)&&(iCurrentAudioInput!=aAudioInput)) |
|
1582 |
{ |
|
1583 |
RArray<CAudioInput::TAudioInputPreference> inputArray(4); |
|
1584 |
CleanupClosePushL( inputArray ); |
|
1585 |
inputArray.Append( aAudioInput ); |
|
1586 |
iAudioInput->SetAudioInputL( inputArray.Array() ); |
|
1587 |
CleanupStack::PopAndDestroy( &inputArray ); |
|
1588 |
iCurrentAudioInput = aAudioInput; |
|
1589 |
} |
|
1590 |
||
1591 |
} |
|
1592 |
||
1593 |
// --------------------------------------------------------- |
|
1594 |
// DeleteAudioInput |
|
1595 |
// --------------------------------------------------------- |
|
1596 |
// |
|
1597 |
void CVRMdaRecorder::DeleteAudioInput() |
|
1598 |
{ |
|
1599 |
delete iAudioInput; |
|
1600 |
iAudioInput = NULL; |
|
1601 |
} |
|
1602 |
||
1603 |
// --------------------------------------------------------- |
|
1604 |
// ConfigSampleRateOfVoiceCallL |
|
1605 |
// --------------------------------------------------------- |
|
1606 |
// |
|
1607 |
void CVRMdaRecorder::ConfigSampleRateOfVoiceCallL() |
|
1608 |
{ |
|
1609 |
// Sample rate |
|
1610 |
TUint sampleRates = iAudioRecorder->DestinationSampleRateL(); |
|
1611 |
TInt configuredAacSamplerate( VRUtils::AACSamplerateL() ); |
|
1612 |
if(sampleRates == configuredAacSamplerate) |
|
1613 |
{ |
|
1614 |
return; |
|
1615 |
} |
|
1616 |
||
1617 |
if (iMemo->Quality() == EQualityHigh) |
|
1618 |
{ |
|
1619 |
TInt aacSampleRate( KVRDefaultSamplerateAac ); |
|
1620 |
// Sample rate |
|
1621 |
RArray<TUint> supportedSampleRates; |
|
1622 |
iAudioRecorder->GetSupportedSampleRatesL(supportedSampleRates); |
|
1623 |
TInt num1 = supportedSampleRates.Count(); |
|
1624 |
if(num1 > 0) |
|
1625 |
{ |
|
1626 |
supportedSampleRates.Sort(); |
|
1627 |
TInt found1 = supportedSampleRates.Find(configuredAacSamplerate); |
|
1628 |
if (found1 == KErrNotFound) |
|
1629 |
{ |
|
1630 |
aacSampleRate = supportedSampleRates[num1-1]; |
|
1631 |
} |
|
1632 |
} |
|
1633 |
supportedSampleRates.Reset(); |
|
1634 |
iAudioRecorder->SetDestinationSampleRateL(aacSampleRate); |
|
1635 |
} |
|
1636 |
} |
|
1637 |
||
1638 |
// End of file |