|
1 /* |
|
2 * Copyright (c) 2002 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: AudioroutingControl test module |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include <StifParser.h> |
|
23 #include <Stiftestinterface.h> |
|
24 #include "AudioRoutingTestClass.h" |
|
25 #include "debug.h" |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 //extern ?external_data; |
|
29 |
|
30 // EXTERNAL FUNCTION PROTOTYPES |
|
31 //extern ?external_function( ?arg_type,?arg_type ); |
|
32 |
|
33 // CONSTANTS |
|
34 //const ?type ?constant_var = ?constant; |
|
35 |
|
36 // MACROS |
|
37 //#define ?macro ?macro_def |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 //const ?type ?constant_var = ?constant; |
|
41 //#define ?macro_name ?macro_def |
|
42 |
|
43 // MODULE DATA STRUCTURES |
|
44 //enum ?declaration |
|
45 //typedef ?declaration |
|
46 |
|
47 // LOCAL FUNCTION PROTOTYPES |
|
48 //?type ?function_name( ?arg_type, ?arg_type ); |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 //class ?FORWARD_CLASSNAME; |
|
52 |
|
53 // ============================= LOCAL FUNCTIONS =============================== |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // ?function_name ?description. |
|
57 // ?description |
|
58 // Returns: ?value_1: ?description |
|
59 // ?value_n: ?description_line1 |
|
60 // ?description_line2 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 /* |
|
64 ?type ?function_name( |
|
65 ?arg_type arg, // ?description |
|
66 ?arg_type arg) // ?description |
|
67 { |
|
68 |
|
69 ?code // ?comment |
|
70 |
|
71 // ?comment |
|
72 ?code |
|
73 } |
|
74 */ |
|
75 |
|
76 // ============================ MEMBER FUNCTIONS =============================== |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CAudioAudioRoutingTest::Delete |
|
80 // Delete here all resources allocated and opened from test methods. |
|
81 // Called from destructor. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 TInt CAudioRoutingTestClass::Delete() |
|
85 { |
|
86 TInt error= KErrNone; |
|
87 FTRACE(FPrint(_L("CAudioRoutingTestClass::Delete"))); |
|
88 |
|
89 iExpectedEvents.Close(); |
|
90 iOcurredEvents.Close(); |
|
91 |
|
92 iLog->Log(_L("Deleting test class...")); |
|
93 iLog->Log(_L("")); |
|
94 iLog->Log(_L("")); |
|
95 |
|
96 |
|
97 if (iAudioInput) |
|
98 { |
|
99 delete iAudioInput; |
|
100 } |
|
101 |
|
102 if (iAudioOutput) |
|
103 { |
|
104 delete iAudioOutput; |
|
105 } |
|
106 |
|
107 if (iAudioTone) |
|
108 { |
|
109 delete iAudioTone; |
|
110 } |
|
111 |
|
112 if (iAudioInputStream) |
|
113 { |
|
114 delete iAudioInputStream; |
|
115 } |
|
116 |
|
117 if (iAudioOutputStream) |
|
118 { |
|
119 delete iAudioOutputStream; |
|
120 } |
|
121 |
|
122 if (iCustomCommandUtility) |
|
123 { |
|
124 delete iCustomCommandUtility; |
|
125 } |
|
126 |
|
127 if (iMidiClientUtility) |
|
128 { |
|
129 iMidiClientUtility->Close(); |
|
130 delete iMidiClientUtility; |
|
131 } |
|
132 |
|
133 if (iRecorder) |
|
134 { |
|
135 delete iRecorder; |
|
136 } |
|
137 |
|
138 if (iUtil) |
|
139 { |
|
140 delete iUtil; |
|
141 } |
|
142 |
|
143 if (iDrmPlayerUtility) |
|
144 { |
|
145 delete iDrmPlayerUtility; |
|
146 } |
|
147 |
|
148 |
|
149 if (iVideoPlayerUtility) |
|
150 { |
|
151 delete iVideoPlayerUtility; |
|
152 DeleteVideoWindow(); |
|
153 } |
|
154 if (iDevSound) |
|
155 { |
|
156 delete iDevSound; |
|
157 } |
|
158 REComSession::FinalClose(); |
|
159 return error; |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CAudioAudioRoutingTest::RunMethodL |
|
164 // Run specified method. Contains also table of test mothods and their names. |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 TInt CAudioRoutingTestClass::RunMethodL( CStifItemParser& aItem ) |
|
168 { |
|
169 |
|
170 static TStifFunctionInfo const KFunctions[] = |
|
171 { |
|
172 // Copy this line for every implemented function. |
|
173 // First string is the function name used in TestScripter script file. |
|
174 // Second is the actual implementation member function. |
|
175 ENTRY( "AudioInput", CAudioRoutingTestClass::CreateAudioInput), |
|
176 ENTRY( "CreateObject", CAudioRoutingTestClass::CreateObject), |
|
177 ENTRY( "AudioInputs", CAudioRoutingTestClass::AudioInput), |
|
178 ENTRY( "SetAudioInput", CAudioRoutingTestClass::SetAudioInputL), |
|
179 ENTRY( "AudioOutput", CAudioRoutingTestClass::AudioOutput), |
|
180 ENTRY( "DefaultAudioOutput", CAudioRoutingTestClass::DefaultAudioOutput), |
|
181 ENTRY( "RegisterObserver", CAudioRoutingTestClass::RegisterObserverL), |
|
182 ENTRY( "SecureOutput", CAudioRoutingTestClass::SecureOutput), |
|
183 ENTRY( "SetAudioOutput", CAudioRoutingTestClass::SetAudioOutputL), |
|
184 ENTRY( "SetSecureOutput", CAudioRoutingTestClass::SetSecureOutputL), |
|
185 ENTRY( "UnregisterObserver", CAudioRoutingTestClass::UnregisterObserver), |
|
186 }; |
|
187 |
|
188 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
|
189 |
|
190 return RunInternalL( KFunctions, count, aItem ); |
|
191 |
|
192 } |
|
193 |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CAudioAudioRoutingTest::EventName |
|
197 // Return descriptor with the notification description |
|
198 // ----------------------------------------------------------------------------- |
|
199 TPtrC CAudioRoutingTestClass::EventName( TInt aKey ) |
|
200 { |
|
201 static TText* const badKeyword = (TText*)L"BadKeyword"; |
|
202 static TText* const keywords[] = |
|
203 { |
|
204 |
|
205 (TText*)L"EInitializeComplete", |
|
206 |
|
207 }; |
|
208 |
|
209 |
|
210 |
|
211 if( (TUint)aKey >= (sizeof( keywords )/sizeof(TText*)) ) |
|
212 { |
|
213 iLog->Log(_L("Keyword out of bounds")); |
|
214 TPtrC keyword( badKeyword ); |
|
215 return keyword; |
|
216 } |
|
217 else |
|
218 { |
|
219 TPtrC keyword( keywords[aKey] ); |
|
220 return keyword; |
|
221 } |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CAudioAudioRoutingTest::AddExpectedEvent |
|
226 // Add an event to the expected events' list |
|
227 // ----------------------------------------------------------------------------- |
|
228 void CAudioRoutingTestClass::AddExpectedEvent(TG711ExpectedEvent event, TInt ms) |
|
229 { |
|
230 FTRACE(FPrint(_L("CAudioRoutingTestClass::AddExpectedEvent"))); |
|
231 iExpectedEvents.Append(event); |
|
232 TPtrC eventName = EventName(event); |
|
233 iLog->Log(_L("Adding expected event:(0x%02x)%S Total=%d"), event, &eventName, iExpectedEvents.Count() ); |
|
234 |
|
235 if ( iTimeoutController && !iTimeoutController->IsActive() ) |
|
236 { |
|
237 if (ms > 0) |
|
238 { |
|
239 iTimeoutController->Start( TTimeIntervalMicroSeconds(ms * 1000) ); |
|
240 } |
|
241 else |
|
242 { |
|
243 iLog->Log(_L("Timeout with default value (1s)")); |
|
244 iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) ); |
|
245 } |
|
246 } |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CAudioAudioRoutingTest::RemoveExpectedEvent |
|
251 // Remove the indicated event from the expected events' list |
|
252 // ----------------------------------------------------------------------------- |
|
253 TBool CAudioRoutingTestClass::RemoveExpectedEvent(TG711ExpectedEvent aEvent) |
|
254 { |
|
255 FTRACE(FPrint(_L("CAudioRoutingTestClass::RemoveExpectedEvent"))); |
|
256 TBool match = EFalse; |
|
257 for (TUint i=0; i < iExpectedEvents.Count() ; i++) |
|
258 { |
|
259 if (iExpectedEvents[i] == aEvent) |
|
260 { |
|
261 iExpectedEvents.Remove(i); |
|
262 match = ETrue; |
|
263 break; |
|
264 } |
|
265 } |
|
266 |
|
267 return match; |
|
268 } |
|
269 |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CAudioAudioRoutingTest::RemoveAllExpectedEvents |
|
273 // Remove the indicated event from the expected events' list |
|
274 // ----------------------------------------------------------------------------- |
|
275 void CAudioRoutingTestClass::RemoveAllExpectedEvents() |
|
276 { |
|
277 FTRACE(FPrint(_L("CAudioRoutingTestClass::RemoveAllExpectedEvents"))); |
|
278 iLog->Log(_L("Removing all expected events")); |
|
279 |
|
280 iExpectedEvents.Reset(); |
|
281 iOcurredEvents.Reset(); |
|
282 } |
|
283 |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CAudioAudioRoutingTest::ProcessEvent |
|
287 // ----------------------------------------------------------------------------- |
|
288 void CAudioRoutingTestClass::ProcessEvent(TG711ExpectedEvent aEvent, TInt aError) |
|
289 { |
|
290 FTRACE(FPrint(_L("CAudioRoutingTestClass::ProcessEvent"))); |
|
291 TPtrC nameEvent = EventName(aEvent); |
|
292 |
|
293 // Check for error |
|
294 if (aError == KErrNone) |
|
295 { |
|
296 // Remove the event |
|
297 if (RemoveExpectedEvent(aEvent)) |
|
298 { |
|
299 iLog->Log(_L("Expected Event: (0x%02x)%S has ocurred Total=%d"), aEvent, &nameEvent,iExpectedEvents.Count()); |
|
300 } |
|
301 else |
|
302 { |
|
303 iLog->Log(_L("Event: (0x%02x)%S has ocurred"), aEvent, &nameEvent); |
|
304 return; |
|
305 } |
|
306 |
|
307 // All expected events have ocurred |
|
308 if (iExpectedEvents.Count() == 0 ) |
|
309 { |
|
310 Signal(); |
|
311 iTimeoutController->Cancel(); |
|
312 } |
|
313 } |
|
314 else |
|
315 { |
|
316 iLog->Log(_L("[Error] Event: (0x%02x)%S return with error code=%d"), aEvent, &nameEvent, aError); |
|
317 if (iExpectedEvents.Count() != 0 ) |
|
318 { |
|
319 RemoveExpectedEvent(aEvent); |
|
320 } |
|
321 iTimeoutController->Cancel(); |
|
322 Signal(KErrCallbackErrorCode); |
|
323 } |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CAudioAudioRoutingTest::HandleTimeout |
|
328 // Review if all the expected events have ocurred once the time is over |
|
329 // ----------------------------------------------------------------------------- |
|
330 |
|
331 void CAudioRoutingTestClass::HandleTimeout(TInt aError) |
|
332 { |
|
333 FTRACE(FPrint(_L("CAudioRoutingTestClass::HandleTimeout"))); |
|
334 // All expected events have ocurred |
|
335 if (aError != KErrNone) |
|
336 { |
|
337 if (iExpectedEvents.Count() == 0 ) |
|
338 { |
|
339 iLog->Log(_L("Timing out but events have ocurred")); |
|
340 Signal(); |
|
341 } |
|
342 else |
|
343 { |
|
344 RemoveAllExpectedEvents(); |
|
345 iLog->Log(_L("Timing out and events still pending")); |
|
346 Signal(KErrEventPending); |
|
347 } |
|
348 } |
|
349 else |
|
350 { |
|
351 iLog->Log(_L("Timing out return a error %d"), aError); |
|
352 Signal(aError); |
|
353 } |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CAudioAudioRoutingTest::SetTimeout |
|
358 // Create a timer and set a timeout |
|
359 // When the timeout is reached the test case is marked as failed |
|
360 // It's used rather than the "timeout" keyword in the configuration file |
|
361 // because in this way the log continues |
|
362 // ----------------------------------------------------------------------------- |
|
363 TInt CAudioRoutingTestClass::SetTimeout( CStifItemParser& aItem ) |
|
364 { |
|
365 FTRACE(FPrint(_L("CAudioRoutingTestClass::SetTimeout"))); |
|
366 TInt timeout=0; |
|
367 TInt error = aItem.GetNextInt(timeout) ; |
|
368 if ( iTimeoutController ) |
|
369 { |
|
370 if ( timeout > 0 ) |
|
371 { |
|
372 iTimeoutController->Start( TTimeIntervalMicroSeconds(timeout*1000) ); |
|
373 } |
|
374 else |
|
375 { |
|
376 iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) ); |
|
377 } |
|
378 } |
|
379 else |
|
380 { |
|
381 iLog->Log(_L("Timeout Controller doesn't exist")); |
|
382 error = KErrTimeoutController; |
|
383 } |
|
384 return error; |
|
385 } |
|
386 |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // Uses the TestModuleBase API to allow a panic as exit reason for a test case |
|
390 // ----------------------------------------------------------------------------- |
|
391 TInt CAudioRoutingTestClass::SetAllowedPanic( CStifItemParser& aItem ) |
|
392 { |
|
393 FTRACE(FPrint(_L("CAudioRoutingTestClass::SetAllowedPanic"))); |
|
394 TInt error = KErrNone; |
|
395 TInt panicCode; |
|
396 TPtrC panicType; |
|
397 if ( ( KErrNone == aItem.GetNextString(panicType) ) && |
|
398 ( KErrNone == aItem.GetNextInt(panicCode) ) ) |
|
399 { |
|
400 iLog->Log(_L("Allowing panic: %S %d"), &panicType, panicCode); |
|
401 iTestModuleIf.SetExitReason( CTestModuleIf::EPanic, panicCode ); |
|
402 iNormalExitReason = EFalse; |
|
403 } |
|
404 else |
|
405 { |
|
406 iLog->Log(KMsgBadTestParameters); |
|
407 error = KErrBadTestParameter; |
|
408 } |
|
409 return error; |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // CAudioAudioRoutingTest::SetExpectedEvents() |
|
414 // ----------------------------------------------------------------------------- |
|
415 TInt CAudioRoutingTestClass::SetExpectedEvents( CStifItemParser& aItem ) |
|
416 { |
|
417 FTRACE(FPrint(_L("CAudioRoutingTestClass::SetExpectedEvents"))); |
|
418 TInt error = KErrNone; |
|
419 TInt event=0; |
|
420 while ( KErrNone == aItem.GetNextInt(event)) |
|
421 { |
|
422 AddExpectedEvent(static_cast<TG711ExpectedEvent>(event), 0); // Default timeout value |
|
423 } |
|
424 return error; |
|
425 } |
|
426 |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // CAudioAudioRoutingTest::ExampleL |
|
430 // Example test method function. |
|
431 // (other items were commented in a header). |
|
432 // ----------------------------------------------------------------------------- |
|
433 // |
|
434 TInt CAudioRoutingTestClass::ExampleL( CStifItemParser& aItem ) |
|
435 { |
|
436 _LIT( KAudioRoutingTestClass, "AudioRoutingTestClass" ); |
|
437 _LIT( KExample, "In Example" ); |
|
438 TestModuleIf().Printf( 0, KAudioRoutingTestClass, KExample ); |
|
439 |
|
440 iLog->Log( KExample ); |
|
441 |
|
442 TInt i = 0; |
|
443 TPtrC string; |
|
444 _LIT( KParam, "Param[%i]: %S" ); |
|
445 while ( aItem.GetNextString ( string ) == KErrNone ) |
|
446 { |
|
447 TestModuleIf().Printf( i, KAudioRoutingTestClass, KParam, i, &string ); |
|
448 i++; |
|
449 } |
|
450 |
|
451 return KErrNone; |
|
452 } |
|
453 |
|
454 // ----------------------------------------------------------------------------- |
|
455 // CG711DecoderIntfcTestClass::CreateObject |
|
456 // Create Factory |
|
457 // ----------------------------------------------------------------------------- |
|
458 // |
|
459 |
|
460 |
|
461 TInt CAudioRoutingTestClass::CreateObject( CStifItemParser& aItem ) |
|
462 { |
|
463 FTRACE(FPrint(_L("CAudioAudioRoutingTest::CreateObject"))); |
|
464 iLog->Log(_L("CAudioAudioRoutingTest::CreateObject")); |
|
465 TInt error = KErrNone; |
|
466 |
|
467 TPtrC object; |
|
468 aItem.GetNextString ( object ); |
|
469 |
|
470 iObject.Set(object); |
|
471 iLog->Log(_L("the object to create is [%S]"),&object); |
|
472 |
|
473 if (object == KTagDevSound) |
|
474 { |
|
475 TRAP(error, iDevSound = CMMFDevSound::NewL()); |
|
476 if (error == KErrNone) |
|
477 { |
|
478 TRAP(error,iDevSound->InitializeL(*this,KMMFFourCCCodeAMR,EMMFStatePlaying)); |
|
479 } |
|
480 } |
|
481 else if (object == KTagRecorder) |
|
482 { |
|
483 iInputOutput = ETrue; |
|
484 CreateInput(); |
|
485 } |
|
486 else if (object== KTagCustomCommand) |
|
487 { |
|
488 TPtrC type; |
|
489 aItem.GetNextString ( type ); |
|
490 if (type == KTagAudioPlayer) |
|
491 { |
|
492 TRAP(error,iCustomCommandUtility = CCustomCommandUtility::NewL(*iUtil)); |
|
493 } |
|
494 else |
|
495 { |
|
496 TRAP(error,iCustomCommandUtility = CCustomCommandUtility::NewL(*iRecorder,ETrue)); |
|
497 } |
|
498 } |
|
499 else if (object == KTagCustomInterface) |
|
500 { |
|
501 TPtrC type; |
|
502 aItem.GetNextString ( type ); |
|
503 if (type == KTagAudioPlayer) |
|
504 { |
|
505 TRAP(error,iCustomInterfaceUtility = CCustomInterfaceUtility::NewL(*iUtil)); |
|
506 } |
|
507 else if (type == KTagCustomCommand) |
|
508 { |
|
509 TRAP(error,iCustomInterfaceUtility = CCustomInterfaceUtility::NewL(*iCustomCommandUtility)); |
|
510 } |
|
511 else if (type == KTagRecorder) |
|
512 { |
|
513 TRAP(error,iCustomInterfaceUtility = CCustomInterfaceUtility::NewL(*iRecorder,ETrue)); |
|
514 } |
|
515 } |
|
516 else if (object == KTagInputStream) |
|
517 { |
|
518 TRAP(error,iAudioInputStream = CMdaAudioInputStream::NewL(*this)); |
|
519 } |
|
520 else if (object == KTagAudioPlayer) |
|
521 { |
|
522 CreateOutput(); |
|
523 } |
|
524 else if (object == KTagOuputRecord) |
|
525 { |
|
526 iInputOutput = EFalse; |
|
527 CreateInput(); |
|
528 } |
|
529 else if (object == KTagOutputStream) |
|
530 { |
|
531 iStreamSettings.iChannels = TMdaAudioDataSettings::EChannelsMono; |
|
532 iStreamSettings.iSampleRate = TMdaAudioDataSettings::ESampleRate16000Hz; |
|
533 iStreamSettings.iVolume = 1; |
|
534 TRAPD(error, iAudioOutputStream = CMdaAudioOutputStream::NewL(*this)); |
|
535 if (error == KErrNone) |
|
536 { |
|
537 iAudioOutputStream->Open(&iStreamSettings); |
|
538 } |
|
539 } |
|
540 else if (object == KTagToneUtility) |
|
541 { |
|
542 TRAP(error,iAudioTone = CMdaAudioToneUtility::NewL(*this)); |
|
543 } |
|
544 else if (object == KTagDevSound1) |
|
545 { |
|
546 TRAP(error, iDevSound = CMMFDevSound::NewL()); |
|
547 } |
|
548 else if (object == KTagMidiClient) |
|
549 { |
|
550 TRAP(error, iMidiClientUtility = CMidiClientUtility::NewL(*this,80,TMdaPriorityPreference(0x00000000),EFalse)); |
|
551 //TRAP(error, iMidiClientUtility = CMidiClientUtility::NewL(*this)); |
|
552 if(error == KErrNone) |
|
553 { |
|
554 isInput = EFalse; |
|
555 //iMidiClientUtility->OpenFile(KAudioMidiFile); |
|
556 } |
|
557 } |
|
558 else if (object == KTagDrmPlayer) |
|
559 { |
|
560 TRAP(error, iDrmPlayerUtility = CDrmPlayerUtility::NewL(*this,EMdaPriorityNormal,TMdaPriorityPreference(0x00000000))); |
|
561 if (error == KErrNone) |
|
562 { |
|
563 iDrmPlayerUtility->OpenFileL(KAudioDrmFile); |
|
564 } |
|
565 } |
|
566 else if (object == KTagVideoPlayer) |
|
567 { |
|
568 aItem.GetNextString ( object ); |
|
569 if(object==_L("Input")) |
|
570 { |
|
571 isInput = ETrue; |
|
572 } |
|
573 else if(object==_L("Output")) |
|
574 { |
|
575 isInput = EFalse; |
|
576 } |
|
577 error = KErrNone; |
|
578 TRAP(error, CreateSessionAndScreen()); |
|
579 TRAP(error, CreateWindowGroup()); |
|
580 TRAP(error, CreateVideoWindow()); |
|
581 TRAP(error, CreateVideoObject(aItem)); |
|
582 |
|
583 } |
|
584 if (error == KErrNone) |
|
585 { |
|
586 AddExpectedEvent(EInitializeComplete, KMediumTimeout); |
|
587 } |
|
588 else |
|
589 { |
|
590 iLog->Log(_L("CAudioRoutingTestClass::CreateObject Error [%d] - [%S]"),error,&object); |
|
591 FTRACE(FPrint(_L("CAudioRoutingTestClass::CreateObject Error [%d] - [%S]"),error,&object)); |
|
592 } |
|
593 return error; |
|
594 } |
|
595 |
|
596 TInt CAudioRoutingTestClass::CreateAudioInput( CStifItemParser& aItem ) |
|
597 { |
|
598 TInt error = KErrNone; |
|
599 |
|
600 TPtrC object; |
|
601 RArray<CAudioInput::TAudioInputPreference> inputArray; |
|
602 |
|
603 aItem.GetNextString ( object ); |
|
604 iLog->Log(_L("The AudioInput to create is with [%S]"),&object); |
|
605 |
|
606 if ( object == KTagVideoRecord ) |
|
607 { |
|
608 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioInput"))); |
|
609 iLog->Log(_L("CAudioRoutingTest::CAudioInput")); |
|
610 iVideoRecord = NULL; |
|
611 TRAP(error, iAudioInput = CAudioInput::NewL(*iVideoRecord)); |
|
612 if (error == KErrNone) |
|
613 { |
|
614 iLog->Log(_L("CAudioInput::NewL(*iVideoRecord) OK")); |
|
615 } |
|
616 } |
|
617 |
|
618 else if ( object == KTagDevSound ) |
|
619 { |
|
620 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioInput"))); |
|
621 iLog->Log(_L("CAudioRoutingTest::CAudioInput")); |
|
622 TRAP(error, iAudioInput = CAudioInput::NewL(*iDevSound)); |
|
623 if (error == KErrNone) |
|
624 { |
|
625 iLog->Log(_L("CAudioInput::NewL(*iDevSound) OK")); |
|
626 } |
|
627 } |
|
628 else if (object == KTagRecorder) |
|
629 { |
|
630 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioInput"))); |
|
631 iLog->Log(_L("CAudioRoutingTest::CAudioInput")); |
|
632 TRAP(error, iAudioInput = CAudioInput::NewL(*iRecorder)); |
|
633 if (error == KErrNone) |
|
634 { |
|
635 iLog->Log(_L("CAudioInput::NewL(*iRecorder) OK")); |
|
636 } |
|
637 } |
|
638 else if (object == KTagCustomCommand) |
|
639 { |
|
640 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioInput - iCustomCommandUtility"))); |
|
641 iLog->Log(_L("CAudioRoutingTest::CAudioInput - iCustomCommandUtility")); |
|
642 TRAP(error, iAudioInput = CAudioInput::NewL(*iCustomCommandUtility)); |
|
643 if (error == KErrNone) |
|
644 { |
|
645 iLog->Log(_L("CAudioInput::NewL(*iCustomCommandUtility) OK")); |
|
646 } |
|
647 } |
|
648 else if (object == KTagCustomInterface) |
|
649 { |
|
650 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioInput - CustomInterfaceUtility"))); |
|
651 iLog->Log(_L("CAudioRoutingTest::CAudioInput - CustomInterfaceUtility")); |
|
652 TRAP(error, iAudioInput = CAudioInput::NewL(*iCustomInterfaceUtility)); |
|
653 if (error == KErrNone) |
|
654 { |
|
655 iLog->Log(_L("CAudioInput::NewL(*iCustomInterfaceUtility) OK")); |
|
656 } |
|
657 } |
|
658 else if (object == KTagInputStream) |
|
659 { |
|
660 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioInput - InputStream"))); |
|
661 iLog->Log(_L("CAudioRoutingTest::CAudioInput - InputStream")); |
|
662 TRAP(error, iAudioInput = CAudioInput::NewL(*iAudioInputStream)); |
|
663 if (error == KErrNone) |
|
664 { |
|
665 iLog->Log(_L(" CAudioInput::NewL(*iAudioInputStream) OK")); |
|
666 } |
|
667 } |
|
668 else if (object == KTagOuputRecord) |
|
669 { |
|
670 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioInput - InputStream"))); |
|
671 iLog->Log(_L("CAudioRoutingTest::CAudioInput - InputStream")); |
|
672 TRAP(error, iAudioOutput = CAudioOutput::NewL(*iRecorder,ETrue)); |
|
673 if (error == KErrNone) |
|
674 { |
|
675 iLog->Log(_L("CAudioOutput::NewL(*iRecorder,ETrue OK")); |
|
676 } |
|
677 } |
|
678 else if (object == KTagOutputStream) |
|
679 { |
|
680 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioOutput - OutputStream"))); |
|
681 iLog->Log(_L("CAudioRoutingTest::CAudioOutput - OutputStream")); |
|
682 TRAP(error, iAudioOutput = CAudioOutput::NewL(*iAudioOutputStream)); |
|
683 if (error == KErrNone) |
|
684 { |
|
685 iLog->Log(_L("CAudioOutput::NewL(*iAudioOutputStream) OK")); |
|
686 } |
|
687 } |
|
688 else if (object == KTagToneUtility) |
|
689 { |
|
690 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioOutput - AudioTone"))); |
|
691 iLog->Log(_L("CAudioRoutingTest::CAudioOutput - AudioTone")); |
|
692 TRAP(error, iAudioOutput = CAudioOutput::NewL(*iAudioTone)); |
|
693 if (error == KErrNone) |
|
694 { |
|
695 iLog->Log(_L("CAudioOutput::NewL(*iAudioTone) OK")); |
|
696 } |
|
697 } |
|
698 else if (object == KTagDevSound1) |
|
699 { |
|
700 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioOutput - DevSound"))); |
|
701 iLog->Log(_L("CAudioRoutingTest::CAudioOutput - DevSound")); |
|
702 TRAP(error, iAudioOutput = CAudioOutput::NewL(*iDevSound)); |
|
703 if (error == KErrNone) |
|
704 { |
|
705 iLog->Log(_L("CAudioOutput::NewL(*iDevSound) OK")); |
|
706 } |
|
707 } |
|
708 else if (object == KTagCustomInterfaceOutput) |
|
709 { |
|
710 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioOutput - CustomInterfaceOutput"))); |
|
711 iLog->Log(_L("CAudioRoutingTest::CAudioOutput - CustomInterfaceOutput")); |
|
712 TRAP(error, iAudioOutput = CAudioOutput::NewL(*iCustomInterfaceUtility)); |
|
713 } |
|
714 else if (object == KTagAudioPlayer) |
|
715 { |
|
716 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioOutput - AudioPlayer"))); |
|
717 iLog->Log(_L("CAudioRoutingTest::CAudioOutput - AudioPlayer")); |
|
718 TRAPD(error,iAudioOutput = CAudioOutput::NewL(*iUtil)); |
|
719 if (error == KErrNone) |
|
720 { |
|
721 iLog->Log(_L("CAudioOutput::NewL(*iUtil) OK")); |
|
722 } |
|
723 } |
|
724 else if (object == KTagCustomCommandOutput) |
|
725 { |
|
726 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioOutput - iCustomCommandOutput"))); |
|
727 iLog->Log(_L("CAudioRoutingTest::CAudioOutput - iCustomCommandOutput")); |
|
728 TRAP(error, iAudioOutput = CAudioOutput::NewL(*iCustomCommandUtility)); |
|
729 if (error == KErrNone) |
|
730 { |
|
731 iLog->Log(_L("CAudioOutput::NewL(*iCustomCommandUtility) OK")); |
|
732 } |
|
733 } |
|
734 |
|
735 else if (object == KTagMidiClient) |
|
736 { |
|
737 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioOutput - CMidiClientUtility"))); |
|
738 iLog->Log(_L("CAudioRoutingTest::CAudioOutput - CMidiClientUtility")); |
|
739 TRAP(error, iAudioOutput = CAudioOutput::NewL(*iMidiClientUtility)); |
|
740 if (error == KErrNone) |
|
741 { |
|
742 iLog->Log(_L("CAudioOutput::NewL(*iMidiClientUtility) OK")); |
|
743 } |
|
744 } |
|
745 else if (object == KTagDrmPlayer) |
|
746 { |
|
747 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioOutput - CDrmPlayerUtility"))); |
|
748 iLog->Log(_L("CAudioRoutingTest::CAudioOutput - CDrmPlayerUtility")); |
|
749 TRAP(error, iAudioOutput = CAudioOutput::NewL(*iDrmPlayerUtility)); |
|
750 if (error == KErrNone) |
|
751 { |
|
752 iLog->Log(_L("CAudioOutput::NewL(*iDrmPlayerUtility) OK")); |
|
753 } |
|
754 } |
|
755 else if (object == KTagVideoPlayer) |
|
756 { |
|
757 FTRACE(FPrint(_L("CAudioRoutingTest::CAudioOutput - VideoPlayer"))); |
|
758 iLog->Log(_L("CAudioRoutingTest::CAudioOutput - VideoPlayer")); |
|
759 TRAP(error, iAudioOutput = CAudioOutput::NewL(*iVideoPlayerUtility)); |
|
760 if (error == KErrNone) |
|
761 { |
|
762 iLog->Log(_L("CAudioOutput::NewL(*iVideoPlayerUtility) OK")); |
|
763 } |
|
764 } |
|
765 else |
|
766 { |
|
767 iLog->Log(_L(" No Intut Data")); |
|
768 } |
|
769 if (error != KErrNone) |
|
770 { |
|
771 iLog->Log(_L("CAudioRoutingTestClass::CreateAudioInput ERROR [%d]"),error); |
|
772 } |
|
773 return error; |
|
774 } |
|
775 |
|
776 void CAudioRoutingTestClass::CreateInput() |
|
777 { |
|
778 //TInt error = KErrNone; |
|
779 isInput = ETrue; |
|
780 iUtil = CMdaAudioPlayerUtility::NewFilePlayerL(KMp3TestFile, *this); |
|
781 TRAPD(error, iRecorder = CMdaAudioRecorderUtility::NewL(*this)); |
|
782 if (error == KErrNone) |
|
783 { |
|
784 iLog->Log(_L("CMdaAudioRecorderUtility::NewL(*this) OK")); |
|
785 } |
|
786 } |
|
787 |
|
788 void CAudioRoutingTestClass::CreateOutput() |
|
789 { |
|
790 isInput = EFalse; |
|
791 iUtil = CMdaAudioPlayerUtility::NewFilePlayerL(KMp3TestFile, *this); |
|
792 } |
|
793 |
|
794 TInt CAudioRoutingTestClass::CreateVideoInput() |
|
795 { |
|
796 // TInt error1 = KErrNone; |
|
797 TInt error = KErrNone; |
|
798 isInput = ETrue; |
|
799 iUtil = CMdaAudioPlayerUtility::NewFilePlayerL(KMp3TestFile,*this); |
|
800 if (iUtil) |
|
801 { |
|
802 iRecorder = CMdaAudioRecorderUtility::NewL(*this); |
|
803 if (iRecorder) |
|
804 { |
|
805 iLog->Log(_L("CMdaAudioRecorderUtility::NewL(*this) OK")); |
|
806 } |
|
807 } |
|
808 return error; |
|
809 } |
|
810 |
|
811 TInt CAudioRoutingTestClass::CreateVideoWindow() |
|
812 { |
|
813 TInt error = KErrNone; |
|
814 TRAP(error,iWindow = RWindow( iWindowSession )); |
|
815 if (error == KErrNone) |
|
816 { |
|
817 TRAP(error,User::LeaveIfError(iWindow.Construct(iWindowGroup, reinterpret_cast<TUint32>(&iWindowGroup) + 1))); |
|
818 if (error == KErrNone) |
|
819 { |
|
820 iWindow.SetBackgroundColor(TRgb(0x90, 0x90, 0x90)); |
|
821 iWindow.Activate(); |
|
822 iWindow.SetExtent(TPoint(0, 0), TSize(screenWidth, screenHeight)); |
|
823 iWindow.SetVisible(ETrue); |
|
824 iWindowGc->Activate(iWindow); |
|
825 iRect = TRect(iWindow.Size()); |
|
826 iWindow.Invalidate(iRect); |
|
827 iWindow.BeginRedraw(iRect); |
|
828 } |
|
829 } |
|
830 return error; |
|
831 } |
|
832 |
|
833 TInt CAudioRoutingTestClass::DeleteVideoWindow() |
|
834 { |
|
835 TInt error = KErrNone; |
|
836 |
|
837 TRAP(error,iWindowSession.Close()); |
|
838 |
|
839 if (iScreenDevice) |
|
840 { |
|
841 |
|
842 } |
|
843 if (iWindowGc) |
|
844 { |
|
845 |
|
846 } |
|
847 |
|
848 return error; |
|
849 } |
|
850 |
|
851 TInt CAudioRoutingTestClass::CreateSessionAndScreen() |
|
852 { |
|
853 TInt error = KErrNone; |
|
854 error = User::LeaveIfError(iWindowSession.Connect()); |
|
855 |
|
856 if (error == KErrNone) |
|
857 { |
|
858 TRAP(error,iScreenDevice = new(ELeave) CWsScreenDevice(iWindowSession)); |
|
859 } |
|
860 |
|
861 if (error == KErrNone) |
|
862 { |
|
863 TRAP(error, iScreenDevice->Construct()); |
|
864 } |
|
865 |
|
866 return error; |
|
867 } |
|
868 |
|
869 TInt CAudioRoutingTestClass::CreateVideoObject( CStifItemParser& aItem ) |
|
870 { |
|
871 TInt error = KErrNone; |
|
872 TPtrC object; |
|
873 aItem.GetNextString ( object ); |
|
874 TRAP(error, iVideoPlayerUtility = CVideoPlayerUtility::NewL ( *this, |
|
875 EMdaPriorityNormal, |
|
876 EMdaPriorityPreferenceNone, |
|
877 iWindowSession, |
|
878 *iScreenDevice, |
|
879 iWindow, |
|
880 iRect, |
|
881 iRect)); |
|
882 if (error == KErrNone) |
|
883 { |
|
884 TRAP(error, iVideoPlayerUtility->OpenFileL(K3gpTestFile)); |
|
885 if (error == KErrNone) |
|
886 { |
|
887 if (!(isInput)) |
|
888 { |
|
889 TRAP(error, iVideoRecord = CVideoRecorderUtility::NewL(*this)); |
|
890 } |
|
891 } |
|
892 } |
|
893 if (error == KErrNone) |
|
894 { |
|
895 EndDrawing(); |
|
896 iWindow.Close(); |
|
897 iWindowGroup.Close(); |
|
898 } |
|
899 |
|
900 return error; |
|
901 } |
|
902 |
|
903 TInt CAudioRoutingTestClass::CreateWindowGroup() |
|
904 { |
|
905 TInt error = KErrNone; |
|
906 TRAP(error, iWindowGroup = RWindowGroup(iWindowSession)); |
|
907 if (error == KErrNone) |
|
908 { |
|
909 error = User::LeaveIfError(iWindowGroup.Construct(reinterpret_cast<TUint32>(&iWindowGroup), EFalse)); |
|
910 if (error == KErrNone) |
|
911 { |
|
912 TRAP(error, iWindowGroup.SetOrdinalPosition(10, ECoeWinPriorityAlwaysAtFront)); |
|
913 } |
|
914 } |
|
915 else |
|
916 { |
|
917 iLog->Log(_L("iWindowGroup = RWindowGroup(iWindowSession) Failed [%d]"),error); |
|
918 } |
|
919 |
|
920 User::LeaveIfError(iScreenDevice->CreateContext(iWindowGc)); |
|
921 |
|
922 return error; |
|
923 } |
|
924 |
|
925 TInt CAudioRoutingTestClass::EndDrawing() |
|
926 { |
|
927 TInt error = KErrNone; |
|
928 TRAP(error,{iWindow.EndRedraw();iWindowGc->Deactivate();iWindowSession.Flush();}); |
|
929 if (error!=KErrNone) |
|
930 { |
|
931 iLog->Log(_L("CAudioRoutingTestClass::EndDrawing Failed [%d]"),error); |
|
932 } |
|
933 return error; |
|
934 } |
|
935 |
|
936 TInt CAudioRoutingTestClass::AudioInput() |
|
937 { |
|
938 if (iAudioInput) |
|
939 { |
|
940 CAudioInput::TAudioInputArray currentInputs = iAudioInput->AudioInput(); |
|
941 CAudioInput::TAudioInputPreference currentInput = currentInputs[0]; |
|
942 iLog->Log(_L("AudioInput - currentInput = %d"),currentInput); |
|
943 } |
|
944 return KErrNone; |
|
945 } |
|
946 |
|
947 TInt CAudioRoutingTestClass::SetAudioInputL() |
|
948 { |
|
949 if (iAudioInput) |
|
950 { |
|
951 RArray<CAudioInput::TAudioInputPreference> inputArray; |
|
952 inputArray.Append(CAudioInput::EDefaultMic); |
|
953 iAudioInput->SetAudioInputL(inputArray.Array()); |
|
954 inputArray.Reset(); |
|
955 } |
|
956 iLog->Log(_L("AudioInput - SetAudioInputL ")); |
|
957 return KErrNone; |
|
958 } |
|
959 |
|
960 TInt CAudioRoutingTestClass::AudioOutput() |
|
961 { |
|
962 if (iAudioOutput) |
|
963 { |
|
964 iAudioOutput->AudioOutput(); |
|
965 } |
|
966 iLog->Log(_L("AudioOutput - AudioOutput ")); |
|
967 return KErrNone; |
|
968 } |
|
969 TInt CAudioRoutingTestClass::DefaultAudioOutput() |
|
970 { |
|
971 if (iAudioOutput) |
|
972 { |
|
973 iAudioOutput->DefaultAudioOutput(); |
|
974 } |
|
975 iLog->Log(_L("iAudioOutput - DefaultAudioOutput ")); |
|
976 return KErrNone; |
|
977 } |
|
978 |
|
979 TInt CAudioRoutingTestClass::RegisterObserverL() |
|
980 { |
|
981 if(iAudioOutput) |
|
982 { |
|
983 iAudioOutput->RegisterObserverL(*this); |
|
984 } |
|
985 iLog->Log(_L("iAudioOutput - RegisterObserverL ")); |
|
986 return KErrNone; |
|
987 } |
|
988 |
|
989 TInt CAudioRoutingTestClass::SecureOutput() |
|
990 { |
|
991 if (iAudioOutput) |
|
992 { |
|
993 TBool secureOutput = iAudioOutput->SecureOutput(); |
|
994 iLog->Log(_L("CAudioRoutingTestClass::SecureOutput - SecureOutput = %d"),secureOutput); |
|
995 } |
|
996 iLog->Log(_L("iAudioOutput - SecureOutput ")); |
|
997 return KErrNone; |
|
998 } |
|
999 |
|
1000 |
|
1001 TInt CAudioRoutingTestClass::SetAudioOutputL() |
|
1002 { |
|
1003 if(iAudioOutput) |
|
1004 { |
|
1005 iAudioOutput->SetAudioOutputL(CAudioOutput::EPublic); |
|
1006 } |
|
1007 iLog->Log(_L("iAudioOutput - SetAudioOutputL ")); |
|
1008 return KErrNone; |
|
1009 } |
|
1010 |
|
1011 TInt CAudioRoutingTestClass::SetSecureOutputL() |
|
1012 { |
|
1013 if(iAudioOutput) |
|
1014 { |
|
1015 iAudioOutput->SetSecureOutputL(EFalse); |
|
1016 } |
|
1017 iLog->Log(_L("iAudioOutput - SetSecureOutputL ")); |
|
1018 return KErrNone; |
|
1019 } |
|
1020 |
|
1021 TInt CAudioRoutingTestClass::UnregisterObserver() |
|
1022 { |
|
1023 iLog->Log(_L("iAudioOutput - UnregisterObserver INIT")); |
|
1024 if(iAudioOutput) |
|
1025 { |
|
1026 iAudioOutput->UnregisterObserver(*this); |
|
1027 } |
|
1028 iLog->Log(_L("iAudioOutput - UnregisterObserver ")); |
|
1029 return KErrNone; |
|
1030 } |
|
1031 // End of File |