|
1 /* |
|
2 * Copyright (c) 2009 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 // Method : |
|
21 // Purpose : Working as a stub for CMccInterface instantation tests |
|
22 // Parameters : |
|
23 // Return Value: |
|
24 //******************************************************************************* |
|
25 #include <e32base.h> |
|
26 #include <e32debug.h> |
|
27 #include "mccteststubs.h" |
|
28 #include "mmccnetworksettings.h" |
|
29 |
|
30 CMccInterfaceStub* CMccInterfaceStub::NewL() |
|
31 { |
|
32 CMccInterfaceStub* self = new (ELeave) CMccInterfaceStub(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 |
|
37 CMccInterfaceStub::CMccInterfaceStub() |
|
38 { |
|
39 |
|
40 } |
|
41 |
|
42 CMccInterfaceStub::~CMccInterfaceStub() |
|
43 { |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CMccInterfaceStub:: |
|
48 // |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void CMccInterfaceStub::MccEventReceived( const TMccEvent& aEvent ) |
|
52 { |
|
53 RDebug::Print( _L("CMccInterfaceStub::MccEventReceived") ); |
|
54 RDebug::Print( _L("SESSID: %d, LINKID: %d, STREAMID: %d, ENDPOINTID: %d"), |
|
55 aEvent.iSessionId, aEvent.iLinkId, aEvent.iStreamId, aEvent.iEndpointId ); |
|
56 RDebug::Print( _L("CATEGORY: %d, EVENTTYPE: %d, ERRCODE: %d"), |
|
57 aEvent.iEventCategory, aEvent.iEventType, aEvent.iErrorCode ); |
|
58 |
|
59 HandleEventReceival( aEvent ); |
|
60 |
|
61 if ( KMccEventCategoryDtmf == aEvent.iEventCategory |
|
62 && KMccDtmfControl == aEvent.iEventType ) |
|
63 { |
|
64 const TMccDtmfEventData& dtmfEvent = |
|
65 (*reinterpret_cast<const TMccDtmfEventDataPackage*>( |
|
66 &aEvent.iEventData ))(); |
|
67 |
|
68 switch ( dtmfEvent.iDtmfEventType ) |
|
69 { |
|
70 case KMccDtmfManualStart: |
|
71 RDebug::Print( _L("EMccDtmfManualStart") ); |
|
72 break; |
|
73 case KMccDtmfManualStop: |
|
74 RDebug::Print( _L("EMccDtmfManualStop") ); |
|
75 break; |
|
76 case KMccDtmfManualAbort: |
|
77 RDebug::Print( _L("EMccDtmfManualAbort") ); |
|
78 break; |
|
79 case KMccDtmfSequenceStart: |
|
80 RDebug::Print( _L("EMccDtmfSequenceStart") ); |
|
81 break; |
|
82 case KMccDtmfSequenceStop: |
|
83 RDebug::Print( _L("EMccDtmfSequenceStop") ); |
|
84 break; |
|
85 case KMccDtmfSequenceAbort: |
|
86 RDebug::Print( _L("EMccDtmfSequenceAbort") ); |
|
87 break; |
|
88 case KMccDtmfStopInDtmfString: |
|
89 RDebug::Print( _L("EMccDtmfStopInDtmfString") ); |
|
90 break; |
|
91 case KMccDtmfSendingComplete: |
|
92 RDebug::Print( _L("KMccDtmfSendingComplete") ); |
|
93 break; |
|
94 default: |
|
95 break; |
|
96 } |
|
97 } |
|
98 |
|
99 if ( KMccEventCategoryRtp == aEvent.iEventCategory |
|
100 && KMccMediaQualityStatus == aEvent.iEventType ) |
|
101 { |
|
102 RDebug::Print( _L("CMccInterfaceStub::MccEventReceived JITTER STATUS RECV") ); |
|
103 |
|
104 const TMccRtpEventData& rtpEvent = |
|
105 (*reinterpret_cast<const TMccRtpEventDataPackage*>( |
|
106 &aEvent.iEventData ))(); |
|
107 |
|
108 RDebug::Print( _L("jitter estimate: %u, packets received: %u, prev trans time: %u, triggered jitter level: %u"), |
|
109 rtpEvent.iJitterEstimate, rtpEvent.iPacketsReceived, rtpEvent.iPrevTransTime, rtpEvent.iTriggeredJitterLevel ); |
|
110 } |
|
111 |
|
112 if ( KMccLinkCreated == aEvent.iEventType ) |
|
113 { |
|
114 RDebug::Print( _L("KMccLinkCreated Event arrived succesfully!") ); |
|
115 |
|
116 TMccNetSettingsPackage package; |
|
117 package.Copy( aEvent.iEventData ); |
|
118 TBuf<50> localAddr; |
|
119 TBuf<50> localPublicAddr; |
|
120 TMccNetSettings netSettings = package(); |
|
121 netSettings.iLocalAddress.Output( localAddr ); |
|
122 netSettings.iLocalPublicAddress.Output( localPublicAddr ); |
|
123 |
|
124 RDebug::Print( _L("Local ADDR: %S, PORT: %d, Public ADDR: %S, PORT: %d,"), |
|
125 &localAddr, netSettings.iLocalAddress.Port(), |
|
126 &localPublicAddr, netSettings.iLocalPublicAddress.Port() ); |
|
127 RDebug::Print( _L("Local RTCP PORT: %d, Public RTCP PORT: %d"), |
|
128 netSettings.iLocalRtcpPort, netSettings.iLocalPublicRtcpPort ); |
|
129 } |
|
130 } |
|
131 |
|
132 void CMccInterfaceStub::MccMediaStarted( TUint32 aSessionId, |
|
133 TUint32 aLinkId, |
|
134 TUint32 aStreamId, |
|
135 TUint32 aSinkSourceId ) |
|
136 { |
|
137 RDebug::Print( _L("CMccInterfaceStub::MccMediaStarted") ); |
|
138 RDebug::Print( _L("SESSID: %u, LINKID: %u, STREAMID: %u, SINKSOURCEID: %u"), |
|
139 aSessionId, aLinkId, aStreamId, aSinkSourceId ); |
|
140 |
|
141 TMccEvent event = TMccEvent( aSessionId, aLinkId, aStreamId, aSinkSourceId, |
|
142 KMccEventCategoryStream, KMccStreamStarted, KErrNone, KNullDesC8 ); |
|
143 |
|
144 HandleEventReceival( event ); |
|
145 } |
|
146 |
|
147 void CMccInterfaceStub::MccMediaStopped( TUint32 aSessionId, |
|
148 TUint32 aLinkId, |
|
149 TUint32 aStreamId, |
|
150 TUint32 aSinkSourceId ) |
|
151 { |
|
152 RDebug::Print( _L("CMccInterfaceStub::MccMediaStopped") ); |
|
153 RDebug::Print( _L("SESSID: %u, LINKID: %u, STREAMID: %u, SINKSOURCEID: %u"), |
|
154 aSessionId, aLinkId, aStreamId, aSinkSourceId ); |
|
155 |
|
156 TMccEvent event = TMccEvent( aSessionId, aLinkId, aStreamId, aSinkSourceId, |
|
157 KMccEventCategoryStream, KMccStreamStopped, KErrNone, KNullDesC8 ); |
|
158 |
|
159 HandleEventReceival( event ); |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CMccInterfaceStub:: |
|
164 // |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void CMccInterfaceStub::MccMediaPaused( TUint32 aSessionId, |
|
168 TUint32 aLinkId, |
|
169 TUint32 aStreamId, |
|
170 TUint32 aSinkSourceId ) |
|
171 { |
|
172 RDebug::Print( _L("CMccInterfaceStub::MccMediaPaused") ); |
|
173 RDebug::Print( _L("SESSID: %u, LINKID: %u, STREAMID: %u, SINKSOURCEID: %u"), |
|
174 aSessionId, aLinkId, aStreamId, aSinkSourceId ); |
|
175 |
|
176 TMccEvent event = TMccEvent( aSessionId, aLinkId, aStreamId, aSinkSourceId, |
|
177 KMccEventCategoryStream, KMccStreamPaused, KErrNone, KNullDesC8 ); |
|
178 |
|
179 HandleEventReceival( event ); |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // CMccInterfaceStub:: |
|
184 // |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 void CMccInterfaceStub::MccMediaResumed( TUint32 aSessionId, |
|
188 TUint32 aLinkId, |
|
189 TUint32 aStreamId, |
|
190 TUint32 aSinkSourceId ) |
|
191 { |
|
192 RDebug::Print( _L("CMccInterfaceStub::MccMediaResumed") ); |
|
193 RDebug::Print( _L("SESSID: %u, LINKID: %u, STREAMID: %u, SINKSOURCEID: %u"), |
|
194 aSessionId, aLinkId, aStreamId, aSinkSourceId ); |
|
195 |
|
196 TMccEvent event = TMccEvent( aSessionId, aLinkId, aStreamId, aSinkSourceId, |
|
197 KMccEventCategoryStream, KMccStreamResumed, KErrNone, KNullDesC8 ); |
|
198 |
|
199 HandleEventReceival( event ); |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // CMccInterfaceStub:: |
|
204 // |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 void CMccInterfaceStub::MccMediaPrepared( TUint32 aSessionId, |
|
208 TUint32 aLinkId, |
|
209 TUint32 aStreamId, |
|
210 TUint32 aSinkSourceId ) |
|
211 { |
|
212 RDebug::Print( _L("CMccInterfaceStub::MccMediaPrepared") ); |
|
213 RDebug::Print( _L("SESSID: %u, LINKID: %u, STREAMID: %u, SINKSOURCEID: %u"), |
|
214 aSessionId, aLinkId, aStreamId, aSinkSourceId ); |
|
215 |
|
216 TMccEvent event = TMccEvent( aSessionId, aLinkId, aStreamId, aSinkSourceId, |
|
217 KMccEventCategoryStream, KMccStreamPrepared, KErrNone, KNullDesC8 ); |
|
218 |
|
219 HandleEventReceival( event ); |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // CMccInterfaceStub:: |
|
224 // |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CMccInterfaceStub::MccMediaInactive( TUint32 aSessionId, |
|
228 TUint32 aLinkId, |
|
229 TUint32 aStreamId, |
|
230 TUint32 aSinkSourceId ) |
|
231 { |
|
232 RDebug::Print( _L("CMccInterfaceStub::MccMediaInactive" ) ); |
|
233 RDebug::Print( _L("SESSID: %u, LINKID: %u, STREAMID: %u, SINKSOURCEID: %u"), |
|
234 aSessionId, aLinkId, aStreamId, aSinkSourceId ); |
|
235 |
|
236 TMccEvent event = TMccEvent( aSessionId, aLinkId, aStreamId, aSinkSourceId, |
|
237 KMccEventCategoryRtp, KMccInactivityEvent, KErrNone, KNullDesC8 ); |
|
238 |
|
239 HandleEventReceival( event ); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CMccInterfaceStub:: |
|
244 // |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void CMccInterfaceStub::MccMediaActive( TUint32 aSessionId, |
|
248 TUint32 aLinkId, |
|
249 TUint32 aStreamId, |
|
250 TUint32 aSinkSourceId ) |
|
251 { |
|
252 RDebug::Print( _L("CMccInterfaceStub::MccMediaActive") ); |
|
253 RDebug::Print( _L("SESSID: %u, LINKID: %u, STREAMID: %u, SINKSOURCEID: %u"), |
|
254 aSessionId, aLinkId, aStreamId, aSinkSourceId ); |
|
255 |
|
256 TMccEvent event = TMccEvent( aSessionId, aLinkId, aStreamId, aSinkSourceId, |
|
257 KMccEventCategoryRtp, KMccActivityEvent, KErrNone, KNullDesC8 ); |
|
258 |
|
259 HandleEventReceival( event ); |
|
260 } |
|
261 |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // CMccInterfaceStub:: |
|
265 // |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 void CMccInterfaceStub::MccCtrlError( TInt aError, |
|
269 TUint32 aSessionId, |
|
270 TUint32 aLinkId, |
|
271 TUint32 aStreamId, |
|
272 TUint32 aSinkSourceId ) |
|
273 { |
|
274 RDebug::Print( _L("CMccInterfaceStub::MccCtrlError, ERR: %d"), aError ); |
|
275 RDebug::Print( _L("SESSID: %u, LINKID: %u, STREAMID: %u, SINKSOURCEID: %u"), |
|
276 aSessionId, aLinkId, aStreamId, aSinkSourceId ); |
|
277 |
|
278 TMccEvent event = TMccEvent( aSessionId, aLinkId, aStreamId, aSinkSourceId, |
|
279 KMccEventCategoryStream, KMccStreamError, aError, KNullDesC8 ); |
|
280 |
|
281 HandleEventReceival( event ); |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // CMccInterfaceStub:: |
|
286 // |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 void CMccInterfaceStub::UnknownMediaReceived( TUint32 aSessionId, |
|
290 TUint32 /*aLinkId*/, |
|
291 TUint32 aStreamId, |
|
292 TUint32 /*aSinkSourceId*/, |
|
293 TUint8 aPayloadType ) |
|
294 { |
|
295 RDebug::Print( _L("CMccInterfaceStub::UnknownMediaReceived") ); |
|
296 RDebug::Print( _L("SESSID: %u, STREAMID: %u, PT: %u"), |
|
297 aSessionId, aStreamId, aPayloadType ); |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // CMccInterfaceStub::WaitForEvent |
|
302 // |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 void CMccInterfaceStub::WaitForEvent( TUint32 aSessionId, TUint32 aLinkId, |
|
306 TUint32 aStreamId, TMccEventType aEventType ) |
|
307 { |
|
308 ClearEvent( iEventToWaitFor ); |
|
309 iEventToWaitFor.iSessionId = aSessionId; |
|
310 iEventToWaitFor.iLinkId = aLinkId; |
|
311 iEventToWaitFor.iStreamId = aStreamId; |
|
312 iEventToWaitFor.iEventType = aEventType; |
|
313 |
|
314 CActiveScheduler::Start(); |
|
315 } |
|
316 |
|
317 |
|
318 // --------------------------------------------------------------------------- |
|
319 // CMccInterfaceStub::WaitForEvent |
|
320 // |
|
321 // --------------------------------------------------------------------------- |
|
322 // |
|
323 void CMccInterfaceStub::WaitForEvent( TUint32 aSessionId, TUint32 aLinkId, |
|
324 TUint32 aStreamId, TUint32 aSinkSourceId, TMccEventType aEventType ) |
|
325 { |
|
326 ClearEvent( iEventToWaitFor ); |
|
327 iEventToWaitFor.iSessionId = aSessionId; |
|
328 iEventToWaitFor.iLinkId = aLinkId; |
|
329 iEventToWaitFor.iStreamId = aStreamId; |
|
330 iEventToWaitFor.iEndpointId = aSinkSourceId; |
|
331 iEventToWaitFor.iEventType = aEventType; |
|
332 |
|
333 CActiveScheduler::Start(); |
|
334 } |
|
335 |
|
336 // --------------------------------------------------------------------------- |
|
337 // CMccInterfaceStub::WaitForEvent |
|
338 // |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 void CMccInterfaceStub::WaitForEvent( TUint32 aSessionId, TUint32 aLinkId, |
|
342 TUint32 aStreamId, TMccEventType aEventType, TMccDtmfEventType aDtmfEventType ) |
|
343 { |
|
344 ClearEvent( iEventToWaitFor ); |
|
345 iEventToWaitFor.iSessionId = aSessionId; |
|
346 iEventToWaitFor.iLinkId = aLinkId; |
|
347 iEventToWaitFor.iStreamId = aStreamId; |
|
348 iEventToWaitFor.iEventCategory = KMccEventCategoryDtmf; |
|
349 iEventToWaitFor.iEventType = aEventType; |
|
350 |
|
351 TMccDtmfEventData dtmfEvent; |
|
352 dtmfEvent.iDtmfEventType = aDtmfEventType; |
|
353 iEventToWaitFor.iEventData = TMccDtmfEventDataPackage( dtmfEvent ); |
|
354 |
|
355 CActiveScheduler::Start(); |
|
356 } |
|
357 |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // CMccInterfaceStub::EventsAreEqual |
|
361 // |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 TBool CMccInterfaceStub::EventsAreEqual( |
|
365 const TMccEvent& aEvent1, const TMccEvent& aEvent2 ) const |
|
366 { |
|
367 TBool match( EFalse ); |
|
368 match = ( aEvent1.iSessionId == aEvent2.iSessionId ); |
|
369 |
|
370 if ( match && aEvent1.iLinkId != 0 ) |
|
371 { |
|
372 match = ( aEvent1.iLinkId == aEvent2.iLinkId ); |
|
373 } |
|
374 |
|
375 if ( match && aEvent1.iStreamId != 0 ) |
|
376 { |
|
377 match = ( aEvent1.iStreamId == aEvent2.iStreamId ); |
|
378 } |
|
379 |
|
380 if ( match && aEvent1.iEndpointId != 0 ) |
|
381 { |
|
382 match = ( aEvent1.iEndpointId == aEvent2.iEndpointId ); |
|
383 } |
|
384 |
|
385 if ( match && aEvent1.iEventCategory != 0 ) |
|
386 { |
|
387 match = ( aEvent1.iEventCategory == aEvent2.iEventCategory ); |
|
388 } |
|
389 |
|
390 if ( match && aEvent1.iEventType != KMccEventNone ) |
|
391 { |
|
392 match = ( aEvent1.iEventType == aEvent2.iEventType ); |
|
393 } |
|
394 |
|
395 if ( match && aEvent1.iEventData != KNullDesC8 ) |
|
396 { |
|
397 if ( KMccEventCategoryDtmf == aEvent1.iEventCategory ) |
|
398 { |
|
399 const TMccDtmfEventData& dtmfEvent1 = |
|
400 (*reinterpret_cast<const TMccDtmfEventDataPackage*> |
|
401 ( &aEvent1.iEventData ) )(); |
|
402 |
|
403 const TMccDtmfEventData& dtmfEvent2 = |
|
404 (*reinterpret_cast<const TMccDtmfEventDataPackage*> |
|
405 ( &aEvent1.iEventData ) )(); |
|
406 |
|
407 match = ( dtmfEvent1.iDtmfEventType == dtmfEvent2.iDtmfEventType ); |
|
408 } |
|
409 } |
|
410 |
|
411 return match; |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------------------------- |
|
415 // CMccInterfaceStub::ClearEvent |
|
416 // |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 void CMccInterfaceStub::ClearEvent( TMccEvent& aEvent ) |
|
420 { |
|
421 aEvent = TMccEvent(); |
|
422 } |
|
423 |
|
424 |
|
425 // --------------------------------------------------------------------------- |
|
426 // CMccInterfaceStub::HandleEventReceival |
|
427 // |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 void CMccInterfaceStub::HandleEventReceival( const TMccEvent& aEvent ) |
|
431 { |
|
432 if ( EventsAreEqual( iEventToWaitFor, aEvent ) ) |
|
433 { |
|
434 RDebug::Print( _L("CMccInterfaceStub::HandleEventReceival, STOP WAIT LOOP") ); |
|
435 CActiveScheduler::Stop(); |
|
436 } |
|
437 else |
|
438 { |
|
439 // Eat event and continue to listen a new one |
|
440 RDebug::Print( _L("CMccInterfaceStub::HandleEventReceival, UNEXPECTED EVENT") ); |
|
441 } |
|
442 } |