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 // INTERNAL INCLUDES |
|
20 #include "ut_musengtwowaysession.h" |
|
21 #include "musengstubs.h" |
|
22 #include "musengtestdefs.h" |
|
23 #include "musengtwowaysession.h" |
|
24 #include "mussipprofilehandler.h" |
|
25 #include "musengmceutils.h" |
|
26 #include "mussettings.h" |
|
27 #include "mussessionproperties.h" |
|
28 #include "musengremotevideoplayer.h" |
|
29 |
|
30 // SYSTEM INCLUDES |
|
31 #include <eunitmacros.h> |
|
32 #include <mceoutsession.h> |
|
33 #include <mcestreambundle.h> |
|
34 #include <mcevideostream.h> |
|
35 #include <mcecamerasource.h> |
|
36 #include <mcertpsink.h> |
|
37 #include <mcefilesink.h> |
|
38 #include <mceh263codec.h> |
|
39 #include <mceavccodec.h> |
|
40 #include <mceaudiocodec.h> |
|
41 #include <mcedisplaysink.h> |
|
42 #include <mcertpsource.h> |
|
43 |
|
44 |
|
45 _LIT8( KMusAvcBitrateLevel1TestText, "TestTextForAvcBrL1Level" ); |
|
46 _LIT8( KMusAvcBitrateLevel1bTestText, "TestTextForAvcBrL1bLevel" ); |
|
47 _LIT8( KMusAvcBitrateLevel1_1TestText, "TestTextForAvcBrL1_1Level" ); |
|
48 _LIT8( KMusAvcBitrateLevel1_2TestText, "TestTextForAvcBrL1_2Level" ); |
|
49 _LIT8( KMusAvcBitrateLevel1_3TestText, "TestTextForAvcBrL1_3Level" ); |
|
50 _LIT8( KMusAvcBitrateLevel2TestText, "TestTextForAvcBrL2Level" ); |
|
51 |
|
52 _LIT8( KMusAvcBitrateLevel_1b_ConfigKey, "AvcBrL1b=TestTextForAvcBrL1bLevel;" ); |
|
53 |
|
54 _LIT8( KMusAvcBitrateLevel_1_1_ConfigKey, |
|
55 "AvcBrL1_1=TestTextForAvcBrL1_1Level;"); |
|
56 |
|
57 _LIT8( KMusAvcBitrateLevels_1_1_And_1b_ConfigKeys, |
|
58 "AvcBrL1_1=TestTextForAvcBrL1_1Level;\ |
|
59 AvcBrL1b=TestTextForAvcBrL1bLevel;" ); |
|
60 |
|
61 _LIT8( KMusAvcAllLevelsConcatenation, |
|
62 "AvcBrL1=TestTextForAvcBrL1Level;\ |
|
63 AvcBrL1b=TestTextForAvcBrL1bLevel;\ |
|
64 AvcBrL1_1=TestTextForAvcBrL1_1Level;\ |
|
65 AvcBrL1_2=TestTextForAvcBrL1_2Level;\ |
|
66 AvcBrL1_3=TestTextForAvcBrL1_3Level;\ |
|
67 AvcBrL2=TestTextForAvcBrL2Level;" ); |
|
68 |
|
69 |
|
70 |
|
71 //use step in different time period |
|
72 const TInt KZoomBigStepCount = 15; |
|
73 const TInt KZoomSmallStepCount = KZoomBigStepCount*2; |
|
74 const TInt KZoomStepMinSize = 1; |
|
75 |
|
76 // 0.4 second |
|
77 const TInt64 KZoomFasterTime = 400000;//must bigger than 1/3 second |
|
78 |
|
79 //insure that step is 1 |
|
80 #define USER_SLEEP User::After(KZoomFasterTime) |
|
81 |
|
82 |
|
83 // NOTE!!!!!!!!!! |
|
84 // There are intentianally many same cases as already in CMusEngLiveSession |
|
85 // as two-way session derives from livesession. These cases therefore |
|
86 // ensure that live session changes are not breaking two-way session. |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 UT_CMusEngTwoWaySession* UT_CMusEngTwoWaySession::NewL() |
|
94 { |
|
95 UT_CMusEngTwoWaySession* self = UT_CMusEngTwoWaySession::NewLC(); |
|
96 CleanupStack::Pop( self ); |
|
97 return self; |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 UT_CMusEngTwoWaySession* UT_CMusEngTwoWaySession::NewLC() |
|
106 { |
|
107 UT_CMusEngTwoWaySession* self = new( ELeave ) UT_CMusEngTwoWaySession(); |
|
108 CleanupStack::PushL( self ); |
|
109 self->ConstructL(); |
|
110 return self; |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 UT_CMusEngTwoWaySession::~UT_CMusEngTwoWaySession() |
|
119 { |
|
120 // NOP |
|
121 } |
|
122 |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // Default constructor |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 UT_CMusEngTwoWaySession::UT_CMusEngTwoWaySession() |
|
129 { |
|
130 // NOP |
|
131 } |
|
132 |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // Second phase construct |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void UT_CMusEngTwoWaySession::ConstructL() |
|
139 { |
|
140 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
141 // It generates the test case table. |
|
142 CEUnitTestSuiteClass::ConstructL(); |
|
143 } |
|
144 |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void UT_CMusEngTwoWaySession::SetupL() |
|
151 { |
|
152 iLcSessionObserver = new( ELeave )CLcSessionObserverStub; |
|
153 iLcUiProvider = new( ELeave )CLcUiProviderStub; |
|
154 iLiveSession = CMusEngTwoWaySession::NewL(); |
|
155 iLiveSession->SetLcSessionObserver( iLcSessionObserver ); |
|
156 iLiveSession->SetLcUiProvider( iLcUiProvider ); |
|
157 |
|
158 User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, |
|
159 NMusSessionApi::KRemoteSipAddress, |
|
160 KTestRecipientSipUri ) ); |
|
161 } |
|
162 |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void UT_CMusEngTwoWaySession::Teardown() |
|
169 { |
|
170 delete iLiveSession; |
|
171 delete iLcSessionObserver; |
|
172 delete iLcUiProvider; |
|
173 PropertyHelper::Close(); |
|
174 // Delete static data from CenRep stub |
|
175 CRepository::iStaticWriteAvcKeysToStaticData = EFalse; |
|
176 CRepository::DeleteStubAvcConfigKeys(); |
|
177 CRepository::ResetStubGlobal(); |
|
178 CRepository::iForceFailWithCode = KErrNone; |
|
179 } |
|
180 |
|
181 |
|
182 |
|
183 // TEST CASES |
|
184 |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 void UT_CMusEngTwoWaySession::UT_NewLL() |
|
191 { |
|
192 EUNIT_ASSERT( iLiveSession ) |
|
193 EUNIT_ASSERT( iLiveSession->iCameraHandler.iCameraUsage == MusSettingsKeys::EUseCameraSwapping ); |
|
194 EUNIT_ASSERT( iLiveSession->iMceManagerUid == TUid::Uid( KMusUiUid ) ); |
|
195 |
|
196 delete iLiveSession; |
|
197 iLiveSession = NULL; |
|
198 CRepository::SetStubGlobal( MusSettingsKeys::KCameraUsage, |
|
199 MusSettingsKeys::EUseOnlySecondaryCamera ); |
|
200 |
|
201 iLiveSession = CMusEngTwoWaySession::NewL(); |
|
202 |
|
203 EUNIT_ASSERT( iLiveSession->iCameraHandler.iCameraUsage == MusSettingsKeys::EUseOnlySecondaryCamera ); |
|
204 |
|
205 delete iLiveSession; |
|
206 iLiveSession = NULL; |
|
207 CRepository::SetStubGlobal( MusSettingsKeys::KCameraUsage, |
|
208 MusSettingsKeys::EUseOnlyMainCamera ); |
|
209 |
|
210 iLiveSession = CMusEngTwoWaySession::NewL(); |
|
211 |
|
212 EUNIT_ASSERT_EQUALS( TInt( MusSettingsKeys::EUseOnlyMainCamera ), |
|
213 TInt( iLiveSession->iCameraHandler.iCameraUsage ) ) |
|
214 } |
|
215 |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void UT_CMusEngTwoWaySession::UT_EstablishLcSessionLL() |
|
222 { |
|
223 CRepository::SetStubGlobal( MusSettingsKeys::KVideoBandwidth, |
|
224 128 ); |
|
225 iLiveSession->EstablishLcSessionL(); |
|
226 |
|
227 EUNIT_ASSERT( iLiveSession->iSession ); |
|
228 // Next assertion ensures that session structure is new |
|
229 EUNIT_ASSERT( iLiveSession->iSession->Streams().Count() > 0 ); |
|
230 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0] ); |
|
231 EUNIT_ASSERT( *(iLiveSession->iRecipient) == KTestRecipientSipUri8() ); |
|
232 EUNIT_ASSERT( iLiveSession->iSession->State() == CMceSession::EOffering ); |
|
233 |
|
234 EUNIT_ASSERT( iLiveSession->iSession->iHeaders ); |
|
235 EUNIT_ASSERT( iLiveSession->iSession->iHeaders->Count() == 2 ); |
|
236 EUNIT_ASSERT( iLiveSession->iSession->iHeaders->MdcaPoint( 0 ) == |
|
237 KMusEngAcceptContactHeader() ); |
|
238 EUNIT_ASSERT( iLiveSession->iSession->iHeaders->MdcaPoint( 1 ) == |
|
239 KMusAcceptHeader() ); |
|
240 |
|
241 // Ensure there is no SDP lines at session level |
|
242 EUNIT_ASSERT( iLiveSession->iSession->iSessionSDPLines ); |
|
243 EUNIT_ASSERT( iLiveSession->iSession->iSessionSDPLines->Count() == 1 ); |
|
244 EUNIT_ASSERT( iLiveSession->iSession->iSessionSDPLines->MdcaPoint( 0 ) == |
|
245 KMusEngSessionSdpLineXApplication() ); |
|
246 |
|
247 // Ensure b=AS and b=TIAS attributes are taken at media level |
|
248 MDesC8Array* mediaSdpLines = |
|
249 iLiveSession->iSession->Streams()[0]->iMediaSDPLines; |
|
250 |
|
251 EUNIT_ASSERT( mediaSdpLines ); |
|
252 EUNIT_ASSERT( mediaSdpLines->MdcaCount() == 2 ); |
|
253 EUNIT_ASSERT( mediaSdpLines->MdcaPoint( 0 ).Find( |
|
254 KMusEngSessionSdpLineBandwidthLine() ) == 0 ); |
|
255 EUNIT_ASSERT( mediaSdpLines->MdcaPoint( 1 ).Find( |
|
256 KMusEngSessionSdpLineTiasLine() ) == 0 ); |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 void UT_CMusEngTwoWaySession::UT_EnableDisplayLL() |
|
264 { |
|
265 TRAPD( error, iLiveSession->EnableDisplayL( ETrue ) ); |
|
266 MUS_TEST_FORWARD_ALLOC_FAILURE( error ); |
|
267 EUNIT_ASSERT( error == KErrNotReady ); |
|
268 |
|
269 ESTABLISH_OUT_SESSION( iLiveSession ); |
|
270 |
|
271 CMceDisplaySink* display = |
|
272 MusEngMceUtils::GetDisplayL( *(iLiveSession->iSession) ); |
|
273 |
|
274 CMceDisplaySink* receivingDisplay = |
|
275 MusEngMceUtils::GetReceivingDisplayL( *iLiveSession->iSession ); |
|
276 |
|
277 // Disable |
|
278 iLiveSession->EnableDisplayL( EFalse ); |
|
279 |
|
280 EUNIT_ASSERT( !display->iIsEnabled ); |
|
281 EUNIT_ASSERT( !receivingDisplay->iIsEnabled ); |
|
282 |
|
283 // Try to disable again, request should be ignored |
|
284 |
|
285 iLiveSession->EnableDisplayL( EFalse ); |
|
286 |
|
287 EUNIT_ASSERT( !display->iIsEnabled ); |
|
288 EUNIT_ASSERT( !receivingDisplay->iIsEnabled ); |
|
289 |
|
290 // Enable |
|
291 |
|
292 iLiveSession->EnableDisplayL( ETrue ); |
|
293 |
|
294 EUNIT_ASSERT( display->iIsEnabled ); |
|
295 EUNIT_ASSERT( receivingDisplay->iIsEnabled ); |
|
296 |
|
297 // Try to enable again, request should be ignored |
|
298 |
|
299 iLiveSession->EnableDisplayL( ETrue ); |
|
300 |
|
301 EUNIT_ASSERT( display->iIsEnabled ); |
|
302 EUNIT_ASSERT( receivingDisplay->iIsEnabled ); |
|
303 |
|
304 // Display is active only if receiving and display is explicitly enabled |
|
305 EUNIT_ASSERT( !iLiveSession->IsDisplayActive() ) |
|
306 iLiveSession->iReceiving = ETrue; |
|
307 EUNIT_ASSERT( iLiveSession->IsDisplayActive() ) |
|
308 } |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void UT_CMusEngTwoWaySession::UT_SetOrientationLL() |
|
315 { |
|
316 // Try without session, fails |
|
317 EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->SetOrientationL( |
|
318 CMusEngMceSession::EPortrait ), |
|
319 KErrNotReady ) |
|
320 |
|
321 // Establish a session |
|
322 ESTABLISH_OUT_SESSION( iLiveSession ) |
|
323 |
|
324 CMceDisplaySink* display = |
|
325 MusEngMceUtils::GetDisplayL( *iLiveSession->iSession ); |
|
326 |
|
327 CMceDisplaySink* receivingDisplay = |
|
328 MusEngMceUtils::GetReceivingDisplayL( *iLiveSession->iSession ); |
|
329 |
|
330 |
|
331 // Check the initial state |
|
332 display->iRotation = CMceDisplaySink::ENone; |
|
333 receivingDisplay->iRotation = CMceDisplaySink::ENone; |
|
334 EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), |
|
335 MLcWindow::EPortrait ) |
|
336 |
|
337 // Successfully change orientation |
|
338 |
|
339 iLiveSession->SetOrientationL( CMusEngMceSession::ELandscape ); |
|
340 EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), |
|
341 MLcWindow::ELandscape ) |
|
342 |
|
343 EUNIT_ASSERT_EQUALS( display->iRotation, CMceDisplaySink::EClockwise90Degree ); |
|
344 EUNIT_ASSERT_EQUALS( receivingDisplay->iRotation, CMceDisplaySink::EClockwise90Degree ); |
|
345 |
|
346 iLiveSession->SetOrientationL( CMusEngMceSession::EPortrait ); |
|
347 EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), |
|
348 MLcWindow::EPortrait ) |
|
349 |
|
350 EUNIT_ASSERT_EQUALS( display->iRotation, CMceDisplaySink::ENone ); |
|
351 EUNIT_ASSERT_EQUALS( receivingDisplay->iRotation, CMceDisplaySink::ENone ); |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 void UT_CMusEngTwoWaySession::UT_SetLocalRectLL() |
|
359 { |
|
360 // Does nothing real before session establishment |
|
361 TRect rect1( 100, 200, 300, 500 ); |
|
362 iLiveSession->SetSecondaryRectL( rect1 ); |
|
363 |
|
364 EUNIT_ASSERT( rect1 == iLiveSession->iLocalRect ); |
|
365 |
|
366 // Local rect changing affects to viewfinder display sink not to receiving video |
|
367 // |
|
368 ESTABLISH_OUT_SESSION( iLiveSession ); |
|
369 |
|
370 CMceDisplaySink* vfDisplay = |
|
371 MusEngMceUtils::GetDisplayL( *( iLiveSession->iSession ) ); |
|
372 CMceDisplaySink* receivingDisplay = |
|
373 MusEngMceUtils::GetReceivingDisplayL( *( iLiveSession->iSession ) ); |
|
374 |
|
375 EUNIT_ASSERT( vfDisplay->DisplayRectL() == iLiveSession->iLocalRect ); |
|
376 EUNIT_ASSERT( receivingDisplay->DisplayRectL() != iLiveSession->iLocalRect ); |
|
377 |
|
378 TRect rect2( 200, 200, 300, 500 ); |
|
379 iLiveSession->SetSecondaryRectL( rect2 ); |
|
380 EUNIT_ASSERT( rect2 == iLiveSession->iLocalRect ); |
|
381 EUNIT_ASSERT( vfDisplay->DisplayRectL() == iLiveSession->iLocalRect ); |
|
382 EUNIT_ASSERT( receivingDisplay->DisplayRectL() != iLiveSession->iLocalRect ); |
|
383 |
|
384 // Terminate session and try again, rect must not be changed |
|
385 |
|
386 iLiveSession->iSession->iState = CMceSession::ETerminated; |
|
387 |
|
388 TRect rect3( 300, 300, 400, 600 ); |
|
389 |
|
390 iLiveSession->SetSecondaryRectL( rect3 ); |
|
391 |
|
392 EUNIT_ASSERT( vfDisplay->DisplayRectL() != rect3 ) |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 void UT_CMusEngTwoWaySession::UT_SetRectsLL() |
|
400 { |
|
401 // Does nothing real before session establishment |
|
402 TRect localrect1( 100, 200, 300, 400 ); |
|
403 TRect remoterect1( 100, 200, 300, 500 ); |
|
404 iLiveSession->SetRectsL( remoterect1, localrect1 ); |
|
405 |
|
406 EUNIT_ASSERT( localrect1 == iLiveSession->iLocalRect ); |
|
407 EUNIT_ASSERT( remoterect1 == iLiveSession->iRect ); |
|
408 |
|
409 // Local rect changing affects to viewfinder display sink and remote rect to |
|
410 // receiving video display sink |
|
411 // |
|
412 ESTABLISH_OUT_SESSION( iLiveSession ); |
|
413 |
|
414 CMceDisplaySink* vfDisplay = |
|
415 MusEngMceUtils::GetDisplayL( *( iLiveSession->iSession ) ); |
|
416 CMceDisplaySink* receivingDisplay = |
|
417 MusEngMceUtils::GetReceivingDisplayL( *( iLiveSession->iSession ) ); |
|
418 |
|
419 TRect localrect2( 200, 200, 300, 400 ); |
|
420 TRect remoterect2( 200, 200, 300, 500 ); |
|
421 EUNIT_ASSERT( vfDisplay->DisplayRectL() != localrect2 ); |
|
422 EUNIT_ASSERT( receivingDisplay->DisplayRectL() != remoterect2 ); |
|
423 |
|
424 iLiveSession->SetRectsL( remoterect2, localrect2 ); |
|
425 EUNIT_ASSERT( localrect2 == iLiveSession->iLocalRect ); |
|
426 EUNIT_ASSERT( remoterect2 == iLiveSession->iRect ); |
|
427 EUNIT_ASSERT( vfDisplay->DisplayRectL() == iLiveSession->iLocalRect ); |
|
428 EUNIT_ASSERT( receivingDisplay->DisplayRectL() == iLiveSession->iRect ); |
|
429 |
|
430 // Terminate session and try again, rect must not be changed |
|
431 |
|
432 iLiveSession->iSession->iState = CMceSession::ETerminated; |
|
433 |
|
434 TRect localrect3( 300, 200, 300, 400 ); |
|
435 TRect remoterect3( 300, 200, 300, 500 ); |
|
436 |
|
437 iLiveSession->SetRectsL( remoterect3, localrect3 ); |
|
438 |
|
439 EUNIT_ASSERT( vfDisplay->DisplayRectL() != localrect3 ) |
|
440 EUNIT_ASSERT( receivingDisplay->DisplayRectL() != remoterect3 ); |
|
441 } |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 void UT_CMusEngTwoWaySession::UT_EnableLcFileL() |
|
448 { |
|
449 // Recording is not supported for two-way session |
|
450 EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->EnableLcFileL( ETrue ), |
|
451 KErrNotSupported ) |
|
452 } |
|
453 |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 void UT_CMusEngTwoWaySession::UT_CompleteSessionStructureLL() |
|
459 { |
|
460 |
|
461 CMceStreamBundle* localBundle = |
|
462 CMceStreamBundle::NewLC( CMceStreamBundle::ELS ); |
|
463 |
|
464 // Check that structure cannot be completed before creating the session |
|
465 TRAPD( error, iLiveSession->CompleteSessionStructureL( *localBundle ) ); |
|
466 MUS_TEST_FORWARD_ALLOC_FAILURE( error ); |
|
467 EUNIT_ASSERT( error == KErrNotReady ); |
|
468 |
|
469 // Normal case |
|
470 |
|
471 CSIPProfile* profile = iLiveSession->iSipProfileHandler->Profile(); |
|
472 |
|
473 iLiveSession->iSession = CMceOutSession::NewL( |
|
474 *(iLiveSession->iManager), |
|
475 *profile, |
|
476 KTestRecipientSipUri8() ); |
|
477 |
|
478 iLiveSession->CompleteSessionStructureL( *localBundle ); |
|
479 |
|
480 EUNIT_ASSERT( localBundle->Streams().Count() == 0 ) |
|
481 |
|
482 EUNIT_ASSERT( iLiveSession->iSession->Streams().Count() == 1 ); |
|
483 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Type() == KMceVideo ); |
|
484 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Source() ); |
|
485 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Source()->Type() == |
|
486 KMceCameraSource ); |
|
487 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Sinks().Count() == 1 ); |
|
488 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Sinks()[0]->Type() == |
|
489 KMceRTPSink ); |
|
490 |
|
491 EUNIT_ASSERT( iLiveSession->iCameraHandler.iCurrentCamera == |
|
492 TMusEngCameraHandler::EBackCamera ); |
|
493 |
|
494 CMceVideoStream* vidStream = static_cast<CMceVideoStream*>( iLiveSession->iSession->Streams()[0] ); |
|
495 EUNIT_ASSERT( vidStream->BoundStream() ); |
|
496 CMceVideoStream& inStream = static_cast<CMceVideoStream&>( vidStream->BoundStreamL() ); |
|
497 EUNIT_ASSERT( inStream.Source() ); |
|
498 EUNIT_ASSERT( inStream.Source()->Type() == KMceRTPSource ); |
|
499 EUNIT_ASSERT( inStream.Sinks().Count() == 1 ); |
|
500 EUNIT_ASSERT( inStream.Sinks()[0]->Type() == KMceDisplaySink ); |
|
501 |
|
502 delete iLiveSession->iSession; |
|
503 iLiveSession->iSession = NULL; |
|
504 |
|
505 iLiveSession->iSession = CMceOutSession::NewL( |
|
506 *(iLiveSession->iManager), |
|
507 *profile, |
|
508 KTestRecipientSipUri8() ); |
|
509 |
|
510 iLiveSession->iCameraHandler.iCameraUsage = MusSettingsKeys::EUseOnlySecondaryCamera; |
|
511 iLiveSession->CompleteSessionStructureL( *localBundle ); |
|
512 |
|
513 EUNIT_ASSERT( iLiveSession->iCameraHandler.iCurrentCamera == |
|
514 TMusEngCameraHandler::EFrontCamera ); |
|
515 |
|
516 |
|
517 CleanupStack::PopAndDestroy( localBundle ); |
|
518 } |
|
519 |
|
520 // ----------------------------------------------------------------------------- |
|
521 // |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 void UT_CMusEngTwoWaySession::UT_HandleSessionStateChangedL() |
|
525 { |
|
526 // Make Repository empty, config keys must be written |
|
527 CRepository::SetStubAvcConfigKeysL( KNullDesC8() ); |
|
528 |
|
529 // Invite |
|
530 iLiveSession->EstablishLcSessionL(); |
|
531 iLiveSession->iSession->iState = CMceSession::EEstablished; |
|
532 CRepository::iForceFailWithCode = KErrNone; |
|
533 |
|
534 // Simulate session state transition notification |
|
535 iLiveSession->HandleSessionStateChanged( |
|
536 *iLiveSession->iSession, |
|
537 200, KNullDesC8() ); |
|
538 |
|
539 HBufC8* info = MultimediaSharingSettings::EncoderConfigInfoLC(); |
|
540 EUNIT_ASSERT_NOT_EQUALS( *info, KMusAvcBitrateLevel_1b_ConfigKey() ) |
|
541 CleanupStack::PopAndDestroy( info ); |
|
542 |
|
543 // sendrecv->recvonly downgrade terminates session |
|
544 iLcSessionObserver->Reset(); |
|
545 iLiveSession->iSession->iState = CMceSession::EEstablished; |
|
546 CMceVideoStream* inStream = |
|
547 MusEngMceUtils::GetVideoInStreamL( *iLiveSession->iSession ); |
|
548 inStream->EnableL(); |
|
549 CMceVideoStream* outStream = |
|
550 MusEngMceUtils::GetVideoOutStreamL( *iLiveSession->iSession ); |
|
551 outStream->DisableL(); |
|
552 iLiveSession->HandleSessionStateChanged( |
|
553 *iLiveSession->iSession, 200, KNullDesC8() ); |
|
554 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
555 TInt( CLcSessionObserverStub::ESessionFailed ) ) |
|
556 } |
|
557 |
|
558 // ----------------------------------------------------------------------------- |
|
559 // |
|
560 // ----------------------------------------------------------------------------- |
|
561 // |
|
562 void UT_CMusEngTwoWaySession::UT_AdjustVideoCodecLL() |
|
563 { |
|
564 CRepository::SetStubAvcConfigKeysL( KNullDesC8() ); |
|
565 |
|
566 CMceVideoCodec* codecH263 = CMceH263Codec::NewLC( KMceSDPNameH263() ); |
|
567 CMceVideoCodec* codecH2632000 = CMceH263Codec::NewLC( KMceSDPNameH2632000() ); |
|
568 CMceVideoCodec* codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() ); |
|
569 CMceVideoCodec* codecUnknown = CMceH263Codec::NewLC( KNullDesC8() ); |
|
570 |
|
571 iLiveSession->AdjustVideoCodecL( *codecH263, KMceCameraSource ); |
|
572 iLiveSession->AdjustVideoCodecL( *codecH2632000, KMceCameraSource ); |
|
573 iLiveSession->AdjustVideoCodecL( *codecAvc, KMceCameraSource ); |
|
574 iLiveSession->AdjustVideoCodecL( *codecUnknown, KMceCameraSource ); |
|
575 |
|
576 // Test that bit rates and keepalive has been set to H263 & AVC codecs |
|
577 EUNIT_ASSERT( codecH263->iAllowedBitrates == KMceAllowedH263BitrateAll ) |
|
578 EUNIT_ASSERT( codecH263->iMaxBitRate == KMceH263Level45Bitrate ) |
|
579 EUNIT_ASSERT( codecH263->iBitrate == 80000 ) |
|
580 EUNIT_ASSERT_EQUALS( codecH263->KeepAliveTimer(), 6 ) |
|
581 EUNIT_ASSERT_EQUALS( codecH263->KeepAlivePayloadType(), 96 ) |
|
582 EUNIT_ASSERT_EQUALS( codecH263->KeepAliveData(), KNullDesC8() ) |
|
583 |
|
584 EUNIT_ASSERT( codecH2632000->iAllowedBitrates == |
|
585 KMceAllowedH263BitrateAll ) |
|
586 EUNIT_ASSERT( codecH2632000->iMaxBitRate == KMceH263Level45Bitrate ) |
|
587 EUNIT_ASSERT( codecH2632000->iBitrate == 80000 ) |
|
588 EUNIT_ASSERT_EQUALS( codecH2632000->KeepAliveTimer(), 6 ) |
|
589 EUNIT_ASSERT_EQUALS( codecH2632000->KeepAlivePayloadType(), 96 ) |
|
590 EUNIT_ASSERT_EQUALS( codecH2632000->KeepAliveData(), KNullDesC8() ) |
|
591 |
|
592 EUNIT_ASSERT( codecAvc->iAllowedBitrates == |
|
593 KMceAvcCodecProfileIdBaseline | |
|
594 KMceAvcCodecProfileIopConstraintSet | |
|
595 KMceAvcBitrateLevel1b ) |
|
596 EUNIT_ASSERT_EQUALS( codecAvc->KeepAliveTimer(), 6 ) |
|
597 EUNIT_ASSERT_EQUALS( codecAvc->KeepAlivePayloadType(), 98 ) |
|
598 EUNIT_ASSERT_EQUALS( codecAvc->KeepAliveData(), KNullDesC8() ) |
|
599 EUNIT_ASSERT( iLiveSession->iStoreEncoderConfigInfo ) |
|
600 |
|
601 |
|
602 // Test that bitrates and keepalive has not been set to unknown codecs |
|
603 EUNIT_ASSERT( codecUnknown->iAllowedBitrates != |
|
604 KMceAllowedH263BitrateAll ) |
|
605 EUNIT_ASSERT( codecUnknown->iMaxBitRate != KMceH263Level45Bitrate ) |
|
606 EUNIT_ASSERT( codecUnknown->iBitrate != KMceH263Level10Bitrate ) |
|
607 EUNIT_ASSERT_EQUALS( codecUnknown->KeepAliveTimer(), 6 ) |
|
608 EUNIT_ASSERT_EQUALS( codecUnknown->KeepAlivePayloadType(), 0 ) |
|
609 EUNIT_ASSERT_EQUALS( codecUnknown->KeepAliveData(), KNullDesC8() ) |
|
610 |
|
611 // Test that base class has been called to all codecs |
|
612 EUNIT_ASSERT( codecH263->iPayloadType == 96 ) |
|
613 EUNIT_ASSERT( codecH2632000->iPayloadType == 96 ) |
|
614 EUNIT_ASSERT( codecAvc->iPayloadType == 98 ) |
|
615 EUNIT_ASSERT( codecUnknown->iPayloadType == 0 ) |
|
616 |
|
617 CleanupStack::PopAndDestroy( codecUnknown ); |
|
618 CleanupStack::PopAndDestroy( codecAvc ); |
|
619 CleanupStack::PopAndDestroy( codecH2632000 ); |
|
620 CleanupStack::PopAndDestroy( codecH263 ); |
|
621 } |
|
622 |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 // ----------------------------------------------------------------------------- |
|
626 // |
|
627 void UT_CMusEngTwoWaySession::UT_AdjustAudioCodecLL() |
|
628 { |
|
629 CMceAudioCodec* codec = |
|
630 iLiveSession->iManager->SupportedAudioCodecs()[0]->CloneL(); |
|
631 CleanupStack::PushL( codec ); |
|
632 iLiveSession->AdjustAudioCodecL( *codec ); |
|
633 |
|
634 // Does nothing so just test that base class has been called |
|
635 |
|
636 EUNIT_ASSERT( codec->iPayloadType == 97 ) |
|
637 |
|
638 CleanupStack::PopAndDestroy( codec ); |
|
639 } |
|
640 |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 // ----------------------------------------------------------------------------- |
|
644 // |
|
645 void UT_CMusEngTwoWaySession::UT_DoCodecSelectionLL() |
|
646 { |
|
647 CMceVideoStream* stream = CMceVideoStream::NewLC(); |
|
648 |
|
649 CMceVideoCodec* codecH263 = CMceH263Codec::NewLC( _L8( "Foo" ) ); |
|
650 stream->AddCodecL( codecH263 ); |
|
651 CleanupStack::Pop( codecH263 ); |
|
652 |
|
653 CMceVideoCodec* codecH2632000 = CMceH263Codec::NewLC( _L8( "Bar" ) ); |
|
654 stream->AddCodecL( codecH2632000 ); |
|
655 CleanupStack::Pop( codecH2632000 ); |
|
656 |
|
657 CMceVideoCodec* codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() ); |
|
658 stream->AddCodecL( codecAvc ); |
|
659 CleanupStack::Pop( codecAvc ); |
|
660 |
|
661 // No assumptions so all the codecs are left to stream |
|
662 iLiveSession->DoCodecSelectionL( *stream ); |
|
663 EUNIT_ASSERT_EQUALS( stream->Codecs().Count(), 3 ) |
|
664 |
|
665 // Check that AVC codecs are removed if they are known to be not supported |
|
666 delete iLiveSession->iVideoCodecList; |
|
667 iLiveSession->iVideoCodecList = NULL; |
|
668 iLiveSession->iVideoCodecList = _L8("SomethingThatIsNotAVC").AllocL(); |
|
669 iLiveSession->DoCodecSelectionL( *stream ); |
|
670 EUNIT_ASSERT_EQUALS( stream->Codecs().Count(), 2 ) |
|
671 EUNIT_ASSERT( stream->Codecs()[0]->SdpName() != KMceSDPNameH264() ) |
|
672 EUNIT_ASSERT( stream->Codecs()[1]->SdpName() != KMceSDPNameH264() ) |
|
673 |
|
674 CleanupStack::PopAndDestroy( stream ); |
|
675 } |
|
676 |
|
677 // ----------------------------------------------------------------------------- |
|
678 // Although all states are not meaningfull for LiveSession, all states are |
|
679 // tested in order to force the updating of unit tests when behavior is changed |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 void UT_CMusEngTwoWaySession::UT_StreamStateChangedL() |
|
683 { |
|
684 // Try without a session, nothing happens |
|
685 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
686 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
687 *videoStream ); |
|
688 CleanupStack::PopAndDestroy( videoStream ); |
|
689 |
|
690 // Simulate sending invite |
|
691 iLiveSession->EstablishLcSessionL(); |
|
692 |
|
693 // Try all the stream states |
|
694 CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0]; |
|
695 |
|
696 // EUninitialized, stream is created, unexpected change, nothing happens |
|
697 changedStream->iState = CMceMediaStream::EUninitialized; |
|
698 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
699 *changedStream ); |
|
700 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
701 |
|
702 // EInitialized, stream is initialized |
|
703 changedStream->iState = CMceMediaStream::EInitialized; |
|
704 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
705 *changedStream ); |
|
706 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
707 |
|
708 // EBuffering, outgoing stream is buffering |
|
709 changedStream->iState = CMceMediaStream::EBuffering; |
|
710 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
711 *changedStream ); |
|
712 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
713 |
|
714 // EBuffering, incoming stream is buffering |
|
715 EUNIT_ASSERT( !iLiveSession->iBuffered ); |
|
716 CMceMediaStream* changedInStream = &iLiveSession->iSession->Streams()[0]->BoundStreamL(); |
|
717 changedInStream->iState = CMceMediaStream::EBuffering; |
|
718 iLiveSession->StreamStateChanged( *changedInStream ); |
|
719 EUNIT_ASSERT( iLiveSession->iBuffered ); |
|
720 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
721 |
|
722 // EIdle, stream is not receiving RTP |
|
723 changedStream->iState = CMceMediaStream::EIdle; |
|
724 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
725 *changedStream ); |
|
726 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
727 |
|
728 // EStreaming, outgoing stream is streaming, no effect on receiving information |
|
729 changedStream->iState = CMceMediaStream::EStreaming; |
|
730 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
731 *changedStream ); |
|
732 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
733 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
734 iLcSessionObserver->Reset(); |
|
735 |
|
736 // EStreaming, incoming stream is streaming, receiving information is updated and notified |
|
737 EUNIT_ASSERT( !iLiveSession->iReceiving ); |
|
738 changedInStream->iState = CMceMediaStream::EStreaming; |
|
739 iLiveSession->StreamStateChanged( *changedInStream ); |
|
740 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
741 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
742 EUNIT_ASSERT( iLiveSession->iReceiving ); |
|
743 iLcSessionObserver->Reset(); |
|
744 |
|
745 // EStreaming, incoming stream is streaming, state is notified even if receiving information |
|
746 // says we are already receiving |
|
747 changedInStream->iState = CMceMediaStream::EStreaming; |
|
748 iLiveSession->StreamStateChanged( *changedInStream ); |
|
749 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
750 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
751 iLcSessionObserver->Reset(); |
|
752 |
|
753 // EDisabled, stream is explicitly disabled |
|
754 changedStream->iState = CMceMediaStream::EDisabled; |
|
755 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
756 *changedStream ); |
|
757 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
758 |
|
759 // ENoResources, stream has no needed resources to stream |
|
760 changedStream->iState = CMceMediaStream::ENoResources; |
|
761 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
762 *changedStream ); |
|
763 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
764 |
|
765 // ETranscodingRequired, stream requires non-realtime transcoding |
|
766 changedStream->iState = CMceMediaStream::ETranscodingRequired; |
|
767 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
768 *changedStream ); |
|
769 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
770 |
|
771 // ETranscoding, stream is transcoding in non-realtime |
|
772 changedStream->iState = CMceMediaStream::ETranscoding; |
|
773 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
774 *changedStream ); |
|
775 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
776 } |
|
777 |
|
778 // ----------------------------------------------------------------------------- |
|
779 // Although all states are not meaningfull for LiveSession, all states are |
|
780 // tested in order to force the updating of unit tests when behavior is changed |
|
781 // ----------------------------------------------------------------------------- |
|
782 // |
|
783 void UT_CMusEngTwoWaySession::UT_StreamStateChangedWithSourceL() |
|
784 { |
|
785 // Try without a session, nothing happens |
|
786 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
787 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
788 *videoStream, |
|
789 *CMceCameraSource::NewLC( *iLiveSession->iManager ) ); |
|
790 CleanupStack::PopAndDestroy(); // camera |
|
791 CleanupStack::PopAndDestroy( videoStream ); |
|
792 |
|
793 // Simulate sending invite |
|
794 iLiveSession->EstablishLcSessionL(); |
|
795 |
|
796 // Try all the stream states |
|
797 CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0]; |
|
798 CMceMediaSource* changedSource = changedStream->Source(); |
|
799 |
|
800 // EUninitialized, stream is created, unexpected change, nothing happens |
|
801 changedStream->iState = CMceMediaStream::EUninitialized; |
|
802 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
803 *changedStream, *changedSource ); |
|
804 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
805 |
|
806 // EInitialized, stream is initialized |
|
807 changedStream->iState = CMceMediaStream::EInitialized; |
|
808 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
809 *changedStream, *changedSource );; |
|
810 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
811 |
|
812 // EBuffering, stream is buffering |
|
813 changedStream->iState = CMceMediaStream::EBuffering; |
|
814 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
815 *changedStream, *changedSource ); |
|
816 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
817 |
|
818 // EIdle, stream is not receiving RTP |
|
819 changedStream->iState = CMceMediaStream::EIdle; |
|
820 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
821 *changedStream, *changedSource ); |
|
822 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
823 |
|
824 // EStreaming, stream is streaming |
|
825 changedStream->iState = CMceMediaStream::EStreaming; |
|
826 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
827 *changedStream, *changedSource ); |
|
828 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
829 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
830 iLcSessionObserver->Reset(); |
|
831 |
|
832 // EDisabled, stream is explicitly disabled |
|
833 changedStream->iState = CMceMediaStream::EDisabled; |
|
834 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
835 *changedStream, *changedSource ); |
|
836 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
837 |
|
838 // ENoResources, stream has no needed resources to stream |
|
839 changedStream->iState = CMceMediaStream::ENoResources; |
|
840 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
841 *changedStream, *changedSource ); |
|
842 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
843 |
|
844 // ETranscodingRequired, stream requires non-realtime transcoding |
|
845 changedStream->iState = CMceMediaStream::ETranscodingRequired; |
|
846 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
847 *changedStream, *changedSource ); |
|
848 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
849 |
|
850 // ETranscoding, stream is transcoding in non-realtime |
|
851 changedStream->iState = CMceMediaStream::ETranscoding; |
|
852 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
853 *changedStream, *changedSource ); |
|
854 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
855 } |
|
856 |
|
857 // ----------------------------------------------------------------------------- |
|
858 // |
|
859 // ----------------------------------------------------------------------------- |
|
860 // |
|
861 void UT_CMusEngTwoWaySession::UT_SetEncodingDeviceLL() |
|
862 { |
|
863 CMceAvcCodec* codec = CMceAvcCodec::NewLC( KMceSDPNameH264() ); |
|
864 |
|
865 // Generic error in CenRep, leave expected |
|
866 CRepository::iForceFailWithCode = KErrNotReady; |
|
867 EUNIT_ASSERT_LEAVE( iLiveSession->SetEncodingDeviceL( *codec ) ) |
|
868 EUNIT_ASSERT_EQUALS( codec->iEncodingDecodingDevice, TUid::Uid( 0 ) ) |
|
869 |
|
870 // No entry in CenRep, default value expected |
|
871 CRepository::iForceFailWithCode = KErrNotFound; |
|
872 const TUid KDefaultEncodingDevice( TUid::Uid( 0x20001C13 ) ); |
|
873 iLiveSession->SetEncodingDeviceL( *codec ); |
|
874 EUNIT_ASSERT_EQUALS( codec->iEncodingDecodingDevice, |
|
875 KDefaultEncodingDevice ) |
|
876 |
|
877 // Entry in CenRep |
|
878 const TInt KSomeEncodingDevice( 0x20001C15 ); |
|
879 CRepository::iStaticEncoderUid = KSomeEncodingDevice; |
|
880 iLiveSession->SetEncodingDeviceL( *codec ); |
|
881 EUNIT_ASSERT_EQUALS( codec->iEncodingDecodingDevice, |
|
882 TUid::Uid( KSomeEncodingDevice ) ) |
|
883 |
|
884 CleanupStack::PopAndDestroy( codec ); |
|
885 } |
|
886 |
|
887 // ----------------------------------------------------------------------------- |
|
888 // |
|
889 // ----------------------------------------------------------------------------- |
|
890 // |
|
891 void UT_CMusEngTwoWaySession::UT_SetCodecConfigKeyLL() |
|
892 { |
|
893 CMceAvcCodec* codec = CMceAvcCodec::NewLC( KMceSDPNameH264() ); |
|
894 codec->SetAllowedBitrates( KMceAvcBitrateLevel1b ); |
|
895 |
|
896 // Generic error in CenRep, leave expected |
|
897 CRepository::iForceFailWithCode = KErrNotReady; |
|
898 EUNIT_ASSERT_LEAVE( iLiveSession->SetCodecConfigKeyL( *codec ) ); |
|
899 EUNIT_ASSERT( !codec->iConfigKey ) |
|
900 EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo ) |
|
901 CRepository::iForceFailWithCode = KErrNone; |
|
902 |
|
903 // No entry in CenRep, nothing happens |
|
904 iLiveSession->SetCodecConfigKeyL( *codec ); |
|
905 EUNIT_ASSERT( !codec->iConfigKey ) |
|
906 EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo ) |
|
907 |
|
908 // Empty entry in CenRep |
|
909 CRepository::SetStubAvcConfigKeysL( KNullDesC8() ); |
|
910 iLiveSession->SetCodecConfigKeyL( *codec ); |
|
911 EUNIT_ASSERT( !codec->iConfigKey ) |
|
912 EUNIT_ASSERT( iLiveSession->iStoreEncoderConfigInfo ) |
|
913 iLiveSession->iStoreEncoderConfigInfo = EFalse; // emulate original situation |
|
914 |
|
915 // Entry in CenRep |
|
916 CRepository::SetStubAvcConfigKeysL( KMusAvcBitrateLevel_1b_ConfigKey ); |
|
917 iLiveSession->SetCodecConfigKeyL( *codec ); |
|
918 EUNIT_ASSERT( codec->iConfigKey ) |
|
919 HBufC8* key = codec->ConfigKeyL(); |
|
920 CleanupStack::PushL( key ); |
|
921 EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1bTestText() ) |
|
922 CleanupStack::PopAndDestroy( key ); |
|
923 EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo ) |
|
924 |
|
925 CleanupStack::PopAndDestroy( codec ); |
|
926 } |
|
927 |
|
928 // ----------------------------------------------------------------------------- |
|
929 // |
|
930 // ----------------------------------------------------------------------------- |
|
931 // |
|
932 void UT_CMusEngTwoWaySession::UT_ReadCodecConfigKeyLL() |
|
933 { |
|
934 HBufC8* key( NULL ); |
|
935 |
|
936 // Try with H263, leave expected |
|
937 CMceVideoCodec* codecH263 = CMceH263Codec::NewLC( KMceSDPNameH263() ); |
|
938 EUNIT_ASSERT_LEAVE( key = iLiveSession->ReadCodecConfigKeyL( *codecH263 ) ) |
|
939 CleanupStack::PopAndDestroy( codecH263 ); |
|
940 |
|
941 // Try without an entry in CenRep, leave expected |
|
942 CMceVideoCodec* codec = CMceAvcCodec::NewLC( KMceSDPNameH264() ); |
|
943 codec->SetAllowedBitrates( 0 | KMceAvcBitrateLevel1 ); |
|
944 EUNIT_ASSERT_LEAVE( key = iLiveSession->ReadCodecConfigKeyL( *codec ) ) |
|
945 |
|
946 // Create CenRep entry which does not include wanted bitrate, NULL value |
|
947 // expected |
|
948 CRepository::SetStubAvcConfigKeysL( KMusAvcBitrateLevel1bTestText() ); |
|
949 key = iLiveSession->ReadCodecConfigKeyL( *codec ); |
|
950 EUNIT_ASSERT( !key ) |
|
951 |
|
952 // Create entry with all AVC keys and try with all the values |
|
953 CRepository::SetStubAvcConfigKeysL( KMusAvcAllLevelsConcatenation() ); |
|
954 |
|
955 // KMceAvcBitrateLevel1 |
|
956 key = iLiveSession->ReadCodecConfigKeyL( *codec ); |
|
957 EUNIT_ASSERT( key ); |
|
958 CleanupStack::PushL( key ); |
|
959 EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1TestText ); |
|
960 CleanupStack::PopAndDestroy( key ); |
|
961 |
|
962 // KMceAvcBitrateLevel1b |
|
963 codec->SetAllowedBitrates( KMceAvcBitrateLevel1b ); |
|
964 key = iLiveSession->ReadCodecConfigKeyL( *codec ); |
|
965 EUNIT_ASSERT( key ); |
|
966 CleanupStack::PushL( key ); |
|
967 EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1bTestText ); |
|
968 CleanupStack::PopAndDestroy( key ); |
|
969 |
|
970 // KMceAvcBitrateLevel1_1 |
|
971 codec->SetAllowedBitrates( KMceAvcBitrateLevel1_1 ); |
|
972 key = iLiveSession->ReadCodecConfigKeyL( *codec ); |
|
973 EUNIT_ASSERT( key ); |
|
974 CleanupStack::PushL( key ); |
|
975 EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1_1TestText ); |
|
976 CleanupStack::PopAndDestroy( key ); |
|
977 |
|
978 // KMceAvcBitrateLevel1_2 |
|
979 codec->SetAllowedBitrates( KMceAvcBitrateLevel1_2 ); |
|
980 key = iLiveSession->ReadCodecConfigKeyL( *codec ); |
|
981 EUNIT_ASSERT( key ); |
|
982 CleanupStack::PushL( key ); |
|
983 EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1_2TestText ); |
|
984 CleanupStack::PopAndDestroy( key ); |
|
985 |
|
986 // KMceAvcBitrateLevel1_3 |
|
987 codec->SetAllowedBitrates( KMceAvcBitrateLevel1_3 ); |
|
988 key = iLiveSession->ReadCodecConfigKeyL( *codec ); |
|
989 EUNIT_ASSERT( key ); |
|
990 CleanupStack::PushL( key ); |
|
991 EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1_3TestText ); |
|
992 CleanupStack::PopAndDestroy( key ); |
|
993 |
|
994 // KMceAvcBitrateLevel2 |
|
995 codec->SetAllowedBitrates( KMceAvcBitrateLevel2 ); |
|
996 key = iLiveSession->ReadCodecConfigKeyL( *codec ); |
|
997 EUNIT_ASSERT( key ); |
|
998 CleanupStack::PushL( key ); |
|
999 EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel2TestText ); |
|
1000 CleanupStack::PopAndDestroy( key ); |
|
1001 |
|
1002 CleanupStack::PopAndDestroy( codec ); |
|
1003 } |
|
1004 |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // |
|
1007 // ----------------------------------------------------------------------------- |
|
1008 // |
|
1009 void UT_CMusEngTwoWaySession::UT_StoreEncoderConfigInfoLL() |
|
1010 { |
|
1011 CRepository::iStaticWriteAvcKeysToStaticData = ETrue; |
|
1012 |
|
1013 // Try with clean CenRep |
|
1014 MultimediaSharingSettings::SetEncoderConfigInfoL( KNullDesC8() ); |
|
1015 |
|
1016 ESTABLISH_OUT_SESSION( iLiveSession ) // calls StoreEncoderConfigInfoL |
|
1017 // If StoreEncoderConfigInfoL leaves with KErrNoMemory, |
|
1018 // MMusEngSessionObserver::SessionFailed will be called. |
|
1019 if ( iLcSessionObserver->iCalledFunction == CLcSessionObserverStub::ESessionFailed ) |
|
1020 { |
|
1021 User::Leave( KErrNoMemory ); |
|
1022 } |
|
1023 |
|
1024 HBufC8* keys = MultimediaSharingSettings::EncoderConfigInfoLC(); |
|
1025 EUNIT_ASSERT_EQUALS( *keys, KMusAvcBitrateLevel_1b_ConfigKey() ) |
|
1026 CleanupStack::PopAndDestroy( keys ); |
|
1027 } |
|
1028 |
|
1029 // ----------------------------------------------------------------------------- |
|
1030 // |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // |
|
1033 void UT_CMusEngTwoWaySession::UT_RemoteVideoPlayerL() |
|
1034 { |
|
1035 EUNIT_ASSERT( iLiveSession->RemoteVideoPlayer() == |
|
1036 iLiveSession->iRemoteVideoPlayer ) |
|
1037 } |
|
1038 |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // |
|
1041 // ----------------------------------------------------------------------------- |
|
1042 // |
|
1043 void UT_CMusEngTwoWaySession::UT_InactivityTimeoutL() |
|
1044 { |
|
1045 // Not receiving, no effect |
|
1046 iLiveSession->iReceiving = EFalse; |
|
1047 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
1048 CMceRtpSource* rtpSource = CMceRtpSource::NewLC(); |
|
1049 iLiveSession->InactivityTimeout( *videoStream, *rtpSource ); |
|
1050 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
1051 |
|
1052 // Receiving, state change is notified and |
|
1053 // receiving and buffering status are cleared |
|
1054 iLiveSession->iBuffered = ETrue; |
|
1055 iLiveSession->iReceiving = ETrue; |
|
1056 iLiveSession->InactivityTimeout( *videoStream, *rtpSource ); |
|
1057 EUNIT_ASSERT_EQUALS( iLcSessionObserver->iCalledFunction, |
|
1058 CLcSessionObserverStub::EPlayerStateChanged ); |
|
1059 EUNIT_ASSERT( !iLiveSession->iReceiving ); |
|
1060 EUNIT_ASSERT( !iLiveSession->iBuffered ); |
|
1061 CleanupStack::PopAndDestroy( rtpSource ); |
|
1062 CleanupStack::PopAndDestroy( videoStream ); |
|
1063 } |
|
1064 |
|
1065 |
|
1066 // TEST TABLE |
|
1067 |
|
1068 EUNIT_BEGIN_TEST_TABLE( |
|
1069 UT_CMusEngTwoWaySession, |
|
1070 "UT_CMusEngTwoWaySession", |
|
1071 "UNIT" ) |
|
1072 |
|
1073 EUNIT_TEST( |
|
1074 "NewL - test ", |
|
1075 "CMusEngTwoWaySession", |
|
1076 "NewL", |
|
1077 "FUNCTIONALITY", |
|
1078 SetupL, UT_NewLL, Teardown) |
|
1079 |
|
1080 EUNIT_TEST( |
|
1081 "EstablishLcSessionL - test ", |
|
1082 "CMusEngTwoWaySession", |
|
1083 "EstablishLcSessionL", |
|
1084 "FUNCTIONALITY", |
|
1085 SetupL, UT_EstablishLcSessionLL, Teardown) |
|
1086 |
|
1087 EUNIT_TEST( |
|
1088 "EnableDisplayL - test ", |
|
1089 "CMusEngTwoWaySession", |
|
1090 "EnableDisplayL", |
|
1091 "FUNCTIONALITY", |
|
1092 SetupL, UT_EnableDisplayLL, Teardown) |
|
1093 |
|
1094 EUNIT_TEST( |
|
1095 "SetOrientationL - test ", |
|
1096 "CMusEngTwoWaySession", |
|
1097 "SetOrientationL", |
|
1098 "FUNCTIONALITY", |
|
1099 SetupL, UT_SetOrientationLL, Teardown) |
|
1100 |
|
1101 EUNIT_TEST( |
|
1102 "SetLocalRectL - test ", |
|
1103 "CMusEngTwoWaySession", |
|
1104 "SetLocalRectL", |
|
1105 "FUNCTIONALITY", |
|
1106 SetupL, UT_SetLocalRectLL, Teardown) |
|
1107 |
|
1108 EUNIT_TEST( |
|
1109 "SetRectsL - test ", |
|
1110 "CMusEngTwoWaySession", |
|
1111 "SetRectsL", |
|
1112 "FUNCTIONALITY", |
|
1113 SetupL, UT_SetRectsLL, Teardown) |
|
1114 |
|
1115 EUNIT_TEST( |
|
1116 "CompleteSessionStructureL - test ", |
|
1117 "CMusEngTwoWaySession", |
|
1118 "CompleteSessionStructureL", |
|
1119 "FUNCTIONALITY", |
|
1120 SetupL, UT_CompleteSessionStructureLL, Teardown) |
|
1121 |
|
1122 EUNIT_TEST( |
|
1123 "HandleSessionStateChanged - test ", |
|
1124 "CMusEngTwoWaySession", |
|
1125 "HandleSessionStateChanged", |
|
1126 "FUNCTIONALITY", |
|
1127 SetupL, UT_HandleSessionStateChangedL, Teardown) |
|
1128 |
|
1129 EUNIT_TEST( |
|
1130 "AdjustVideoCodecL - test ", |
|
1131 "CMusEngTwoWaySession", |
|
1132 "AdjustVideoCodecL", |
|
1133 "FUNCTIONALITY", |
|
1134 SetupL, UT_AdjustVideoCodecLL, Teardown) |
|
1135 |
|
1136 EUNIT_TEST( |
|
1137 "AdjustAudioCodecL - test ", |
|
1138 "CMusEngTwoWaySession", |
|
1139 "AdjustAudioCodecL", |
|
1140 "FUNCTIONALITY", |
|
1141 SetupL, UT_AdjustAudioCodecLL, Teardown) |
|
1142 |
|
1143 EUNIT_TEST( |
|
1144 "DoCodecSelectionL- test ", |
|
1145 "CMusEngTwoWaySession", |
|
1146 "DoCodecSelectionL", |
|
1147 "FUNCTIONALITY", |
|
1148 SetupL, UT_DoCodecSelectionLL, Teardown) |
|
1149 |
|
1150 EUNIT_TEST( |
|
1151 "StreamStateChangedL() - test ", |
|
1152 "CMusEngTwoWaySession", |
|
1153 "StreamStateChangedL()", |
|
1154 "FUNCTIONALITY", |
|
1155 SetupL, UT_StreamStateChangedL, Teardown) |
|
1156 |
|
1157 EUNIT_TEST( |
|
1158 "StreamStateChangedL( src ) - test ", |
|
1159 "CMusEngTwoWaySession", |
|
1160 "StreamStateChangedL( src )", |
|
1161 "FUNCTIONALITY", |
|
1162 SetupL, UT_StreamStateChangedWithSourceL, Teardown) |
|
1163 |
|
1164 EUNIT_TEST( |
|
1165 "SetEncodingDeviceL - test ", |
|
1166 "CMusEngTwoWaySession", |
|
1167 "SetEncodingDeviceL", |
|
1168 "FUNCTIONALITY", |
|
1169 SetupL, UT_SetEncodingDeviceLL, Teardown) |
|
1170 |
|
1171 EUNIT_TEST( |
|
1172 "SetCodecConfigKeyL - test ", |
|
1173 "CMusEngTwoWaySession", |
|
1174 "SetCodecConfigKeyL", |
|
1175 "FUNCTIONALITY", |
|
1176 SetupL, UT_SetCodecConfigKeyLL, Teardown) |
|
1177 |
|
1178 EUNIT_TEST( |
|
1179 "ReadCodecConfigKeyL - test ", |
|
1180 "CMusEngTwoWaySession", |
|
1181 "ReadCodecConfigKeyL", |
|
1182 "FUNCTIONALITY", |
|
1183 SetupL, UT_ReadCodecConfigKeyLL, Teardown) |
|
1184 |
|
1185 EUNIT_TEST( |
|
1186 "StoreEncoderConfigInfoL - test ", |
|
1187 "CMusEngTwoWaySession", |
|
1188 "StoreEncoderConfigInfoL", |
|
1189 "FUNCTIONALITY", |
|
1190 SetupL, UT_StoreEncoderConfigInfoLL, Teardown) |
|
1191 |
|
1192 EUNIT_TEST( |
|
1193 "RemoteVideoPlayer - test ", |
|
1194 "CMusEngTwoWaySession", |
|
1195 "RemoteVideoPlayer", |
|
1196 "FUNCTIONALITY", |
|
1197 SetupL, UT_RemoteVideoPlayerL, Teardown) |
|
1198 |
|
1199 EUNIT_TEST( |
|
1200 "EnableLcFileL - test ", |
|
1201 "CMusEngTwoWaySession", |
|
1202 "EnableLcFileL", |
|
1203 "FUNCTIONALITY", |
|
1204 SetupL, UT_EnableLcFileL, Teardown) |
|
1205 |
|
1206 EUNIT_TEST( |
|
1207 "InactivityTimeout - test ", |
|
1208 "CMusEngTwoWaySession", |
|
1209 "InactivityTimeout", |
|
1210 "FUNCTIONALITY", |
|
1211 SetupL, UT_InactivityTimeoutL, Teardown) |
|
1212 |
|
1213 EUNIT_END_TEST_TABLE |
|
1214 |
|
1215 // END OF FILE |
|
1216 |
|
1217 |
|