|
1 /* |
|
2 * Copyright (c) 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 #include "test_dtmf.h" |
|
23 #include "mccteststubs.h" |
|
24 #include "mmccinterface.h" |
|
25 #include "mmcccodecinformation.h" |
|
26 #include "testdefinitions.hrh" |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ================================================= |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CTest::CTest |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CTestDtmf::CTestDtmf( CConsoleBase& aConsole, |
|
37 const TMccNetSettings& aNetsettings ) |
|
38 : iConsole( aConsole ), iNetsettings( aNetsettings ) |
|
39 { |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CTestDtmf::ConstructL |
|
44 // Symbian 2nd phase constructor can leave. |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 void CTestDtmf::ConstructL() |
|
48 { |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CTestDtmf::NewL |
|
53 // Static constructor. |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CTestDtmf* CTestDtmf::NewL( CConsoleBase& aConsole, |
|
57 const TMccNetSettings& aNetsettings ) |
|
58 { |
|
59 CTestDtmf* self = new ( ELeave ) CTestDtmf( aConsole, aNetsettings ); |
|
60 CleanupStack::PushL( self ); |
|
61 |
|
62 self->ConstructL(); |
|
63 |
|
64 CleanupStack::Pop( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CTestDtmf::~CTestDtmf |
|
70 // Destructor. |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CTestDtmf::~CTestDtmf() |
|
74 { |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CTestDtmf:: |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CTestDtmf::DoRunDtmfTestsL() |
|
82 { |
|
83 iConsole.Printf( _L("\n** DTMF TESTS **\n") ); |
|
84 iConsole.Printf( _L("Stream creation\n") ); |
|
85 |
|
86 RDebug::Print( _L("Mcc_COM_TEST_START: TestStreamCreationL - INBAND") ); |
|
87 __UHEAP_MARK; |
|
88 TestStreamCreationL( EInbandSignal ); |
|
89 __UHEAP_MARKEND; |
|
90 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestStreamCreationL - INBAND") ); |
|
91 |
|
92 RDebug::Print( _L("Mcc_COM_TEST_START: TestStreamCreationL - OUTBAND") ); |
|
93 __UHEAP_MARK; |
|
94 TestStreamCreationL( EOutbandSignal ); |
|
95 __UHEAP_MARKEND; |
|
96 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestStreamCreationL - OUTBAND") ); |
|
97 |
|
98 iConsole.Printf( _L("Stream ctrl\n") ); |
|
99 RDebug::Print( _L("Mcc_COM_TEST_START: TestStreamControlL - INBAND") ); |
|
100 __UHEAP_MARK; |
|
101 TestStreamControlL( EInbandSignal ); |
|
102 __UHEAP_MARKEND; |
|
103 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestStreamControlL - INBAND") ); |
|
104 |
|
105 RDebug::Print( _L("Mcc_COM_TEST_START: TestStreamControlL - OUTBAND") ); |
|
106 __UHEAP_MARK; |
|
107 TestStreamControlL( EOutbandSignal ); |
|
108 __UHEAP_MARKEND; |
|
109 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestStreamControlL - OUTBAND") ); |
|
110 |
|
111 iConsole.Printf( _L("DTMF digit sending - INBAND\n") ); |
|
112 RDebug::Print( _L("Mcc_COM_TEST_START: TestManualDtmfSendingL - INBAND") ); |
|
113 __UHEAP_MARK; |
|
114 TestManualDtmfSendingL( EInbandSignal ); |
|
115 __UHEAP_MARKEND; |
|
116 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestManualDtmfSendingL - INBAND") ); |
|
117 |
|
118 iConsole.Printf( _L("DTMF digit sending - OUTBAND\n") ); |
|
119 RDebug::Print( _L("Mcc_COM_TEST_START: TestManualDtmfSendingL - OUTBAND") ); |
|
120 __UHEAP_MARK; |
|
121 TestManualDtmfSendingL( EOutbandSignal ); |
|
122 __UHEAP_MARKEND; |
|
123 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestManualDtmfSendingL - OUTBAND") ); |
|
124 |
|
125 iConsole.Printf( _L("DTMF string sending - INBAND\n") ); |
|
126 RDebug::Print( _L("Mcc_COM_TEST_START: TestAutomaticDtmfSendingL - INBAND") ); |
|
127 __UHEAP_MARK; |
|
128 TestAutomaticDtmfSendingL( EInbandSignal ); |
|
129 __UHEAP_MARKEND; |
|
130 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestAutomaticDtmfSendingL - INBAND") ); |
|
131 |
|
132 iConsole.Printf( _L("DTMF STRING sending - OUTBAND\n") ); |
|
133 RDebug::Print( _L("Mcc_COM_TEST_START: TestAutomaticDtmfSendingL - OUTBAND") ); |
|
134 __UHEAP_MARK; |
|
135 TestAutomaticDtmfSendingL( EOutbandSignal ); |
|
136 __UHEAP_MARKEND; |
|
137 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestAutomaticDtmfSendingL - OUTBAND") ); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CTestDtmf::TestStreamCreationL |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CTestDtmf::TestStreamCreationL( TDtmfSignalType aSigType ) |
|
145 { |
|
146 TMccNetSettings tempSettings = iNetsettings; |
|
147 |
|
148 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
149 CleanupStack::PushL( stub ); |
|
150 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
151 CleanupStack::PushL( interface ); |
|
152 |
|
153 TUint32 sessionId; |
|
154 User::LeaveIfError( interface->CreateSession( sessionId ) ); |
|
155 |
|
156 TUint32 linkId; |
|
157 TInt linkType( KMccLinkGeneral ); |
|
158 User::LeaveIfError( interface->CreateLink( sessionId, linkType, linkId, |
|
159 tempSettings ) ); |
|
160 stub->WaitForEvent( sessionId, linkId, 0, KMccLinkCreated ); |
|
161 |
|
162 CMccCodecInformation* cInfo |
|
163 = FetchCodecByMimeSubtypeNameL( *interface, KTxtDtmf ); |
|
164 CleanupStack::PushL( cInfo ); |
|
165 |
|
166 if ( aSigType == EInbandSignal ) |
|
167 { |
|
168 cInfo->SetCodecMode( EDTMFModeInband ); |
|
169 } |
|
170 else |
|
171 { |
|
172 cInfo->SetCodecMode( EDTMFModeEvent ); |
|
173 } |
|
174 |
|
175 TUint32 streamId( 0 ); |
|
176 TUint32 endpointId1( 0 ), endpointId2( 0 ); |
|
177 User::LeaveIfError( |
|
178 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, endpointId1 ) ); |
|
179 User::LeaveIfError( |
|
180 interface->AddDataSource( KMccRtpSourceUid, KNullDesC8, endpointId2 ) ); |
|
181 |
|
182 User::LeaveIfError( interface->CreateStream( sessionId, linkId, streamId, |
|
183 KMccDtmfStream, *cInfo ) ); |
|
184 |
|
185 User::LeaveIfError( interface->DeleteStream( sessionId, linkId, streamId ) ); |
|
186 //interface->RemoveDataSink( endpointId1 ); |
|
187 //interface->RemoveDataSource( endpointId1 ); |
|
188 User::LeaveIfError( interface->CloseLink( sessionId, linkId ) ); |
|
189 User::LeaveIfError( interface->CloseSession( sessionId ) ); |
|
190 |
|
191 CleanupStack::PopAndDestroy( cInfo ); |
|
192 CleanupStack::PopAndDestroy( interface ); |
|
193 CleanupStack::PopAndDestroy( stub ); |
|
194 } |
|
195 |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // CTestDtmf::TestStreamControlL |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 void CTestDtmf::TestStreamControlL( TDtmfSignalType aSigType ) |
|
202 { |
|
203 TMccNetSettings tempSettings = iNetsettings; |
|
204 |
|
205 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
206 CleanupStack::PushL( stub ); |
|
207 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
208 CleanupStack::PushL( interface ); |
|
209 |
|
210 TUint32 sessionId; |
|
211 User::LeaveIfError( interface->CreateSession( sessionId ) ); |
|
212 |
|
213 TUint32 linkId; |
|
214 TInt linkType( KMccLinkGeneral ); |
|
215 User::LeaveIfError( interface->CreateLink( sessionId, linkType, linkId, |
|
216 tempSettings ) ); |
|
217 stub->WaitForEvent( sessionId, linkId, 0, KMccLinkCreated ); |
|
218 |
|
219 CMccCodecInformation* cInfo |
|
220 = FetchCodecByMimeSubtypeNameL( *interface, KTxtDtmf ); |
|
221 CleanupStack::PushL( cInfo ); |
|
222 |
|
223 if ( aSigType == EInbandSignal ) |
|
224 { |
|
225 cInfo->SetCodecMode( EDTMFModeInband ); |
|
226 } |
|
227 else |
|
228 { |
|
229 cInfo->SetCodecMode( EDTMFModeEvent ); |
|
230 } |
|
231 |
|
232 TUint32 streamId( 0 ); |
|
233 TUint32 sinkId( 0 ), sourceId( 0 ); |
|
234 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, sinkId ); |
|
235 interface->AddDataSource( KMccRtpSourceUid, KNullDesC8, sourceId ); |
|
236 |
|
237 User::LeaveIfError( interface->CreateStream( sessionId, linkId, streamId, |
|
238 KMccDtmfStream, *cInfo ) ); |
|
239 |
|
240 // TEST CORRECT CONTROL PATHS |
|
241 User::LeaveIfError ( interface->PrepareStream( sessionId, linkId, streamId ) ); |
|
242 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamPrepared ); |
|
243 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamPrepared ); |
|
244 |
|
245 User::LeaveIfError ( interface->StartStream( sessionId, linkId, streamId ) ); |
|
246 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamStarted ); |
|
247 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamStarted ); |
|
248 |
|
249 User::LeaveIfError ( interface->PauseStream( sessionId, linkId, streamId ) ); |
|
250 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamPaused ); |
|
251 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamPaused ); |
|
252 |
|
253 User::LeaveIfError ( interface->ResumeStream( sessionId, linkId, streamId ) ); |
|
254 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamResumed ); |
|
255 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamResumed ); |
|
256 |
|
257 User::LeaveIfError ( interface->StopStream( sessionId, linkId, streamId ) ); |
|
258 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamStopped ); |
|
259 stub->WaitForEvent( sessionId, linkId, streamId, KMccStreamStopped ); |
|
260 |
|
261 // TBD: TEST INVALID CONTROL PATHS |
|
262 |
|
263 User::LeaveIfError( interface->DeleteStream( sessionId, linkId, streamId ) ); |
|
264 User::LeaveIfError( interface->CloseLink( sessionId, linkId ) ); |
|
265 User::LeaveIfError( interface->CloseSession( sessionId ) ); |
|
266 |
|
267 CleanupStack::PopAndDestroy( cInfo ); |
|
268 CleanupStack::PopAndDestroy( interface ); |
|
269 CleanupStack::PopAndDestroy( stub ); |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // CTestDtmf::TestManualDtmfSendingL |
|
274 // --------------------------------------------------------------------------- |
|
275 // |
|
276 void CTestDtmf::TestManualDtmfSendingL( TDtmfSignalType aSigType ) |
|
277 { |
|
278 TMccNetSettings tempSettings = iNetsettings; |
|
279 |
|
280 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
281 CleanupStack::PushL( stub ); |
|
282 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
283 CleanupStack::PushL( interface ); |
|
284 |
|
285 TUint32 sessionId; |
|
286 User::LeaveIfError( interface->CreateSession( sessionId ) ); |
|
287 |
|
288 TUint32 linkId; |
|
289 TInt linkType( KMccLinkGeneral ); |
|
290 User::LeaveIfError( interface->CreateLink( sessionId, |
|
291 linkType, linkId, tempSettings ) ); |
|
292 |
|
293 CMccCodecInformation* cInfo |
|
294 = FetchCodecByMimeSubtypeNameL( *interface, KAMRSdpName ); |
|
295 CleanupStack::PushL( cInfo ); |
|
296 |
|
297 CMccCodecInformation* cInfo2 |
|
298 = FetchCodecByMimeSubtypeNameL( *interface, KTelephoneEvent ); |
|
299 CleanupStack::PushL( cInfo2 ); |
|
300 |
|
301 if ( aSigType == EInbandSignal ) |
|
302 { |
|
303 cInfo2->SetCodecMode( EDTMFModeInband ); |
|
304 } |
|
305 else |
|
306 { |
|
307 cInfo2->SetCodecMode( EDTMFModeEvent ); |
|
308 } |
|
309 |
|
310 TUint32 speakerSinkId( 0 ); |
|
311 TUint32 rtpSourceId( 0 ); |
|
312 TUint32 dlStreamId( 0 ); |
|
313 User::LeaveIfError( |
|
314 interface->AddDataSink( KUidMmfAudioOutput, KNullDesC8, speakerSinkId ) ); |
|
315 User::LeaveIfError( |
|
316 interface->AddDataSource( KMccRtpSourceUid, KNullDesC8, rtpSourceId ) ); |
|
317 User::LeaveIfError( interface->CreateStream( sessionId, linkId, dlStreamId, |
|
318 KMccAudioDownlinkStream, *cInfo ) ); |
|
319 |
|
320 TUint32 rtpSinkId( 0 ); |
|
321 TUint32 micSourceId( 0 ); |
|
322 TUint32 ulStreamId( 0 ); |
|
323 User::LeaveIfError( |
|
324 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, rtpSinkId ) ); |
|
325 User::LeaveIfError( |
|
326 interface->AddDataSource( KUidMmfAudioInput, KNullDesC8, micSourceId ) ); |
|
327 User::LeaveIfError( interface->CreateStream( sessionId, linkId, ulStreamId, |
|
328 KMccAudioUplinkStream, *cInfo ) ); |
|
329 |
|
330 TUint32 dtmfStreamId( 0 ); |
|
331 User::LeaveIfError( |
|
332 interface->Reuse( sessionId, linkId, dlStreamId, rtpSourceId ) ); |
|
333 User::LeaveIfError( |
|
334 interface->Reuse( sessionId, linkId, ulStreamId, rtpSinkId ) ); |
|
335 User::LeaveIfError( interface->CreateStream( sessionId, linkId, |
|
336 dtmfStreamId, KMccDtmfStream, *cInfo2 ) ); |
|
337 |
|
338 User::LeaveIfError( interface->SetRemoteAddress( sessionId, linkId, |
|
339 iNetsettings.iRemoteAddress ) ); |
|
340 |
|
341 User::LeaveIfError ( interface->PrepareStream( sessionId, linkId, dlStreamId ) ); |
|
342 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamPrepared ); |
|
343 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamPrepared ); |
|
344 |
|
345 User::LeaveIfError ( interface->PrepareStream( sessionId, linkId, ulStreamId ) ); |
|
346 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamPrepared ); |
|
347 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamPrepared ); |
|
348 |
|
349 User::LeaveIfError ( interface->PrepareStream( sessionId, linkId, dtmfStreamId ) ); |
|
350 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamPrepared ); |
|
351 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamPrepared ); |
|
352 |
|
353 /* |
|
354 User::LeaveIfError ( interface->StartStream( sessionId, linkId, dlStreamId ) ); |
|
355 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStarted ); |
|
356 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStarted ); |
|
357 User::LeaveIfError ( interface->StartStream( sessionId, linkId, ulStreamId ) ); |
|
358 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStarted ); |
|
359 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStarted ); |
|
360 */ |
|
361 User::LeaveIfError ( interface->StartStream( sessionId, linkId, dtmfStreamId ) ); |
|
362 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamStarted ); |
|
363 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamStarted ); |
|
364 |
|
365 TMccDtmfEventData dtmfSignal; |
|
366 dtmfSignal.iDtmfEventType = KMccDtmfSigStartTone; |
|
367 _LIT8( KDtmfDigit, "0" ); |
|
368 dtmfSignal.iDtmfString.Copy( KDtmfDigit ); |
|
369 TMccDtmfEventDataPackage signalPkg1( dtmfSignal ); |
|
370 |
|
371 TMccEvent event; |
|
372 event.iSessionId = sessionId; |
|
373 event.iLinkId = linkId; |
|
374 event.iStreamId = dtmfStreamId; |
|
375 event.iEventCategory = KMccEventCategoryDtmf; |
|
376 event.iEventType = KMccDtmfControl; |
|
377 event.iEventData.Copy( signalPkg1 ); |
|
378 |
|
379 interface->SendMediaSignalL( event ); |
|
380 stub->WaitForEvent( |
|
381 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfManualStart ); |
|
382 |
|
383 if ( EOutbandSignal == aSigType ) |
|
384 { |
|
385 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccActivityEvent ); |
|
386 } |
|
387 |
|
388 iConsole.Printf( _L("Press a key to stop digit send\n") ); |
|
389 iConsole.Getch(); |
|
390 |
|
391 dtmfSignal.iDtmfEventType = KMccDtmfSigStopTone; |
|
392 signalPkg1 = dtmfSignal; |
|
393 event.iEventData.Copy( signalPkg1 ); |
|
394 interface->SendMediaSignalL( event ); |
|
395 stub->WaitForEvent( |
|
396 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfManualStop ); |
|
397 |
|
398 iConsole.Printf( _L("Press a key to delete streams\n") ); |
|
399 iConsole.Getch(); |
|
400 |
|
401 User::LeaveIfError( interface->DeleteStream( sessionId, linkId, dlStreamId ) ); |
|
402 User::LeaveIfError( interface->DeleteStream( sessionId, linkId, ulStreamId ) ); |
|
403 User::LeaveIfError( interface->DeleteStream( sessionId, linkId, dtmfStreamId ) ); |
|
404 User::LeaveIfError( interface->CloseLink( sessionId, linkId ) ); |
|
405 User::LeaveIfError( interface->CloseSession( sessionId ) ); |
|
406 CleanupStack::PopAndDestroy( cInfo2 ); |
|
407 CleanupStack::PopAndDestroy( cInfo ); |
|
408 CleanupStack::PopAndDestroy( interface ); |
|
409 CleanupStack::PopAndDestroy( stub ); |
|
410 } |
|
411 |
|
412 // --------------------------------------------------------------------------- |
|
413 // CTestDtmf::TestAutomaticDtmfSendingL |
|
414 // --------------------------------------------------------------------------- |
|
415 // |
|
416 void CTestDtmf::TestAutomaticDtmfSendingL( TDtmfSignalType aSigType ) |
|
417 { |
|
418 TMccNetSettings tempSettings = iNetsettings; |
|
419 |
|
420 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
421 CleanupStack::PushL( stub ); |
|
422 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
423 CleanupStack::PushL( interface ); |
|
424 |
|
425 TUint32 sessionId; |
|
426 User::LeaveIfError( interface->CreateSession( sessionId ) ); |
|
427 |
|
428 TUint32 linkId; |
|
429 TInt linkType( KMccLinkGeneral ); |
|
430 User::LeaveIfError( interface->CreateLink( sessionId, |
|
431 linkType, linkId, tempSettings ) ); |
|
432 |
|
433 |
|
434 CMccCodecInformation* cInfo = FetchCodecByMimeSubtypeNameL( *interface, |
|
435 KAMRSdpName ); |
|
436 CleanupStack::PushL( cInfo ); |
|
437 |
|
438 CMccCodecInformation* cInfo2 = FetchCodecByMimeSubtypeNameL( *interface, |
|
439 KTelephoneEvent ); |
|
440 CleanupStack::PushL( cInfo2 ); |
|
441 |
|
442 if ( aSigType == EInbandSignal ) |
|
443 { |
|
444 cInfo2->SetCodecMode( EDTMFModeInband ); |
|
445 } |
|
446 else |
|
447 { |
|
448 cInfo2->SetCodecMode( EDTMFModeEvent ); |
|
449 } |
|
450 |
|
451 TUint32 speakerSinkId( 0 ); |
|
452 TUint32 rtpSourceId( 0 ); |
|
453 |
|
454 TUint32 dlStreamId( 0 ); |
|
455 User::LeaveIfError( |
|
456 interface->AddDataSink( KUidMmfAudioOutput, KNullDesC8, speakerSinkId ) ); |
|
457 User::LeaveIfError( |
|
458 interface->AddDataSource( KMccRtpSourceUid, KNullDesC8, rtpSourceId ) ); |
|
459 User::LeaveIfError( interface->CreateStream( sessionId, linkId, dlStreamId, |
|
460 KMccAudioDownlinkStream, *cInfo ) ); |
|
461 |
|
462 TUint32 rtpSinkId( 0 ); |
|
463 TUint32 micSourceId( 0 ); |
|
464 TUint32 ulStreamId( 0 ); |
|
465 User::LeaveIfError( |
|
466 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, rtpSinkId ) ); |
|
467 User::LeaveIfError( |
|
468 interface->AddDataSource( KUidMmfAudioInput, KNullDesC8, micSourceId ) ); |
|
469 User::LeaveIfError( interface->CreateStream( sessionId, linkId, ulStreamId, |
|
470 KMccAudioUplinkStream, *cInfo ) ); |
|
471 |
|
472 TUint32 dtmfStreamId( 0 ); |
|
473 User::LeaveIfError( |
|
474 interface->Reuse( sessionId, linkId, dlStreamId, rtpSourceId ) ); |
|
475 User::LeaveIfError( |
|
476 interface->Reuse( sessionId, linkId, ulStreamId, rtpSinkId ) ); |
|
477 User::LeaveIfError( interface->CreateStream( sessionId, linkId, |
|
478 dtmfStreamId, KMccDtmfStream, *cInfo2 ) ); |
|
479 |
|
480 |
|
481 User::LeaveIfError( interface->SetRemoteAddress( sessionId, linkId, |
|
482 iNetsettings.iRemoteAddress ) ); |
|
483 |
|
484 |
|
485 User::LeaveIfError ( interface->PrepareStream( sessionId, linkId, dlStreamId ) ); |
|
486 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamPrepared ); |
|
487 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamPrepared ); |
|
488 User::LeaveIfError ( interface->PrepareStream( sessionId, linkId, ulStreamId ) ); |
|
489 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamPrepared ); |
|
490 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamPrepared ); |
|
491 User::LeaveIfError ( interface->PrepareStream( sessionId, linkId, dtmfStreamId ) ); |
|
492 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamPrepared ); |
|
493 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamPrepared ); |
|
494 |
|
495 /* |
|
496 User::LeaveIfError ( interface->StartStream( sessionId, linkId, dlStreamId ) ); |
|
497 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStarted ); |
|
498 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStarted ); |
|
499 User::LeaveIfError ( interface->StartStream( sessionId, linkId, ulStreamId ) ); |
|
500 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStarted ); |
|
501 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStarted ); |
|
502 */ |
|
503 User::LeaveIfError ( interface->StartStream( sessionId, linkId, dtmfStreamId ) ); |
|
504 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamStarted ); |
|
505 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamStarted ); |
|
506 |
|
507 TMccDtmfEventData dtmfSignal; |
|
508 dtmfSignal.iDtmfEventType = KMccDtmfSigSendString; |
|
509 dtmfSignal.iDtmfString.Copy( KTxtTestDtmfString1() ); |
|
510 dtmfSignal.iContinue = ETrue; |
|
511 TMccDtmfEventDataPackage signalPkg1( dtmfSignal ); |
|
512 |
|
513 // BASIC SENDING TEST WITH NORMAL DIGITS |
|
514 // Encapsulate the signal in event |
|
515 TMccEvent event; |
|
516 event.iSessionId = sessionId; |
|
517 event.iLinkId = linkId; |
|
518 event.iStreamId = dtmfStreamId; |
|
519 event.iEventCategory = KMccEventCategoryDtmf; |
|
520 event.iEventType = KMccDtmfControl; |
|
521 event.iEventData.Copy( signalPkg1 ); |
|
522 |
|
523 interface->SendMediaSignalL( event ); |
|
524 if ( EOutbandSignal == aSigType ) |
|
525 { |
|
526 // Note: In loopback test activity event comes first due to delayed |
|
527 // control event sending. |
|
528 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccActivityEvent ); |
|
529 } |
|
530 |
|
531 for ( TInt i = 0; i < KTxtTestDtmfString1().Length(); i++ ) |
|
532 { |
|
533 stub->WaitForEvent( |
|
534 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSequenceStart ); |
|
535 stub->WaitForEvent( |
|
536 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSequenceStop ); |
|
537 } |
|
538 |
|
539 stub->WaitForEvent( |
|
540 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSendingComplete ); |
|
541 |
|
542 iConsole.Printf( _L("Media signal sent 1, press to continue\n") ); |
|
543 iConsole.Getch(); |
|
544 |
|
545 // PAUSE CHARACTER HANDLING TEST |
|
546 dtmfSignal.iDtmfString.Copy( KTxtTestDtmfStringWithPauseChars() ); |
|
547 TMccDtmfEventDataPackage signalPkg2( dtmfSignal ); |
|
548 event.iEventData.Copy( signalPkg2 ); |
|
549 interface->SendMediaSignalL( event ); |
|
550 for ( TInt i = 0; i < 3; i++ ) |
|
551 { |
|
552 stub->WaitForEvent( |
|
553 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSequenceStart ); |
|
554 stub->WaitForEvent( |
|
555 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSequenceStop ); |
|
556 } |
|
557 |
|
558 stub->WaitForEvent( |
|
559 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSendingComplete ); |
|
560 |
|
561 iConsole.Printf( _L("Media signal sent 2, press to continue\n") ); |
|
562 iConsole.Getch(); |
|
563 |
|
564 // STOP CHARACTER HANDLING TEST |
|
565 _LIT( KTxtTestDtmfStringWithStopChars, "w12" ); |
|
566 dtmfSignal.iDtmfString.Copy( KTxtTestDtmfStringWithStopChars() ); |
|
567 TMccDtmfEventDataPackage signalPkg3( dtmfSignal ); |
|
568 event.iEventData.Copy( signalPkg3 ); |
|
569 interface->SendMediaSignalL( event ); |
|
570 |
|
571 stub->WaitForEvent( |
|
572 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfStopInDtmfString ); |
|
573 |
|
574 dtmfSignal.iDtmfEventType = KMccDtmfSigContinueSending; |
|
575 dtmfSignal.iContinue = ETrue; |
|
576 signalPkg3 = dtmfSignal; |
|
577 event.iEventData.Copy( signalPkg3 ); |
|
578 interface->SendMediaSignalL( event ); |
|
579 for ( TInt i = 0; i < 2; i++ ) |
|
580 { |
|
581 stub->WaitForEvent( |
|
582 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSequenceStart ); |
|
583 stub->WaitForEvent( |
|
584 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSequenceStop ); |
|
585 } |
|
586 |
|
587 stub->WaitForEvent( |
|
588 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSendingComplete ); |
|
589 iConsole.Printf( _L("Media signal sent 3, press to continue\n") ); |
|
590 iConsole.Getch(); |
|
591 |
|
592 // CANCEL DTMF STRING SENDING -TEST |
|
593 dtmfSignal.iDtmfString.Copy( KTxtTestDtmfString1() ); |
|
594 dtmfSignal.iDtmfEventType = KMccDtmfSigSendString; |
|
595 |
|
596 TMccDtmfEventDataPackage signalPkg4( dtmfSignal ); |
|
597 event.iEventData.Copy( signalPkg4 ); |
|
598 interface->SendMediaSignalL( event ); |
|
599 stub->WaitForEvent( |
|
600 sessionId, linkId, dtmfStreamId, KMccDtmfControl, KMccDtmfSequenceStart ); |
|
601 |
|
602 dtmfSignal.iDtmfEventType = KMccDtmfSigCancelSending; |
|
603 signalPkg4 = dtmfSignal; |
|
604 event.iEventData.Copy( signalPkg4 ); |
|
605 interface->SendMediaSignalL( event ); |
|
606 |
|
607 iConsole.Printf( _L("Media signal sent 4, press to continue\n") ); |
|
608 iConsole.Getch(); |
|
609 |
|
610 // TBD: which event should be sent when string sending is cancelled? |
|
611 User::LeaveIfError ( interface->StopStream( sessionId, linkId, dlStreamId ) ); |
|
612 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStopped ); |
|
613 stub->WaitForEvent( sessionId, linkId, dlStreamId, KMccStreamStopped ); |
|
614 |
|
615 User::LeaveIfError ( interface->StopStream( sessionId, linkId, ulStreamId ) ); |
|
616 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStopped ); |
|
617 stub->WaitForEvent( sessionId, linkId, ulStreamId, KMccStreamStopped ); |
|
618 |
|
619 User::LeaveIfError ( interface->StopStream( sessionId, linkId, dtmfStreamId ) ); |
|
620 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamStopped ); |
|
621 stub->WaitForEvent( sessionId, linkId, dtmfStreamId, KMccStreamStopped ); |
|
622 |
|
623 User::LeaveIfError( interface->DeleteStream( sessionId, linkId, dlStreamId ) ); |
|
624 User::LeaveIfError( interface->DeleteStream( sessionId, linkId, ulStreamId ) ); |
|
625 User::LeaveIfError( interface->DeleteStream( sessionId, linkId, dtmfStreamId ) ); |
|
626 User::LeaveIfError( interface->CloseLink( sessionId, linkId ) ); |
|
627 User::LeaveIfError( interface->CloseSession( sessionId ) ); |
|
628 CleanupStack::PopAndDestroy( cInfo2 ); |
|
629 CleanupStack::PopAndDestroy( cInfo ); |
|
630 CleanupStack::PopAndDestroy( interface ); |
|
631 CleanupStack::PopAndDestroy( stub ); |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------------------------- |
|
635 // CTestDtmf::FetchCodecByMimeSubtypeNameL |
|
636 // --------------------------------------------------------------------------- |
|
637 // |
|
638 CMccCodecInformation* CTestDtmf::FetchCodecByMimeSubtypeNameL( |
|
639 const CMccInterface& aInterface, const TDesC8& aName ) const |
|
640 { |
|
641 RPointerArray<CMccCodecInformation> codecArray; |
|
642 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray ); |
|
643 User::LeaveIfError( aInterface.GetCapabilities( codecArray ) ); |
|
644 |
|
645 CMccCodecInformation* tmp = NULL; |
|
646 TInt ind( codecArray.Count() ); |
|
647 |
|
648 while ( ( ind-- ) && ( NULL == tmp ) ) |
|
649 { |
|
650 if ( codecArray[ind]->SdpName().Compare( aName ) == 0 ) |
|
651 { |
|
652 tmp = codecArray[ind]->CloneDetailedL(); |
|
653 } |
|
654 } |
|
655 |
|
656 User::LeaveIfNull( tmp ); |
|
657 CleanupStack::PopAndDestroy( &codecArray ); |
|
658 return tmp; |
|
659 } |