|
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_rtcp.h" |
|
23 #include "mccteststubs.h" |
|
24 #include "mmccinterface.h" |
|
25 #include "mmcccodecinformation.h" |
|
26 #include "testdefinitions.hrh" |
|
27 |
|
28 #if (defined __WINSCW__) || (defined __WINS__) |
|
29 /** Length of APP packet name in bytes. Refer to RFC3550. */ |
|
30 const TUint KAppNameOctets = 4; |
|
31 #endif |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ================================================= |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CTestRtcp::CTestRtcp |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CTestRtcp::CTestRtcp( CConsoleBase& aConsole, |
|
42 const TMccNetSettings& aNetsettings ) |
|
43 : iConsole( aConsole ), iNetsettings( aNetsettings ) |
|
44 { |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CTestRtcp::ConstructL |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 void CTestRtcp::ConstructL() |
|
53 { |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CTestRtcp::NewL |
|
58 // Static constructor. |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CTestRtcp* CTestRtcp::NewL( CConsoleBase& aConsole, |
|
62 const TMccNetSettings& aNetsettings ) |
|
63 { |
|
64 CTestRtcp* self = new ( ELeave ) CTestRtcp( aConsole, aNetsettings ); |
|
65 CleanupStack::PushL( self ); |
|
66 |
|
67 self->ConstructL(); |
|
68 |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CTestRtcp::~CTestRtcp |
|
75 // Destructor. |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 CTestRtcp::~CTestRtcp() |
|
79 { |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CTestRtcp:: |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CTestRtcp::DoRunRtcpTestsL() |
|
87 { |
|
88 iConsole.Printf( _L("\n** RTCP tests **\n") ); |
|
89 |
|
90 iConsole.Printf( _L("Send RTCP RR test\n") ); |
|
91 RDebug::Print( _L("Mcc_COM_TEST_START: TestSendRTCPReceiverReportL") ); |
|
92 __UHEAP_MARK; |
|
93 // TestSendRTCPReceiverReportL(); |
|
94 __UHEAP_MARKEND; |
|
95 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSendRTCPReceiverReportL") ); |
|
96 |
|
97 iConsole.Printf( _L("Send RTCP SR test\n") ); |
|
98 RDebug::Print( _L("Mcc_COM_TEST_START: TestSendRTCPSenderReportL") ); |
|
99 __UHEAP_MARK; |
|
100 TestSendRTCPSenderReportL(); |
|
101 __UHEAP_MARKEND; |
|
102 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSendRTCPSenderReportL") ); |
|
103 |
|
104 iConsole.Printf( _L("Send RTCP data test\n") ); |
|
105 RDebug::Print( _L("Mcc_COM_TEST_START: TestSendRTCPDataL") ); |
|
106 __UHEAP_MARK; |
|
107 TestSendRTCPDataL(); |
|
108 __UHEAP_MARKEND; |
|
109 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSendRTCPDataL") ); |
|
110 |
|
111 iConsole.Printf( _L("Send RTCP Sdes test\n") ); |
|
112 RDebug::Print( _L("Mcc_COM_TEST_START: TestSetSdesL") ); |
|
113 __UHEAP_MARK; |
|
114 TestSetSdesL(); |
|
115 __UHEAP_MARKEND; |
|
116 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSetSdesL") ); |
|
117 |
|
118 iConsole.Printf( _L("Send RTCP App test\n") ); |
|
119 RDebug::Print( _L("Mcc_COM_TEST_START: TestSendAppL") ); |
|
120 __UHEAP_MARK; |
|
121 TestSendAppL(); |
|
122 __UHEAP_MARKEND; |
|
123 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSendAppL") ); |
|
124 |
|
125 iConsole.Printf( _L("Send RTCP Bye test\n") ); |
|
126 RDebug::Print( _L("Mcc_COM_TEST_START: TestSendByeL") ); |
|
127 __UHEAP_MARK; |
|
128 TestSendByeL(); |
|
129 __UHEAP_MARKEND; |
|
130 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestSendByeL") ); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CTestRtcp::TestSendRTCPReceiverReportL |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CTestRtcp::TestSendRTCPReceiverReportL() |
|
138 { |
|
139 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
140 CleanupStack::PushL( stub ); |
|
141 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
142 CleanupStack::PushL( interface ); |
|
143 |
|
144 // Create session |
|
145 TUint32 session; |
|
146 User::LeaveIfError( interface->CreateSession( session ) ); |
|
147 |
|
148 RPointerArray<CMccCodecInformation> codecArray; |
|
149 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray ); |
|
150 User::LeaveIfError( interface->GetCapabilities( codecArray ) ); |
|
151 if( !codecArray.Count() ) |
|
152 { |
|
153 User::Leave( KErrNotFound ); |
|
154 } |
|
155 codecArray[0]->SetPriority( EMdaPriorityMax ); |
|
156 |
|
157 // Create link |
|
158 TUint32 link; |
|
159 TInt linkType = KMccLinkGeneral; |
|
160 User::LeaveIfError( interface->CreateLink( session, linkType, link, iNetsettings ) ); |
|
161 stub->WaitForEvent( session, link, 0, KMccLinkCreated ); |
|
162 |
|
163 User::LeaveIfError( interface->SetRemoteAddress( session, link, iNetsettings.iRemoteAddress ) ); |
|
164 |
|
165 // Create upstream |
|
166 TUint32 upStream; |
|
167 TUint32 dataSinkId1; |
|
168 TUint32 dataSourceId1; |
|
169 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ); |
|
170 interface->AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ); |
|
171 |
|
172 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioUplink ); |
|
173 User::LeaveIfError( interface->CreateStream( session, link, upStream, |
|
174 KMccAudioUplinkStream, *codecArray[0] ) ); |
|
175 |
|
176 User::LeaveIfError( interface->PrepareStream( session, link, upStream ) ); |
|
177 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
178 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
179 |
|
180 User::LeaveIfError( interface->StartStream( session, link, upStream ) ); |
|
181 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
182 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
183 |
|
184 // Create downstream |
|
185 TUint32 downStream; |
|
186 TUint32 dataSinkId2; |
|
187 TUint32 dataSourceId2; |
|
188 interface->AddDataSink( KUidMmfAudioOutput, KNullDesC8, dataSinkId2 ); |
|
189 interface->AddDataSource( KMccRtpSourceUid, KNullDesC8, dataSourceId2 ); |
|
190 |
|
191 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioDownlink ); |
|
192 User::LeaveIfError( interface->CreateStream( session, link, downStream, |
|
193 KMccAudioDownlinkStream, *codecArray[0] ) ); |
|
194 |
|
195 User::LeaveIfError( interface->PrepareStream( session, link, downStream ) ); |
|
196 stub->WaitForEvent( session, link, downStream, KMccStreamPrepared ); |
|
197 stub->WaitForEvent( session, link, downStream, KMccStreamPrepared ); |
|
198 |
|
199 User::LeaveIfError( interface->StartStream( session, link, downStream ) ); |
|
200 stub->WaitForEvent( session, link, downStream, KMccStreamStarted ); |
|
201 stub->WaitForEvent( session, link, downStream, KMccStreamStarted ); |
|
202 |
|
203 // Wait for a bit so a few packets can be sent |
|
204 iConsole.Printf( _L( "Press any key to send RR\n" ) ); |
|
205 iConsole.Getch(); |
|
206 |
|
207 // Create the RTCP signal |
|
208 TMccRtcpEventData signal; |
|
209 signal.iRtcpPacketType = KRtcpRrPacket; |
|
210 TPckgBuf<TMccRtcpEventData> rtcpPkg( signal ); |
|
211 |
|
212 // Encapsulate the signal in event |
|
213 TMccEvent event; |
|
214 event.iSessionId = session; |
|
215 event.iLinkId = link; |
|
216 event.iStreamId = downStream; |
|
217 event.iEventCategory = KMccEventCategoryRtcp; |
|
218 event.iEventType = KMccRtcpControl; |
|
219 event.iEventData.Append( rtcpPkg ); |
|
220 |
|
221 // Send the report |
|
222 interface->SendMediaSignalL( event ); |
|
223 |
|
224 // Clean up |
|
225 User::LeaveIfError( interface->StopStream( session, link, upStream ) ); |
|
226 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
227 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
228 |
|
229 User::LeaveIfError( interface->StopStream( session, link, downStream ) ); |
|
230 stub->WaitForEvent( session, link, downStream, KMccStreamStopped ); |
|
231 stub->WaitForEvent( session, link, downStream, KMccStreamStopped ); |
|
232 |
|
233 // TBD: REMOVE DATASINK&SOURCE |
|
234 User::LeaveIfError( interface->DeleteStream( session, link, upStream ) ); |
|
235 User::LeaveIfError( interface->DeleteStream( session, link, downStream ) ); |
|
236 |
|
237 User::LeaveIfError( interface->CloseLink( session, link ) ); |
|
238 User::LeaveIfError( interface->CloseSession( session ) ); |
|
239 |
|
240 CleanupStack::Pop(); // Codec array |
|
241 codecArray.ResetAndDestroy(); |
|
242 codecArray.Close(); |
|
243 CleanupStack::PopAndDestroy( interface ); |
|
244 CleanupStack::PopAndDestroy( stub ); |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CTestRtcp::TestSendRTCPSenderReportL |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 void CTestRtcp::TestSendRTCPSenderReportL() |
|
252 { |
|
253 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
254 CleanupStack::PushL( stub ); |
|
255 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
256 CleanupStack::PushL( interface ); |
|
257 |
|
258 // Create session |
|
259 TUint32 session; |
|
260 User::LeaveIfError( interface->CreateSession( session ) ); |
|
261 |
|
262 RPointerArray<CMccCodecInformation> codecArray; |
|
263 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray ); |
|
264 User::LeaveIfError( interface->GetCapabilities( codecArray ) ); |
|
265 if( !codecArray.Count() ) |
|
266 { |
|
267 User::Leave( KErrNotFound ); |
|
268 } |
|
269 codecArray[0]->SetPriority( EMdaPriorityMax ); |
|
270 |
|
271 // Create link |
|
272 TUint32 link; |
|
273 TInt linkType = KMccLinkGeneral; |
|
274 User::LeaveIfError( interface->CreateLink( session, linkType, link, iNetsettings ) ); |
|
275 stub->WaitForEvent( session, link, 0, KMccLinkCreated ); |
|
276 |
|
277 User::LeaveIfError( interface->SetRemoteAddress( session, link, iNetsettings.iRemoteAddress ) ); |
|
278 |
|
279 // Create upstream |
|
280 TUint32 upStream; |
|
281 TUint32 dataSinkId1; |
|
282 TUint32 dataSourceId1; |
|
283 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId1 ); |
|
284 interface->AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId1 ); |
|
285 |
|
286 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioUplink ); |
|
287 User::LeaveIfError( interface->CreateStream( session, link, upStream, |
|
288 KMccAudioUplinkStream, *codecArray[0] ) ); |
|
289 |
|
290 |
|
291 User::LeaveIfError( interface->PrepareStream( session, link, upStream ) ); |
|
292 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
293 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
294 |
|
295 User::LeaveIfError( interface->StartStream( session, link, upStream ) ); |
|
296 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
297 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
298 |
|
299 // Create downstream |
|
300 TUint32 downStream; |
|
301 TUint32 dataSinkId2; |
|
302 TUint32 dataSourceId2; |
|
303 interface->AddDataSink( KUidMmfAudioOutput, KNullDesC8, dataSinkId2 ); |
|
304 interface->AddDataSource( KMccRtpSourceUid, KNullDesC8, dataSourceId2 ); |
|
305 |
|
306 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioDownlink ); |
|
307 User::LeaveIfError( interface->CreateStream( session, link, downStream, |
|
308 KMccAudioDownlinkStream, *codecArray[0] ) ); |
|
309 |
|
310 User::LeaveIfError( interface->PrepareStream( session, link, downStream ) ); |
|
311 stub->WaitForEvent( session, link, downStream, KMccStreamPrepared ); |
|
312 stub->WaitForEvent( session, link, downStream, KMccStreamPrepared ); |
|
313 |
|
314 User::LeaveIfError( interface->StartStream( session, link, downStream ) ); |
|
315 stub->WaitForEvent( session, link, downStream, KMccStreamStarted ); |
|
316 stub->WaitForEvent( session, link, downStream, KMccStreamStarted ); |
|
317 |
|
318 iConsole.Printf( _L( "Press any key to send SR\n" ) ); |
|
319 iConsole.Getch(); |
|
320 |
|
321 // Create the RTCP signal |
|
322 TMccRtcpEventData signal; |
|
323 signal.iRtcpPacketType = KRtcpSrPacket; |
|
324 TPckgBuf<TMccRtcpEventData> rtcpPkg( signal ); |
|
325 |
|
326 // Encapsulate the signal in event |
|
327 TMccEvent event; |
|
328 event.iSessionId = session; |
|
329 //event.iLinkId = upLink; |
|
330 event.iLinkId = link; |
|
331 event.iStreamId = upStream; |
|
332 event.iEventCategory = KMccEventCategoryRtcp; |
|
333 event.iEventType = KMccRtcpControl; |
|
334 event.iEventData.Append( rtcpPkg ); |
|
335 |
|
336 // Send the report |
|
337 interface->SendMediaSignalL( event ); |
|
338 |
|
339 // Clean up |
|
340 User::LeaveIfError( interface->StopStream( session, link, upStream ) ); |
|
341 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
342 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
343 |
|
344 User::LeaveIfError( interface->StopStream( session, link, downStream ) ); |
|
345 stub->WaitForEvent( session, link, downStream, KMccStreamStopped ); |
|
346 stub->WaitForEvent( session, link, downStream, KMccStreamStopped ); |
|
347 |
|
348 // TBD: REMOVE DATASINK&SOURCE |
|
349 User::LeaveIfError( interface->DeleteStream( session, link, upStream ) ); |
|
350 User::LeaveIfError( interface->DeleteStream( session, link, downStream ) ); |
|
351 |
|
352 User::LeaveIfError( interface->CloseLink( session, link ) ); |
|
353 User::LeaveIfError( interface->CloseSession( session ) ); |
|
354 |
|
355 CleanupStack::Pop(); // Codec array |
|
356 codecArray.ResetAndDestroy(); |
|
357 codecArray.Close(); |
|
358 CleanupStack::PopAndDestroy( interface ); |
|
359 CleanupStack::PopAndDestroy( stub ); |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // CTestRtcp::TestSendRTCPDataL |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 void CTestRtcp::TestSendRTCPDataL() |
|
367 { |
|
368 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
369 CleanupStack::PushL( stub ); |
|
370 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
371 CleanupStack::PushL( interface ); |
|
372 |
|
373 // Create session |
|
374 TUint32 session; |
|
375 User::LeaveIfError( interface->CreateSession( session ) ); |
|
376 |
|
377 RPointerArray<CMccCodecInformation> codecArray; |
|
378 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray ); |
|
379 User::LeaveIfError( interface->GetCapabilities( codecArray ) ); |
|
380 if( !codecArray.Count() ) |
|
381 { |
|
382 User::Leave( KErrNotFound ); |
|
383 } |
|
384 codecArray[0]->SetPriority( EMdaPriorityMax ); |
|
385 |
|
386 // Create link |
|
387 TUint32 link; |
|
388 TInt linkType = KMccLinkGeneral; |
|
389 User::LeaveIfError( interface->CreateLink( session, linkType, link, iNetsettings ) ); |
|
390 stub->WaitForEvent( session, link, 0, KMccLinkCreated ); |
|
391 |
|
392 User::LeaveIfError( interface->SetRemoteAddress( session, link, iNetsettings.iRemoteAddress ) ); |
|
393 |
|
394 // Create upstream |
|
395 TUint32 upStream; |
|
396 TUint32 dataSinkId; |
|
397 TUint32 dataSourceId; |
|
398 |
|
399 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId ); |
|
400 interface->AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId ); |
|
401 |
|
402 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioUplink ); |
|
403 User::LeaveIfError( interface->CreateStream( session, link, upStream, |
|
404 KMccAudioUplinkStream, *codecArray[0] ) ); |
|
405 |
|
406 User::LeaveIfError( interface->PrepareStream( session, link, upStream ) ); |
|
407 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
408 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
409 |
|
410 User::LeaveIfError( interface->StartStream( session, link, upStream ) ); |
|
411 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
412 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
413 |
|
414 iConsole.Printf( _L( "Press any key to send data\n" ) ); |
|
415 iConsole.Getch(); |
|
416 |
|
417 TMccRtcpEventData signal; |
|
418 signal.iRtcpPacketType = KRtcpAnyPacket; |
|
419 |
|
420 // Non-RTCP data |
|
421 TBuf8<15> data; |
|
422 data.Format( _L8( "RTCP data test" ) ); |
|
423 signal.iRtcpPacketData = data; |
|
424 |
|
425 TPckgBuf<TMccRtcpEventData> rtcpPkg( signal ); |
|
426 |
|
427 // Encapsulate the signal in event |
|
428 TMccEvent event; |
|
429 event.iSessionId = session; |
|
430 event.iLinkId = link; |
|
431 event.iStreamId = upStream; |
|
432 event.iEventCategory = KMccEventCategoryRtcp; |
|
433 event.iEventType = KMccRtcpControl; |
|
434 event.iEventData.Append( rtcpPkg ); |
|
435 |
|
436 // Send the signal |
|
437 interface->SendMediaSignalL( event ); |
|
438 |
|
439 // Clean up |
|
440 User::LeaveIfError( interface->StopStream( session, link, upStream ) ); |
|
441 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
442 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
443 |
|
444 // TBD: REMOVE DATASINK&SOURCE |
|
445 User::LeaveIfError( interface->DeleteStream( session, link, upStream ) ); |
|
446 User::LeaveIfError( interface->CloseLink( session, link ) ); |
|
447 User::LeaveIfError( interface->CloseSession( session ) ); |
|
448 |
|
449 CleanupStack::Pop(); // Codec array |
|
450 codecArray.ResetAndDestroy(); |
|
451 codecArray.Close(); |
|
452 CleanupStack::PopAndDestroy( interface ); |
|
453 CleanupStack::PopAndDestroy( stub ); |
|
454 } |
|
455 |
|
456 // --------------------------------------------------------------------------- |
|
457 // CTestRtcp::TestSetSdesL |
|
458 // --------------------------------------------------------------------------- |
|
459 // |
|
460 void CTestRtcp::TestSetSdesL() |
|
461 { |
|
462 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
463 CleanupStack::PushL( stub ); |
|
464 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
465 CleanupStack::PushL( interface ); |
|
466 |
|
467 // Create session |
|
468 TUint32 session; |
|
469 User::LeaveIfError( interface->CreateSession( session ) ); |
|
470 |
|
471 RPointerArray<CMccCodecInformation> codecArray; |
|
472 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray ); |
|
473 User::LeaveIfError( interface->GetCapabilities( codecArray ) ); |
|
474 codecArray[0]->SetPriority( EMdaPriorityMax ); |
|
475 |
|
476 // Create link |
|
477 TUint32 link; |
|
478 TInt linkType = KMccLinkGeneral; |
|
479 User::LeaveIfError( interface->CreateLink( session, linkType, link, iNetsettings ) ); |
|
480 stub->WaitForEvent( session, link, 0, KMccLinkCreated ); |
|
481 |
|
482 User::LeaveIfError( interface->SetRemoteAddress( session, link, iNetsettings.iRemoteAddress ) ); |
|
483 |
|
484 // Create upstream |
|
485 TUint32 upStream; |
|
486 TUint32 dataSinkId; |
|
487 TUint32 dataSourceId; |
|
488 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId ); |
|
489 interface->AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId ); |
|
490 |
|
491 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioUplink ); |
|
492 User::LeaveIfError( interface->CreateStream( session, link, upStream, |
|
493 KMccAudioUplinkStream, *codecArray[0] ) ); |
|
494 |
|
495 User::LeaveIfError( interface->PrepareStream( session, link, upStream ) ); |
|
496 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
497 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
498 |
|
499 User::LeaveIfError( interface->StartStream( session, link, upStream ) ); |
|
500 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
501 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
502 |
|
503 iConsole.Printf( _L( "Press any key to send Sdes\n" ) ); |
|
504 iConsole.Getch(); |
|
505 |
|
506 TMccRtcpEventData signal; |
|
507 signal.iRtcpPacketType = KRtcpSdesPacket; |
|
508 |
|
509 TRtpSdesParams sdes; |
|
510 TPtrC8* ptr = &sdes.iCName; |
|
511 |
|
512 TBuf8<10> cname; |
|
513 cname.SetMax(); |
|
514 cname.FillZ(); |
|
515 ptr->Set( cname ); |
|
516 TPckgBuf<TRtpSdesParams> sdesPackage( sdes ); |
|
517 |
|
518 // Finally copy sdes into beginning of the data |
|
519 signal.iRtcpPacketData.Insert( 0, sdesPackage ); |
|
520 TPckgBuf<TMccRtcpEventData> rtcpPkg( signal ); |
|
521 |
|
522 // Encapsulate the signal in event |
|
523 TMccEvent event; |
|
524 event.iSessionId = session; |
|
525 event.iLinkId = link; |
|
526 event.iStreamId = upStream; |
|
527 event.iEventCategory = KMccEventCategoryRtcp; |
|
528 event.iEventType = KMccRtcpControl; |
|
529 event.iEventData.Append( rtcpPkg ); |
|
530 |
|
531 // Send the signal |
|
532 interface->SendMediaSignalL( event ); |
|
533 |
|
534 // Clean up |
|
535 User::LeaveIfError( interface->StopStream( session, link, upStream ) ); |
|
536 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
537 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
538 |
|
539 // TBD: REMOVE DATASINK&SOURCE |
|
540 User::LeaveIfError( interface->DeleteStream( session, link, upStream ) ); |
|
541 User::LeaveIfError( interface->CloseLink( session, link ) ); |
|
542 User::LeaveIfError( interface->CloseSession( session ) ); |
|
543 |
|
544 CleanupStack::Pop(); // Codec array |
|
545 codecArray.ResetAndDestroy(); |
|
546 codecArray.Close(); |
|
547 CleanupStack::PopAndDestroy( interface ); |
|
548 CleanupStack::PopAndDestroy( stub ); |
|
549 } |
|
550 |
|
551 // --------------------------------------------------------------------------- |
|
552 // CTestRtcp::TestSendAppL |
|
553 // --------------------------------------------------------------------------- |
|
554 // |
|
555 void CTestRtcp::TestSendAppL() |
|
556 { |
|
557 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
558 CleanupStack::PushL( stub ); |
|
559 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
560 CleanupStack::PushL( interface ); |
|
561 |
|
562 // Create session |
|
563 TUint32 session; |
|
564 User::LeaveIfError( interface->CreateSession( session ) ); |
|
565 |
|
566 RPointerArray<CMccCodecInformation> codecArray; |
|
567 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray ); |
|
568 User::LeaveIfError( interface->GetCapabilities( codecArray ) ); |
|
569 codecArray[0]->SetPriority( EMdaPriorityMax ); |
|
570 |
|
571 // Create link |
|
572 TUint32 link; |
|
573 TInt linkType = KMccLinkGeneral; |
|
574 User::LeaveIfError( interface->CreateLink( session, linkType, link, iNetsettings ) ); |
|
575 stub->WaitForEvent( session, link, 0, KMccLinkCreated ); |
|
576 |
|
577 User::LeaveIfError( interface->SetRemoteAddress( session, link, iNetsettings.iRemoteAddress ) ); |
|
578 |
|
579 // Create upstream |
|
580 TUint32 upStream; |
|
581 TUint32 dataSinkId; |
|
582 TUint32 dataSourceId; |
|
583 |
|
584 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId ); |
|
585 interface->AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId ); |
|
586 |
|
587 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioUplink ); |
|
588 User::LeaveIfError( interface->CreateStream( session, link, upStream, |
|
589 KMccAudioUplinkStream, *codecArray[0] ) ); |
|
590 |
|
591 User::LeaveIfError( interface->PrepareStream( session, link, upStream ) ); |
|
592 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
593 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
594 |
|
595 User::LeaveIfError( interface->StartStream( session, link, upStream ) ); |
|
596 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
597 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
598 |
|
599 iConsole.Printf( _L( "Press any key to send App\n" ) ); |
|
600 iConsole.Getch(); |
|
601 |
|
602 TMccRtcpEventData signal; |
|
603 signal.iRtcpPacketType = KRtcpAppPacket; |
|
604 |
|
605 // Has to be flagged temporarily away because somehow |
|
606 // signal.iRtcpPacketData.Copy( appPkg ) operation |
|
607 // makes program to close in HW. |
|
608 #if (defined __WINSCW__) || (defined __WINS__) |
|
609 TRtcpApp appPacket; |
|
610 appPacket.iSubType = 200; |
|
611 |
|
612 TBuf8<KAppNameOctets> tempName; |
|
613 for( TUint i=0; i < KAppNameOctets; i++ ) |
|
614 { |
|
615 tempName.Append( appPacket.iName[i] ); |
|
616 } |
|
617 |
|
618 TBuf8<KMaxRtcpAppData> tempData; |
|
619 for( TUint i=0; i < KMaxRtcpAppData; i++ ) |
|
620 { |
|
621 tempData.Append( appPacket.iAppData[i] ); |
|
622 } |
|
623 |
|
624 TPckgBuf<TRtcpApp> appPkg( appPacket ); |
|
625 |
|
626 signal.iRtcpPacketData.Copy( appPkg ); |
|
627 #endif |
|
628 TPckgBuf<TMccRtcpEventData> rtcpPkg( signal ); |
|
629 |
|
630 // Encapsulate the signal in event |
|
631 TMccEvent event; |
|
632 event.iSessionId = session; |
|
633 event.iLinkId = link; |
|
634 event.iStreamId = upStream; |
|
635 event.iEventCategory = KMccEventCategoryRtcp; |
|
636 event.iEventType = KMccRtcpControl; |
|
637 event.iEventData.Append( rtcpPkg ); |
|
638 |
|
639 // Send the signal |
|
640 interface->SendMediaSignalL( event ); |
|
641 |
|
642 // Clean up |
|
643 User::LeaveIfError( interface->StopStream( session, link, upStream ) ); |
|
644 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
645 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
646 |
|
647 // TBD: REMOVE DATASINK&SOURCE |
|
648 User::LeaveIfError( interface->DeleteStream( session, link, upStream ) ); |
|
649 User::LeaveIfError( interface->CloseLink( session, link ) ); |
|
650 User::LeaveIfError( interface->CloseSession( session ) ); |
|
651 |
|
652 CleanupStack::Pop(); // Codec array |
|
653 codecArray.ResetAndDestroy(); |
|
654 codecArray.Close(); |
|
655 CleanupStack::PopAndDestroy( interface ); |
|
656 CleanupStack::PopAndDestroy( stub ); |
|
657 } |
|
658 |
|
659 // --------------------------------------------------------------------------- |
|
660 // CTestRtcp::TestSendByeL |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 void CTestRtcp::TestSendByeL() |
|
664 { |
|
665 CMccInterfaceStub* stub = CMccInterfaceStub::NewL(); |
|
666 CleanupStack::PushL( stub ); |
|
667 CMccInterface* interface = CMccInterface::NewL( *stub ); |
|
668 CleanupStack::PushL( interface ); |
|
669 |
|
670 // Create session |
|
671 TUint32 session; |
|
672 User::LeaveIfError( interface->CreateSession( session ) ); |
|
673 |
|
674 RPointerArray<CMccCodecInformation> codecArray; |
|
675 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray ); |
|
676 User::LeaveIfError( interface->GetCapabilities( codecArray ) ); |
|
677 codecArray[0]->SetPriority( EMdaPriorityMax ); |
|
678 |
|
679 // Create link |
|
680 TUint32 link; |
|
681 TInt linkType = KMccLinkGeneral; |
|
682 User::LeaveIfError( interface->CreateLink( session, linkType, link, iNetsettings ) ); |
|
683 stub->WaitForEvent( session, link, 0, KMccLinkCreated ); |
|
684 |
|
685 User::LeaveIfError( interface->SetRemoteAddress( session, link, iNetsettings.iRemoteAddress ) ); |
|
686 |
|
687 // Create upstream |
|
688 TUint32 upStream; |
|
689 TUint32 dataSinkId; |
|
690 TUint32 dataSourceId; |
|
691 |
|
692 interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId ); |
|
693 interface->AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId ); |
|
694 |
|
695 codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioUplink ); |
|
696 User::LeaveIfError( interface->CreateStream( session, link, upStream, |
|
697 KMccAudioUplinkStream, *codecArray[0] ) ); |
|
698 |
|
699 User::LeaveIfError( interface->PrepareStream( session, link, upStream ) ); |
|
700 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
701 stub->WaitForEvent( session, link, upStream, KMccStreamPrepared ); |
|
702 |
|
703 User::LeaveIfError( interface->StartStream( session, link, upStream ) ); |
|
704 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
705 stub->WaitForEvent( session, link, upStream, KMccStreamStarted ); |
|
706 |
|
707 iConsole.Printf( _L( "Press any key to send Bye\n" ) ); |
|
708 iConsole.Getch(); |
|
709 |
|
710 TMccRtcpEventData signal; |
|
711 signal.iRtcpPacketType = KRtcpByePacket; |
|
712 |
|
713 TBuf8<10> reason; |
|
714 reason.SetMax(); |
|
715 reason.FillZ(); |
|
716 |
|
717 signal.iRtcpPacketData = reason; |
|
718 TPckgBuf<TMccRtcpEventData> rtcpPkg( signal ); |
|
719 |
|
720 // Encapsulate the signal in event |
|
721 TMccEvent event; |
|
722 event.iSessionId = session; |
|
723 event.iLinkId = link; |
|
724 event.iStreamId = upStream; |
|
725 event.iEventCategory = KMccEventCategoryRtcp; |
|
726 event.iEventType = KMccRtcpControl; |
|
727 event.iEventData.Append( rtcpPkg ); |
|
728 |
|
729 // Send the signal |
|
730 interface->SendMediaSignalL( event ); |
|
731 |
|
732 // Clean up |
|
733 User::LeaveIfError( interface->StopStream( session, link, upStream ) ); |
|
734 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
735 stub->WaitForEvent( session, link, upStream, KMccStreamStopped ); |
|
736 |
|
737 // TBD: REMOVE DATASINK&SOURCE |
|
738 User::LeaveIfError( interface->DeleteStream( session, link, upStream ) ); |
|
739 User::LeaveIfError( interface->CloseLink( session, link ) ); |
|
740 User::LeaveIfError( interface->CloseSession( session ) ); |
|
741 |
|
742 CleanupStack::Pop(); // Codec array |
|
743 codecArray.ResetAndDestroy(); |
|
744 codecArray.Close(); |
|
745 CleanupStack::PopAndDestroy( interface ); |
|
746 CleanupStack::PopAndDestroy( stub ); |
|
747 } |