0
|
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: Restricted Audio Output Test
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <e32svr.h>
|
|
22 |
#include <StifParser.h>
|
|
23 |
#include <Stiftestinterface.h>
|
|
24 |
#include "RestrictedAOTestClass.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 .
|
|
57 |
//
|
|
58 |
// Returns: ?value_1:
|
|
59 |
// ?value_n: _line1
|
|
60 |
// _line2
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
/*
|
|
64 |
?type ?function_name(
|
|
65 |
?arg_type arg, //
|
|
66 |
?arg_type arg) //
|
|
67 |
{
|
|
68 |
|
|
69 |
?code // ?comment
|
|
70 |
|
|
71 |
// ?comment
|
|
72 |
?code
|
|
73 |
}
|
|
74 |
*/
|
|
75 |
|
|
76 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
77 |
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
// CRestrictedAOTestClass::Delete
|
|
80 |
// Delete here all resources allocated and opened from test methods.
|
|
81 |
// Called from destructor.
|
|
82 |
// -----------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
void CRestrictedAOTestClass::Delete()
|
|
85 |
{
|
|
86 |
|
|
87 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::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 |
if(iRestrictedAudioOutput)
|
|
97 |
{
|
|
98 |
delete iRestrictedAudioOutput;
|
|
99 |
}
|
|
100 |
|
|
101 |
if (iDevSound)
|
|
102 |
{
|
|
103 |
delete iDevSound;
|
|
104 |
iDevSound = NULL;
|
|
105 |
}
|
5
|
106 |
|
|
107 |
if (iFactory)
|
|
108 |
{
|
|
109 |
delete iFactory;
|
|
110 |
iFactory = NULL;
|
|
111 |
}
|
0
|
112 |
REComSession::FinalClose();
|
|
113 |
|
|
114 |
}
|
|
115 |
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
// CRestrictedAOTestClass::RunMethodL
|
|
118 |
// Run specified method. Contains also table of test mothods and their names.
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
TInt CRestrictedAOTestClass::RunMethodL(
|
|
122 |
CStifItemParser& aItem )
|
|
123 |
{
|
|
124 |
|
|
125 |
static TStifFunctionInfo const KFunctions[] =
|
|
126 |
{
|
|
127 |
// Copy this line for every implemented function.
|
|
128 |
// First string is the function name used in TestScripter script file.
|
|
129 |
// Second is the actual implementation member function.
|
|
130 |
|
5
|
131 |
ENTRY( "CreateFactory", CRestrictedAOTestClass::CreateFactory ),
|
|
132 |
ENTRY( "CreateRestrictedAO", CRestrictedAOTestClass::CreateRestrictedAO ),
|
0
|
133 |
ENTRY( "AppendAllowedOutput", CRestrictedAOTestClass::AppendAllowedOutput ),
|
|
134 |
ENTRY( "RemoveAllowedOutput", CRestrictedAOTestClass::RemoveAllowedOutput ),
|
|
135 |
ENTRY( "GetAllowedOutputCount", CRestrictedAOTestClass::GetAllowedOutputCount ),
|
|
136 |
ENTRY( "GetAllowedOutput", CRestrictedAOTestClass::GetAllowedOutput ),
|
|
137 |
ENTRY( "Reset", CRestrictedAOTestClass::Reset ),
|
|
138 |
ENTRY( "Commit", CRestrictedAOTestClass::Commit ),
|
5
|
139 |
ENTRY( "GetUid", CRestrictedAOTestClass::GetUid ),
|
|
140 |
|
0
|
141 |
ENTRY( "Example", CRestrictedAOTestClass::ExampleL ),
|
|
142 |
|
|
143 |
};
|
|
144 |
|
|
145 |
const TInt count = sizeof( KFunctions ) /
|
|
146 |
sizeof( TStifFunctionInfo );
|
|
147 |
|
|
148 |
return RunInternalL( KFunctions, count, aItem );
|
|
149 |
|
|
150 |
}
|
|
151 |
|
|
152 |
|
|
153 |
// -----------------------------------------------------------------------------
|
|
154 |
// CRestrictedAOTestClass::EventName
|
|
155 |
// Return descriptor with the notification description
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
TPtrC CRestrictedAOTestClass::EventName( TInt aKey )
|
|
158 |
{
|
|
159 |
static TText* const badKeyword = (TText*)L"BadKeyword";
|
|
160 |
static TText* const keywords[] =
|
|
161 |
{
|
|
162 |
|
|
163 |
(TText*)L"EInitializeComplete",
|
|
164 |
|
|
165 |
};
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
if( (TUint)aKey >= (sizeof( keywords )/sizeof(TText*)) )
|
|
170 |
{
|
|
171 |
iLog->Log(_L("Keyword out of bounds"));
|
|
172 |
TPtrC keyword( badKeyword );
|
|
173 |
return keyword;
|
|
174 |
}
|
|
175 |
else
|
|
176 |
{
|
|
177 |
TPtrC keyword( keywords[aKey] );
|
|
178 |
return keyword;
|
|
179 |
}
|
|
180 |
}
|
|
181 |
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
// CRestrictedAOTestClass::AddExpectedEvent
|
|
184 |
// Add an event to the expected events' list
|
|
185 |
// -----------------------------------------------------------------------------
|
|
186 |
void CRestrictedAOTestClass::AddExpectedEvent(TROExpectedEvent event, TInt ms)
|
|
187 |
{
|
|
188 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::AddExpectedEvent")));
|
|
189 |
iExpectedEvents.Append(event);
|
|
190 |
TPtrC eventName = EventName(event);
|
|
191 |
iLog->Log(_L("Adding expected event:(0x%02x)%S Total=%d"), event, &eventName, iExpectedEvents.Count() );
|
|
192 |
|
|
193 |
if ( iTimeoutController && !iTimeoutController->IsActive() )
|
|
194 |
{
|
|
195 |
if (ms > 0)
|
|
196 |
{
|
|
197 |
iTimeoutController->Start( TTimeIntervalMicroSeconds(ms * 1000) );
|
|
198 |
}
|
|
199 |
else
|
|
200 |
{
|
|
201 |
iLog->Log(_L("Timeout with default value (1s)"));
|
|
202 |
iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) );
|
|
203 |
}
|
|
204 |
}
|
|
205 |
}
|
|
206 |
|
|
207 |
// -----------------------------------------------------------------------------
|
|
208 |
// CRestrictedAOTestClass::RemoveExpectedEvent
|
|
209 |
// Remove the indicated event from the expected events' list
|
|
210 |
// -----------------------------------------------------------------------------
|
|
211 |
TBool CRestrictedAOTestClass::RemoveExpectedEvent(TROExpectedEvent aEvent)
|
|
212 |
{
|
|
213 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::RemoveExpectedEvent")));
|
|
214 |
TBool match = EFalse;
|
|
215 |
for (TUint i=0; i < iExpectedEvents.Count() ; i++)
|
|
216 |
{
|
|
217 |
if (iExpectedEvents[i] == aEvent)
|
|
218 |
{
|
|
219 |
iExpectedEvents.Remove(i);
|
|
220 |
match = ETrue;
|
|
221 |
break;
|
|
222 |
}
|
|
223 |
}
|
|
224 |
|
|
225 |
return match;
|
|
226 |
}
|
|
227 |
|
|
228 |
|
|
229 |
// -----------------------------------------------------------------------------
|
|
230 |
// CRestrictedAOTestClass::RemoveAllExpectedEvents
|
|
231 |
// Remove the indicated event from the expected events' list
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
void CRestrictedAOTestClass::RemoveAllExpectedEvents()
|
|
234 |
{
|
|
235 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::RemoveAllExpectedEvents")));
|
|
236 |
iLog->Log(_L("Removing all expected events"));
|
|
237 |
|
|
238 |
iExpectedEvents.Reset();
|
|
239 |
iOcurredEvents.Reset();
|
|
240 |
}
|
|
241 |
|
|
242 |
|
|
243 |
// -----------------------------------------------------------------------------
|
|
244 |
// CRestrictedAOTestClass::ProcessEvent
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
void CRestrictedAOTestClass::ProcessEvent(TROExpectedEvent aEvent, TInt aError)
|
|
247 |
{
|
|
248 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::ProcessExpectedEvent")));
|
|
249 |
TPtrC nameEvent = EventName(aEvent);
|
|
250 |
|
|
251 |
// Check for error
|
|
252 |
if (aError == KErrNone)
|
|
253 |
{
|
|
254 |
// Remove the event
|
|
255 |
if (RemoveExpectedEvent(aEvent))
|
|
256 |
{
|
|
257 |
iLog->Log(_L("Expected Event: (0x%02x)%S has ocurred Total=%d"), aEvent, &nameEvent,iExpectedEvents.Count());
|
|
258 |
}
|
|
259 |
else
|
|
260 |
{
|
|
261 |
iLog->Log(_L("Event: (0x%02x)%S has ocurred"), aEvent, &nameEvent);
|
|
262 |
return;
|
|
263 |
}
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
// All expected events have ocurred
|
|
268 |
if (iExpectedEvents.Count() == 0 )
|
|
269 |
{
|
|
270 |
Signal();
|
|
271 |
iTimeoutController->Cancel();
|
|
272 |
}
|
|
273 |
|
|
274 |
|
|
275 |
}
|
|
276 |
else
|
|
277 |
{
|
|
278 |
iLog->Log(_L("[Error] Event: (0x%02x)%S return with error code=%d"), aEvent, &nameEvent, aError);
|
|
279 |
if (iExpectedEvents.Count() != 0 )
|
|
280 |
{
|
|
281 |
RemoveExpectedEvent(aEvent);
|
|
282 |
}
|
|
283 |
iTimeoutController->Cancel();
|
|
284 |
Signal(KErrCallbackErrorCode);
|
|
285 |
}
|
|
286 |
}
|
|
287 |
|
|
288 |
// -----------------------------------------------------------------------------
|
|
289 |
// CRestrictedAOTestClass::HandleTimeout
|
|
290 |
// Review if all the expected events have ocurred once the time is over
|
|
291 |
// -----------------------------------------------------------------------------
|
|
292 |
|
|
293 |
void CRestrictedAOTestClass::HandleTimeout(TInt aError)
|
|
294 |
{
|
|
295 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::HandleTimeout")));
|
|
296 |
// All expected events have ocurred
|
|
297 |
if (aError != KErrNone)
|
|
298 |
{
|
|
299 |
if (iExpectedEvents.Count() == 0 )
|
|
300 |
{
|
|
301 |
iLog->Log(_L("Timing out but events have ocurred"));
|
|
302 |
Signal();
|
|
303 |
}
|
|
304 |
else
|
|
305 |
{
|
|
306 |
RemoveAllExpectedEvents();
|
|
307 |
iLog->Log(_L("Timing out and events still pending"));
|
|
308 |
Signal(KErrEventPending);
|
|
309 |
}
|
|
310 |
}
|
|
311 |
else
|
|
312 |
{
|
|
313 |
iLog->Log(_L("Timing out return a error %d"), aError);
|
|
314 |
Signal(aError);
|
|
315 |
}
|
|
316 |
}
|
|
317 |
|
|
318 |
// -----------------------------------------------------------------------------
|
|
319 |
// CRestrictedAOTestClass::SetTimeout
|
|
320 |
// Create a timer and set a timeout
|
|
321 |
// When the timeout is reached the test case is marked as failed
|
|
322 |
// It's used rather than the "timeout" keyword in the configuration file
|
|
323 |
// because in this way the log continues
|
|
324 |
// -----------------------------------------------------------------------------
|
|
325 |
TInt CRestrictedAOTestClass::SetTimeout( CStifItemParser& aItem )
|
|
326 |
{
|
|
327 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::SetTimeout")));
|
|
328 |
TInt timeout=0;
|
|
329 |
TInt error = aItem.GetNextInt(timeout) ;
|
|
330 |
if ( iTimeoutController )
|
|
331 |
{
|
|
332 |
if ( timeout > 0 )
|
|
333 |
{
|
|
334 |
iTimeoutController->Start( TTimeIntervalMicroSeconds(timeout*1000) );
|
|
335 |
}
|
|
336 |
else
|
|
337 |
{
|
|
338 |
iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) );
|
|
339 |
}
|
|
340 |
}
|
|
341 |
else
|
|
342 |
{
|
|
343 |
iLog->Log(_L("Timeout Controller doesn't exist"));
|
|
344 |
error = KErrTimeoutController;
|
|
345 |
}
|
|
346 |
return error;
|
|
347 |
}
|
|
348 |
|
|
349 |
|
|
350 |
// -----------------------------------------------------------------------------
|
|
351 |
// Uses the TestModuleBase API to allow a panic as exit reason for a test case
|
|
352 |
// -----------------------------------------------------------------------------
|
|
353 |
TInt CRestrictedAOTestClass::SetAllowedPanic( CStifItemParser& aItem )
|
|
354 |
{
|
|
355 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::SetAllowedPanic")));
|
|
356 |
TInt error = KErrNone;
|
|
357 |
TInt panicCode;
|
|
358 |
TPtrC panicType;
|
|
359 |
if ( ( KErrNone == aItem.GetNextString(panicType) ) &&
|
|
360 |
( KErrNone == aItem.GetNextInt(panicCode) ) )
|
|
361 |
{
|
|
362 |
iLog->Log(_L("Allowing panic: %S %d"), &panicType, panicCode);
|
|
363 |
iTestModuleIf.SetExitReason( CTestModuleIf::EPanic, panicCode );
|
|
364 |
iNormalExitReason = EFalse;
|
|
365 |
}
|
|
366 |
else
|
|
367 |
{
|
|
368 |
iLog->Log(KMsgBadTestParameters);
|
|
369 |
error = KErrBadTestParameter;
|
|
370 |
}
|
|
371 |
return error;
|
|
372 |
}
|
|
373 |
|
5
|
374 |
TInt CRestrictedAOTestClass::GetUid( CStifItemParser& /*aItem*/ )
|
|
375 |
{
|
|
376 |
TUid AudioHandlerUid = iRestrictedAudioOutputMessageHandler->Uid();
|
|
377 |
TUid AudioProxyUid = iRestrictedAudioOutputProxy->Uid();
|
|
378 |
|
|
379 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::GetUid - AudioHandlerUid=%x, AudioProxyUid=%x "), iRestrictedAudioOutputMessageHandler->Uid(), iRestrictedAudioOutputProxy->Uid()));
|
|
380 |
iLog->Log(_L("CRestrictedAOTestClass::GetUid"));
|
|
381 |
return KErrNone;
|
|
382 |
}
|
0
|
383 |
// -----------------------------------------------------------------------------
|
|
384 |
// CRestrictedAOTestClass::SetExpectedEvents()
|
|
385 |
// -----------------------------------------------------------------------------
|
|
386 |
TInt CRestrictedAOTestClass::SetExpectedEvents( CStifItemParser& aItem )
|
|
387 |
{
|
|
388 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::SetExpectedEvents")));
|
|
389 |
TInt error = KErrNone;
|
|
390 |
TInt event=0;
|
|
391 |
while ( KErrNone == aItem.GetNextInt(event))
|
|
392 |
{
|
|
393 |
AddExpectedEvent(static_cast<TROExpectedEvent>(event), 0); // Default timeout value
|
|
394 |
}
|
|
395 |
return error;
|
|
396 |
}
|
|
397 |
|
|
398 |
|
|
399 |
// -----------------------------------------------------------------------------
|
|
400 |
// CRestrictedAOTestClass::ExampleL
|
|
401 |
// Example test method function.
|
|
402 |
// (other items were commented in a header).
|
|
403 |
// -----------------------------------------------------------------------------
|
|
404 |
//
|
|
405 |
TInt CRestrictedAOTestClass::ExampleL( CStifItemParser& aItem )
|
|
406 |
{
|
|
407 |
|
|
408 |
// Print to UI
|
|
409 |
_LIT( KRestrictedAOTestClass, "RestrictedAOTestClass" );
|
|
410 |
_LIT( KExample, "In Example" );
|
|
411 |
TestModuleIf().Printf( 0, KRestrictedAOTestClass, KExample );
|
|
412 |
// Print to log file
|
|
413 |
iLog->Log( KExample );
|
|
414 |
|
|
415 |
TInt i = 0;
|
|
416 |
TPtrC string;
|
|
417 |
_LIT( KParam, "Param[%i]: %S" );
|
|
418 |
while ( aItem.GetNextString ( string ) == KErrNone )
|
|
419 |
{
|
|
420 |
TestModuleIf().Printf( i, KRestrictedAOTestClass,
|
|
421 |
KParam, i, &string );
|
|
422 |
i++;
|
|
423 |
}
|
|
424 |
|
|
425 |
return KErrNone;
|
|
426 |
|
|
427 |
}
|
|
428 |
|
|
429 |
// -----------------------------------------------------------------------------
|
|
430 |
// CRestrictedAOTestClass::AppendAllowedOutput
|
|
431 |
// Append AllowedOutput
|
|
432 |
// -----------------------------------------------------------------------------
|
|
433 |
//
|
|
434 |
TInt CRestrictedAOTestClass::AppendAllowedOutput( CStifItemParser& aItem )
|
|
435 |
{
|
|
436 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::AppendAllowedOutput")));
|
|
437 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput"));
|
|
438 |
TInt error = KErrNone;
|
|
439 |
|
|
440 |
TPtrC AppendType;
|
|
441 |
error = aItem.GetNextString(AppendType);
|
|
442 |
if (error == KErrNone)
|
|
443 |
{
|
|
444 |
if (AppendType == KTagAll)
|
|
445 |
{
|
|
446 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAllAudio"));
|
|
447 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAllAudio);
|
|
448 |
}
|
|
449 |
else if (AppendType == KTagAudioAnalog)
|
|
450 |
{
|
|
451 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioAnalog"));
|
|
452 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioAnalog);
|
|
453 |
}
|
|
454 |
else if (AppendType == KTagFM)
|
|
455 |
{
|
|
456 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioFMTransmitter"));
|
|
457 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioFMTransmitter);
|
|
458 |
}
|
|
459 |
else if (AppendType == KTagStereoBT)
|
|
460 |
{
|
|
461 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioBtHFPHSP"));
|
|
462 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtHFPHSP);
|
|
463 |
}
|
|
464 |
else if (AppendType == KTagBTA2DP)
|
|
465 |
{
|
|
466 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioBtA2DP"));
|
|
467 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtA2DP);
|
|
468 |
}
|
|
469 |
else if (AppendType == KTagAudioUplink)
|
|
470 |
{
|
|
471 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioUplink"));
|
|
472 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioUplink);
|
|
473 |
}
|
|
474 |
else if (AppendType == KTagUSB)
|
|
475 |
{
|
|
476 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioUsb"));
|
|
477 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioUsb);
|
|
478 |
}
|
|
479 |
else if (AppendType == KTagRecord)
|
|
480 |
{
|
|
481 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioRecording"));
|
|
482 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioRecording);
|
|
483 |
}
|
|
484 |
else if (AppendType == KTagVisualization)
|
|
485 |
{
|
|
486 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowVisualization"));
|
|
487 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowVisualization);
|
|
488 |
}
|
|
489 |
|
|
490 |
/**
|
|
491 |
* RIM CR 417-7642: HDMI with HDCP to Resctricted Audio Output API
|
|
492 |
* Adding new ENUMs to CRestrictedAudioOutput::TAllowedOutputPreference for HDMI and HDCP
|
|
493 |
* EAllowAudioHDMI and EAllowAudioHdmiHdcpRequired
|
|
494 |
*/
|
|
495 |
else if (AppendType == KTagHDMI)
|
|
496 |
{
|
|
497 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioHDMI"));
|
|
498 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioHDMI);
|
|
499 |
}
|
|
500 |
else if (AppendType == KTagHdmiHdcpRequired)
|
|
501 |
{
|
|
502 |
iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioHdmiHdcpRequired"));
|
|
503 |
error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioHdmiHdcpRequired);
|
|
504 |
}
|
|
505 |
else
|
|
506 |
{
|
|
507 |
iLog->Log(KMsgBadTestParameters);
|
|
508 |
error = KErrBadTestParameter;
|
|
509 |
}
|
|
510 |
|
|
511 |
}
|
|
512 |
|
|
513 |
return error;
|
|
514 |
}
|
|
515 |
|
|
516 |
|
|
517 |
// -----------------------------------------------------------------------------
|
|
518 |
// CRestrictedAOTestClass::RemoveAllowedOutput
|
|
519 |
// Remove AllowedOutput
|
|
520 |
// -----------------------------------------------------------------------------
|
|
521 |
//
|
|
522 |
TInt CRestrictedAOTestClass::RemoveAllowedOutput( CStifItemParser& aItem )
|
|
523 |
{
|
|
524 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::RemoveAllowedOutput")));
|
|
525 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput"));
|
|
526 |
TInt error = KErrNone;
|
|
527 |
|
|
528 |
TPtrC RemoveType;
|
|
529 |
error = aItem.GetNextString(RemoveType);
|
|
530 |
if (error == KErrNone)
|
|
531 |
{
|
|
532 |
if (RemoveType == KTagAll)
|
|
533 |
{
|
|
534 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAllAudio"));
|
|
535 |
error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAllAudio);
|
|
536 |
}
|
|
537 |
else if (RemoveType == KTagAudioAnalog)
|
|
538 |
{
|
|
539 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioAnalog"));
|
|
540 |
error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioAnalog);
|
|
541 |
}
|
|
542 |
else if (RemoveType == KTagFM)
|
|
543 |
{
|
|
544 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioFMTransmitter"));
|
|
545 |
error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioFMTransmitter);
|
|
546 |
}
|
|
547 |
else if (RemoveType == KTagStereoBT)
|
|
548 |
{
|
|
549 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioBtHFPHSP"));
|
|
550 |
error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtHFPHSP);
|
|
551 |
}
|
|
552 |
else if (RemoveType == KTagBTA2DP)
|
|
553 |
{
|
|
554 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioBtA2DP"));
|
|
555 |
error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtA2DP);
|
|
556 |
}
|
|
557 |
else if (RemoveType == KTagAudioUplink)
|
|
558 |
{
|
|
559 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioUplink"));
|
|
560 |
error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioUplink);
|
|
561 |
}
|
|
562 |
else if (RemoveType == KTagUSB)
|
|
563 |
{
|
|
564 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioUsb"));
|
|
565 |
error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioUsb);
|
|
566 |
}
|
|
567 |
else if (RemoveType == KTagRecord)
|
|
568 |
{
|
|
569 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioRecording"));
|
|
570 |
error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioRecording);
|
|
571 |
}
|
|
572 |
else if (RemoveType == KTagVisualization)
|
|
573 |
{
|
|
574 |
iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowVisualization"));
|
|
575 |
error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowVisualization);
|
|
576 |
}
|
|
577 |
else
|
|
578 |
{
|
|
579 |
iLog->Log(KMsgBadTestParameters);
|
|
580 |
error = KErrBadTestParameter;
|
|
581 |
}
|
|
582 |
|
|
583 |
}
|
|
584 |
|
|
585 |
return error;
|
|
586 |
}
|
|
587 |
|
|
588 |
|
|
589 |
|
|
590 |
// -----------------------------------------------------------------------------
|
|
591 |
// CRestrictedAOTestClass::GetAllowedOutputCount
|
|
592 |
// Get AllowedOutput Count
|
|
593 |
// -----------------------------------------------------------------------------
|
|
594 |
//
|
|
595 |
TInt CRestrictedAOTestClass::GetAllowedOutputCount( CStifItemParser& /*aItem */)
|
|
596 |
{
|
|
597 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::GetAllowedOutputCount")));
|
|
598 |
iLog->Log(_L("CRestrictedAOTestClass::GetAllowedOutputCount"));
|
|
599 |
TInt error = KErrNone;
|
|
600 |
|
|
601 |
TInt aSize;
|
|
602 |
error = iRestrictedAudioOutput->GetAllowedOutputCount(aSize);
|
|
603 |
if (error == KErrNone)
|
|
604 |
error = aSize;
|
|
605 |
|
|
606 |
return error;
|
|
607 |
}
|
|
608 |
|
|
609 |
// -----------------------------------------------------------------------------
|
|
610 |
// CRestrictedAOTestClass::GetAllowedOutput
|
|
611 |
// Get Allowed Output
|
|
612 |
// -----------------------------------------------------------------------------
|
|
613 |
//
|
|
614 |
TInt CRestrictedAOTestClass::GetAllowedOutput( CStifItemParser& aItem )
|
|
615 |
{
|
|
616 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::GetAllowedOutput")));
|
|
617 |
iLog->Log(_L("CRestrictedAOTestClass::GetAllowedOutput"));
|
|
618 |
TInt error = KErrNone;
|
|
619 |
TInt aCount;
|
|
620 |
TInt index;
|
|
621 |
TInt Found = 0;
|
|
622 |
CRestrictedAudioOutput::TAllowedOutputPreference aOutput;
|
|
623 |
|
|
624 |
error = iRestrictedAudioOutput->GetAllowedOutputCount(aCount);
|
|
625 |
if (error != KErrNone)
|
|
626 |
{
|
|
627 |
iLog->Log(_L("GetAllowedOutputCount return error %d"), error);
|
|
628 |
return error;
|
|
629 |
}
|
|
630 |
|
|
631 |
TPtrC ExpectedOutput;
|
|
632 |
error = aItem.GetNextString(ExpectedOutput);
|
|
633 |
if (error != KErrNone)
|
|
634 |
{
|
|
635 |
iLog->Log(_L("Missing parameter in config file"));
|
|
636 |
return error;
|
|
637 |
}
|
|
638 |
|
|
639 |
for( index = 0; index < aCount; index++)
|
|
640 |
{
|
|
641 |
error = iRestrictedAudioOutput->GetAllowedOutput(index, aOutput);
|
|
642 |
if (error == KErrNone)
|
|
643 |
{
|
|
644 |
switch (aOutput)
|
|
645 |
{
|
|
646 |
case 0: // ALL
|
|
647 |
if (ExpectedOutput == KTagAll)
|
|
648 |
{
|
|
649 |
iLog->Log(_L("index = %d, Allow AllAudio"), index);
|
|
650 |
Found = 1;
|
|
651 |
}
|
|
652 |
break;
|
|
653 |
|
|
654 |
case 1: // Audio Analog
|
|
655 |
if (ExpectedOutput == KTagAudioAnalog)
|
|
656 |
{
|
|
657 |
iLog->Log(_L("index = %d, Allow AudioAnalog"), index);
|
|
658 |
Found = 1;
|
|
659 |
}
|
|
660 |
break;
|
|
661 |
|
|
662 |
case 2: // AudioFMTransmitter
|
|
663 |
if (ExpectedOutput == KTagFM)
|
|
664 |
{
|
|
665 |
iLog->Log(_L("index = %d, Allow AudioFMTransmitter"), index);
|
|
666 |
Found = 1;
|
|
667 |
}
|
|
668 |
break;
|
|
669 |
|
|
670 |
case 3: // AudioStereoBtHFP
|
|
671 |
if (ExpectedOutput == KTagStereoBT)
|
|
672 |
{
|
|
673 |
iLog->Log(_L("index = %d, Allow AudioStereoBtHFP"), index);
|
|
674 |
Found = 1;
|
|
675 |
}
|
|
676 |
break;
|
|
677 |
|
|
678 |
case 4: // AudioBtA2DP
|
|
679 |
if (ExpectedOutput == KTagBTA2DP)
|
|
680 |
{
|
|
681 |
iLog->Log(_L("index = %d, Allow AudioBtA2DP"), index);
|
|
682 |
Found = 1;
|
|
683 |
}
|
|
684 |
break;
|
|
685 |
|
|
686 |
case 5: // AudioUplink
|
|
687 |
if (ExpectedOutput == KTagAudioUplink)
|
|
688 |
{
|
|
689 |
iLog->Log(_L("index = %d, Allow AudioUplink"), index);
|
|
690 |
Found = 1;
|
|
691 |
}
|
|
692 |
break;
|
|
693 |
|
|
694 |
case 6: // AudioUsb
|
|
695 |
if (ExpectedOutput == KTagUSB)
|
|
696 |
{
|
|
697 |
iLog->Log(_L("index = %d, Allow AudioUsb"), index);
|
|
698 |
Found = 1;
|
|
699 |
}
|
|
700 |
break;
|
|
701 |
|
|
702 |
case 7: // Audio Recording
|
|
703 |
if (ExpectedOutput == KTagRecord)
|
|
704 |
{
|
|
705 |
iLog->Log(_L("index = %d, Allow AudioRecording"), index);
|
|
706 |
Found = 1;
|
|
707 |
}
|
|
708 |
break;
|
|
709 |
|
|
710 |
case 8: // Visualization
|
|
711 |
if (ExpectedOutput == KTagVisualization)
|
|
712 |
{
|
|
713 |
iLog->Log(_L("index = %d, Allow Visualization"), index);
|
|
714 |
Found = 1;
|
|
715 |
}
|
|
716 |
break;
|
|
717 |
|
|
718 |
default:
|
|
719 |
iLog->Log(_L("unknown audio output"));
|
|
720 |
break;
|
|
721 |
} // switch
|
|
722 |
if (Found == 1)
|
|
723 |
{
|
|
724 |
return error;
|
|
725 |
}
|
|
726 |
|
|
727 |
} // if
|
|
728 |
} //for
|
|
729 |
|
|
730 |
if (Found == 0)
|
|
731 |
{
|
|
732 |
error = KErrNotFound;
|
|
733 |
}
|
|
734 |
|
|
735 |
return error;
|
|
736 |
}
|
|
737 |
|
|
738 |
// -----------------------------------------------------------------------------
|
|
739 |
// CRestrictedAOTestClass::Reset
|
|
740 |
// Reset AllowedOutput
|
|
741 |
// -----------------------------------------------------------------------------
|
|
742 |
//
|
|
743 |
TInt CRestrictedAOTestClass::Reset( CStifItemParser& /*aItem */)
|
|
744 |
{
|
|
745 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::Reset")));
|
|
746 |
iLog->Log(_L("CRestrictedAOTestClass::Reset"));
|
|
747 |
TInt error = KErrNone;
|
|
748 |
|
|
749 |
error = iRestrictedAudioOutput->Reset();
|
|
750 |
|
|
751 |
return error;
|
|
752 |
}
|
|
753 |
|
|
754 |
// -----------------------------------------------------------------------------
|
|
755 |
// CRestrictedAOTestClass::Commit
|
|
756 |
// Commit AllowedOutput
|
|
757 |
// -----------------------------------------------------------------------------
|
|
758 |
//
|
|
759 |
TInt CRestrictedAOTestClass::Commit( CStifItemParser& /*aItem */)
|
|
760 |
{
|
|
761 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::Commit")));
|
|
762 |
iLog->Log(_L("CRestrictedAOTestClass::Commit"));
|
|
763 |
TInt error = KErrNone;
|
|
764 |
|
|
765 |
error = iRestrictedAudioOutput->Commit();
|
|
766 |
|
|
767 |
return error;
|
|
768 |
}
|
|
769 |
|
|
770 |
|
|
771 |
// -----------------------------------------------------------------------------
|
|
772 |
// CRestrictedAOTestClass::CreateFactory
|
|
773 |
// Create Factory
|
|
774 |
// -----------------------------------------------------------------------------
|
|
775 |
//
|
|
776 |
TInt CRestrictedAOTestClass::CreateFactory( CStifItemParser& /*aItem */)
|
|
777 |
{
|
|
778 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::CreateFactory")));
|
|
779 |
iLog->Log(_L("CRestrictedAOTestClass::CreateFactory"));
|
|
780 |
TInt error = KErrNone;
|
|
781 |
|
5
|
782 |
error = CConfigurationComponentsFactory::CreateFactoryL(iFactory);
|
|
783 |
|
|
784 |
if (error == KErrNone)
|
|
785 |
TRAP(error, iDevSound = CMMFDevSound::NewL()) ;
|
0
|
786 |
// AddExpectedEvent(EInitializeComplete, KMediumTimeout);
|
|
787 |
|
|
788 |
return error;
|
|
789 |
}
|
|
790 |
|
|
791 |
// -----------------------------------------------------------------------------
|
|
792 |
// CRestrictedAOTestClass::CreateRestrictedAO
|
|
793 |
// Create RestrictedAO
|
|
794 |
// -----------------------------------------------------------------------------
|
|
795 |
//
|
|
796 |
TInt CRestrictedAOTestClass::CreateRestrictedAO( CStifItemParser& /*aItem */)
|
|
797 |
{
|
|
798 |
FTRACE(FPrint(_L("CRestrictedAOTestClass::CreateRestrictedAO")));
|
|
799 |
iLog->Log(_L("CRestrictedAOTestClass::CreateRestrictedAO"));
|
|
800 |
TInt error = KErrNone;
|
|
801 |
|
5
|
802 |
if (iFactory != NULL && iDevSound != NULL)
|
0
|
803 |
{
|
5
|
804 |
error = iFactory->CreateRestrictedAudioOutput(*iDevSound, iRestrictedAudioOutput);
|
0
|
805 |
}
|
|
806 |
else
|
|
807 |
{
|
|
808 |
error = KErrNotSupported;
|
|
809 |
}
|
|
810 |
|
|
811 |
return error;
|
|
812 |
}
|
|
813 |
|
|
814 |
// End of File
|