|
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_musenglivesession.h" |
|
21 #include "musengstubs.h" |
|
22 #include "musengtestdefs.h" |
|
23 #include "musenglivesession.h" |
|
24 #include "mussipprofilehandler.h" |
|
25 #include "musengmceutils.h" |
|
26 #include "mussettings.h" |
|
27 #include "mussessionproperties.h" |
|
28 #include "musenglivevideoplayer.h" |
|
29 |
|
30 // SYSTEM INCLUDES |
|
31 #include <digia/eunit/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 |
|
42 |
|
43 |
|
44 //use step in different time period |
|
45 const TInt KZoomBigStepCount = 15; |
|
46 const TInt KZoomSmallStepCount = KZoomBigStepCount*2; |
|
47 const TInt KZoomStepMinSize = 1; |
|
48 |
|
49 // 0.4 second |
|
50 const TInt64 KZoomFasterTime = 400000;//must bigger than 1/3 second |
|
51 |
|
52 //insure that step is 1 |
|
53 #define USER_SLEEP User::After(KZoomFasterTime) |
|
54 |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 UT_CMusEngLiveSession* UT_CMusEngLiveSession::NewL() |
|
62 { |
|
63 UT_CMusEngLiveSession* self = UT_CMusEngLiveSession::NewLC(); |
|
64 CleanupStack::Pop( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 UT_CMusEngLiveSession* UT_CMusEngLiveSession::NewLC() |
|
74 { |
|
75 UT_CMusEngLiveSession* self = new( ELeave ) UT_CMusEngLiveSession(); |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL(); |
|
78 return self; |
|
79 } |
|
80 |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 UT_CMusEngLiveSession::~UT_CMusEngLiveSession() |
|
87 { |
|
88 // NOP |
|
89 } |
|
90 |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // Default constructor |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 UT_CMusEngLiveSession::UT_CMusEngLiveSession() |
|
97 { |
|
98 // NOP |
|
99 } |
|
100 |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // Second phase construct |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void UT_CMusEngLiveSession::ConstructL() |
|
107 { |
|
108 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
109 // It generates the test case table. |
|
110 CEUnitTestSuiteClass::ConstructL(); |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void UT_CMusEngLiveSession::SetupL() |
|
119 { |
|
120 iLcSessionObserver = new( ELeave )CLcSessionObserverStub; |
|
121 iLcUiProvider = new( ELeave )CLcUiProviderStub; |
|
122 iAudioRoutingObserver = new( ELeave )CMusEngObserverStub; |
|
123 |
|
124 iLiveSession = CMusEngLiveSession::NewL(); |
|
125 iLiveSession->SetLcSessionObserver( iLcSessionObserver ); |
|
126 iLiveSession->SetLcUiProvider( iLcUiProvider ); |
|
127 |
|
128 iRecordedLiveSession = CMusEngLiveSession::NewL(); |
|
129 iRecordedLiveSession->SetLcSessionObserver( iLcSessionObserver ); |
|
130 iRecordedLiveSession->SetLcUiProvider( iLcUiProvider ); |
|
131 MLcDestinationFileControl* destinationFileControl = |
|
132 iRecordedLiveSession->LocalVideoPlayer()->LcDestinationFileControl(); |
|
133 destinationFileControl->SetLcFileNameL( KTestVideoFileName() ); |
|
134 |
|
135 User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, |
|
136 NMusSessionApi::KRemoteSipAddress, |
|
137 KTestRecipientSipUri ) ); |
|
138 } |
|
139 |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void UT_CMusEngLiveSession::Teardown() |
|
146 { |
|
147 delete iLiveSession; |
|
148 delete iRecordedLiveSession; |
|
149 delete iLcSessionObserver; |
|
150 delete iLcUiProvider; |
|
151 delete iAudioRoutingObserver; |
|
152 PropertyHelper::Close(); |
|
153 // Delete static data from CenRep stub |
|
154 CRepository::iStaticWriteAvcKeysToStaticData = EFalse; |
|
155 CRepository::DeleteStubAvcConfigKeys(); |
|
156 CRepository::ResetStubGlobal(); |
|
157 CRepository::iForceFailWithCode = KErrNone; |
|
158 } |
|
159 |
|
160 |
|
161 |
|
162 // TEST CASES |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void UT_CMusEngLiveSession::UT_NewLL() |
|
169 { |
|
170 EUNIT_ASSERT( iLiveSession ) |
|
171 EUNIT_ASSERT( iRecordedLiveSession ) |
|
172 EUNIT_ASSERT( iLiveSession->iCameraHandler.iCameraUsage == MusSettingsKeys::EUseCameraSwapping ); |
|
173 EUNIT_ASSERT( iLiveSession->iMceManagerUid == TUid::Uid( KMusUiUid ) ); |
|
174 |
|
175 delete iLiveSession; |
|
176 iLiveSession = NULL; |
|
177 CRepository::SetStubGlobal( MusSettingsKeys::KCameraUsage, |
|
178 MusSettingsKeys::EUseOnlySecondaryCamera ); |
|
179 |
|
180 iLiveSession = CMusEngLiveSession::NewL(); |
|
181 |
|
182 EUNIT_ASSERT_EQUALS( TInt( iLiveSession->iCameraHandler.iCameraUsage ), |
|
183 TInt( MusSettingsKeys::EUseOnlySecondaryCamera ) ); |
|
184 |
|
185 delete iLiveSession; |
|
186 iLiveSession = NULL; |
|
187 CRepository::SetStubGlobal( MusSettingsKeys::KCameraUsage, |
|
188 MusSettingsKeys::EUseOnlyMainCamera ); |
|
189 |
|
190 iLiveSession = CMusEngLiveSession::NewL(); |
|
191 |
|
192 EUNIT_ASSERT_EQUALS( TInt( iLiveSession->iCameraHandler.iCameraUsage ), |
|
193 TInt( MusSettingsKeys::EUseOnlyMainCamera ) ); |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void UT_CMusEngLiveSession::UT_CompleteSessionStructureLL() |
|
201 { |
|
202 CMceStreamBundle* localBundle = |
|
203 CMceStreamBundle::NewLC( CMceStreamBundle::ELS ); |
|
204 |
|
205 // Check that structure cannot be completed before creating the session |
|
206 TRAPD( error, iLiveSession->CompleteSessionStructureL( *localBundle ) ); |
|
207 MUS_TEST_FORWARD_ALLOC_FAILURE( error ); |
|
208 EUNIT_ASSERT( error == KErrNotReady ); |
|
209 |
|
210 // Normal case |
|
211 |
|
212 CSIPProfile* profile = iLiveSession->iSipProfileHandler->Profile(); |
|
213 |
|
214 iLiveSession->iSession = CMceOutSession::NewL( |
|
215 *(iLiveSession->iManager), |
|
216 *profile, |
|
217 KTestRecipientSipUri8() ); |
|
218 |
|
219 iLiveSession->CompleteSessionStructureL( *localBundle ); |
|
220 |
|
221 EUNIT_ASSERT( localBundle->Streams().Count() == 0 ) |
|
222 |
|
223 EUNIT_ASSERT( iLiveSession->iSession->Streams().Count() == 1 ); |
|
224 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Type() == KMceVideo ); |
|
225 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Source() ); |
|
226 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Source()->Type() == |
|
227 KMceCameraSource ); |
|
228 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Sinks().Count() == 1 ); |
|
229 EUNIT_ASSERT( iLiveSession->iSession->Streams()[0]->Sinks()[0]->Type() == |
|
230 KMceRTPSink ); |
|
231 |
|
232 // Test that also recording stream is constructed if needed |
|
233 |
|
234 iRecordedLiveSession->iSession = CMceOutSession::NewL( |
|
235 *(iLiveSession->iManager), |
|
236 *profile, |
|
237 KTestRecipientSipUri8() ); |
|
238 |
|
239 iRecordedLiveSession->CompleteSessionStructureL( *localBundle ); |
|
240 |
|
241 EUNIT_ASSERT( localBundle->Streams().Count() == 0 ) |
|
242 |
|
243 CMceCameraSource* camera = |
|
244 MusEngMceUtils::GetCameraL( *(iRecordedLiveSession->iSession) ); |
|
245 |
|
246 // Check that there is recorded stream and that source is same camera |
|
247 CMceMediaSink* file = NULL; |
|
248 const RPointerArray<CMceMediaStream>& streams = |
|
249 iRecordedLiveSession->iSession->Streams(); |
|
250 |
|
251 for ( TInt i = 0; i < streams.Count(); ++i ) |
|
252 { |
|
253 if ( streams[i]->Type() == KMceVideo ) |
|
254 { |
|
255 if ( streams[i]->Sinks()[0]->Type() == KMceFileSink ) |
|
256 { |
|
257 file = streams[i]->Sinks()[0]; |
|
258 } |
|
259 EUNIT_ASSERT( streams[i]->Source() == camera ) |
|
260 } |
|
261 } |
|
262 |
|
263 EUNIT_ASSERT( file ) |
|
264 |
|
265 |
|
266 |
|
267 EUNIT_ASSERT( iLiveSession->iCameraHandler.iCurrentCamera == |
|
268 TMusEngCameraHandler::EBackCamera ); |
|
269 |
|
270 delete iLiveSession->iSession; |
|
271 iLiveSession->iSession = NULL; |
|
272 |
|
273 iLiveSession->iSession = CMceOutSession::NewL( |
|
274 *(iLiveSession->iManager), |
|
275 *profile, |
|
276 KTestRecipientSipUri8() ); |
|
277 |
|
278 iLiveSession->iCameraHandler.iCameraUsage = MusSettingsKeys::EUseOnlySecondaryCamera; |
|
279 iLiveSession->CompleteSessionStructureL( *localBundle ); |
|
280 |
|
281 EUNIT_ASSERT( iLiveSession->iCameraHandler.iCurrentCamera == |
|
282 TMusEngCameraHandler::EFrontCamera ); |
|
283 |
|
284 |
|
285 CleanupStack::PopAndDestroy( localBundle ); |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 void UT_CMusEngLiveSession::UT_AdjustVideoCodecLL() |
|
293 { |
|
294 CRepository::SetStubAvcConfigKeysL( KNullDesC8() ); |
|
295 |
|
296 CMceVideoCodec* codecH263 = CMceH263Codec::NewLC( KMceSDPNameH263() ); |
|
297 CMceVideoCodec* codecH2632000 = CMceH263Codec::NewLC( KMceSDPNameH2632000() ); |
|
298 CMceVideoCodec* codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() ); |
|
299 CMceVideoCodec* codecUnknown = CMceH263Codec::NewLC( KNullDesC8() ); |
|
300 |
|
301 iLiveSession->AdjustVideoCodecL( *codecH263, KMceCameraSource ); |
|
302 iLiveSession->AdjustVideoCodecL( *codecH2632000, KMceCameraSource ); |
|
303 iLiveSession->AdjustVideoCodecL( *codecAvc, KMceCameraSource ); |
|
304 iLiveSession->AdjustVideoCodecL( *codecUnknown, KMceCameraSource ); |
|
305 |
|
306 // Test that bit rates has been set to H263 & AVC codecs |
|
307 EUNIT_ASSERT( codecH263->iAllowedBitrates == KMceAllowedH263BitrateAll ) |
|
308 EUNIT_ASSERT( codecH263->iMaxBitRate == KMceH263Level45Bitrate ) |
|
309 EUNIT_ASSERT( codecH263->iBitrate == 80000 ) |
|
310 |
|
311 EUNIT_ASSERT( codecH2632000->iAllowedBitrates == |
|
312 KMceAllowedH263BitrateAll ) |
|
313 EUNIT_ASSERT( codecH2632000->iMaxBitRate == KMceH263Level45Bitrate ) |
|
314 EUNIT_ASSERT( codecH2632000->iBitrate == 80000 ) |
|
315 |
|
316 EUNIT_ASSERT( codecAvc->iAllowedBitrates == |
|
317 KMceAvcCodecProfileIdBaseline | |
|
318 KMceAvcCodecProfileIopConstraintSet | |
|
319 KMceAvcBitrateLevel1b ) |
|
320 EUNIT_ASSERT( iLiveSession->iStoreEncoderConfigInfo ) |
|
321 |
|
322 |
|
323 // Test that bitrates has not been set to unknown codecs |
|
324 EUNIT_ASSERT( codecUnknown->iAllowedBitrates != |
|
325 KMceAllowedH263BitrateAll ) |
|
326 EUNIT_ASSERT( codecUnknown->iMaxBitRate != KMceH263Level45Bitrate ) |
|
327 EUNIT_ASSERT( codecUnknown->iBitrate != KMceH263Level10Bitrate ) |
|
328 |
|
329 // Test that base class has been called to all codecs |
|
330 EUNIT_ASSERT( codecH263->iPayloadType == 96 ) |
|
331 EUNIT_ASSERT( codecH2632000->iPayloadType == 96 ) |
|
332 EUNIT_ASSERT( codecAvc->iPayloadType == 98 ) |
|
333 EUNIT_ASSERT( codecUnknown->iPayloadType == 0 ) |
|
334 |
|
335 CleanupStack::PopAndDestroy( codecUnknown ); |
|
336 CleanupStack::PopAndDestroy( codecAvc ); |
|
337 CleanupStack::PopAndDestroy( codecH2632000 ); |
|
338 CleanupStack::PopAndDestroy( codecH263 ); |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 void UT_CMusEngLiveSession::UT_AdjustAudioCodecLL() |
|
346 { |
|
347 CMceAudioCodec* codec = |
|
348 iLiveSession->iManager->SupportedAudioCodecs()[0]->CloneL(); |
|
349 CleanupStack::PushL( codec ); |
|
350 iLiveSession->AdjustAudioCodecL( *codec ); |
|
351 |
|
352 // Does nothing so just test that base class has been called |
|
353 |
|
354 EUNIT_ASSERT( codec->iPayloadType == 97 ) |
|
355 |
|
356 CleanupStack::PopAndDestroy( codec ); |
|
357 } |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 void UT_CMusEngLiveSession::UT_DoCodecSelectionLL() |
|
364 { |
|
365 CMceVideoStream* stream = CMceVideoStream::NewLC(); |
|
366 |
|
367 CMceVideoCodec* codecH263 = CMceH263Codec::NewLC( _L8( "Foo" ) ); |
|
368 stream->AddCodecL( codecH263 ); |
|
369 CleanupStack::Pop( codecH263 ); |
|
370 |
|
371 CMceVideoCodec* codecH2632000 = CMceH263Codec::NewLC( _L8( "Bar" ) ); |
|
372 stream->AddCodecL( codecH2632000 ); |
|
373 CleanupStack::Pop( codecH2632000 ); |
|
374 |
|
375 CMceVideoCodec* codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() ); |
|
376 stream->AddCodecL( codecAvc ); |
|
377 CleanupStack::Pop( codecAvc ); |
|
378 |
|
379 // No assumptions so all the codecs are left to stream |
|
380 iLiveSession->DoCodecSelectionL( *stream ); |
|
381 EUNIT_ASSERT_EQUALS( stream->Codecs().Count(), 3 ) |
|
382 |
|
383 // Check that AVC codecs are removed if they are known to be not supported |
|
384 delete iLiveSession->iVideoCodecList; |
|
385 iLiveSession->iVideoCodecList = NULL; |
|
386 iLiveSession->iVideoCodecList = _L8("SomethingThatIsNotAVC").AllocL(); |
|
387 iLiveSession->DoCodecSelectionL( *stream ); |
|
388 EUNIT_ASSERT_EQUALS( stream->Codecs().Count(), 2 ) |
|
389 EUNIT_ASSERT( stream->Codecs()[0]->SdpName() != KMceSDPNameH264() ) |
|
390 EUNIT_ASSERT( stream->Codecs()[1]->SdpName() != KMceSDPNameH264() ) |
|
391 |
|
392 CleanupStack::PopAndDestroy( stream ); |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // Although all states are not meaningfull for LiveSession, all states are |
|
397 // tested in order to force the updating of unit tests when behavior is changed |
|
398 // ----------------------------------------------------------------------------- |
|
399 // |
|
400 void UT_CMusEngLiveSession::UT_StreamStateChangedL() |
|
401 { |
|
402 // Try without a session, nothing happens |
|
403 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
404 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
405 *videoStream ); |
|
406 CleanupStack::PopAndDestroy( videoStream ); |
|
407 |
|
408 // Simulate sending invite |
|
409 iLiveSession->EstablishLcSessionL(); |
|
410 |
|
411 // Try all the stream states |
|
412 CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0]; |
|
413 |
|
414 // EUninitialized, stream is created, unexpected change, nothing happens |
|
415 changedStream->iState = CMceMediaStream::EUninitialized; |
|
416 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
417 *changedStream ); |
|
418 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
419 |
|
420 // EInitialized, stream is initialized |
|
421 changedStream->iState = CMceMediaStream::EInitialized; |
|
422 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
423 *changedStream ); |
|
424 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
425 |
|
426 // EBuffering, stream is buffering |
|
427 changedStream->iState = CMceMediaStream::EBuffering; |
|
428 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
429 *changedStream ); |
|
430 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
431 |
|
432 // EIdle, stream is not receiving RTP |
|
433 changedStream->iState = CMceMediaStream::EIdle; |
|
434 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
435 *changedStream ); |
|
436 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
437 |
|
438 // EStreaming, stream is streaming |
|
439 changedStream->iState = CMceMediaStream::EStreaming; |
|
440 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( *changedStream ); |
|
441 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
442 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
443 iLcSessionObserver->Reset(); |
|
444 |
|
445 // EDisabled, stream is explicitly disabled |
|
446 changedStream->iState = CMceMediaStream::EDisabled; |
|
447 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
448 *changedStream ); |
|
449 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
450 |
|
451 // ENoResources, stream has no needed resources to stream |
|
452 changedStream->iState = CMceMediaStream::ENoResources; |
|
453 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
454 *changedStream ); |
|
455 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
456 |
|
457 // ETranscodingRequired, stream requires non-realtime transcoding |
|
458 changedStream->iState = CMceMediaStream::ETranscodingRequired; |
|
459 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
460 *changedStream ); |
|
461 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
462 |
|
463 // ETranscoding, stream is transcoding in non-realtime |
|
464 changedStream->iState = CMceMediaStream::ETranscoding; |
|
465 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
466 *changedStream ); |
|
467 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // Although all states are not meaningfull for LiveSession, all states are |
|
472 // tested in order to force the updating of unit tests when behavior is changed |
|
473 // ----------------------------------------------------------------------------- |
|
474 // |
|
475 void UT_CMusEngLiveSession::UT_StreamStateChangedWithSourceL() |
|
476 { |
|
477 // Try without a session, nothing happens |
|
478 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
479 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
480 *videoStream, |
|
481 *CMceCameraSource::NewLC( *iLiveSession->iManager ) ); |
|
482 CleanupStack::PopAndDestroy(); // camera |
|
483 CleanupStack::PopAndDestroy( videoStream ); |
|
484 |
|
485 // Simulate sending invite |
|
486 iLiveSession->EstablishLcSessionL(); |
|
487 |
|
488 // Try all the stream states |
|
489 CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0]; |
|
490 CMceMediaSource* changedSource = changedStream->Source(); |
|
491 |
|
492 // EUninitialized, stream is created, unexpected change, nothing happens |
|
493 changedStream->iState = CMceMediaStream::EUninitialized; |
|
494 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
495 *changedStream, *changedSource ); |
|
496 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
497 |
|
498 // EInitialized, stream is initialized |
|
499 changedStream->iState = CMceMediaStream::EInitialized; |
|
500 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
501 *changedStream, *changedSource );; |
|
502 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
503 |
|
504 // EBuffering, stream is buffering |
|
505 changedStream->iState = CMceMediaStream::EBuffering; |
|
506 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
507 *changedStream, *changedSource ); |
|
508 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
509 |
|
510 // EIdle, stream is not receiving RTP |
|
511 changedStream->iState = CMceMediaStream::EIdle; |
|
512 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
513 *changedStream, *changedSource ); |
|
514 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
515 |
|
516 // EStreaming, stream is streaming |
|
517 changedStream->iState = CMceMediaStream::EStreaming; |
|
518 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
519 *changedStream, *changedSource ); |
|
520 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
521 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
522 iLcSessionObserver->Reset(); |
|
523 |
|
524 // EDisabled, stream is explicitly disabled |
|
525 changedStream->iState = CMceMediaStream::EDisabled; |
|
526 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
527 *changedStream, *changedSource ); |
|
528 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
529 |
|
530 // ENoResources, stream has no needed resources to stream |
|
531 changedStream->iState = CMceMediaStream::ENoResources; |
|
532 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
533 *changedStream, *changedSource ); |
|
534 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
535 |
|
536 // ETranscodingRequired, stream requires non-realtime transcoding |
|
537 changedStream->iState = CMceMediaStream::ETranscodingRequired; |
|
538 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
539 *changedStream, *changedSource ); |
|
540 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
541 |
|
542 // ETranscoding, stream is transcoding in non-realtime |
|
543 changedStream->iState = CMceMediaStream::ETranscoding; |
|
544 static_cast<MMceStreamObserver*>(iLiveSession)->StreamStateChanged( |
|
545 *changedStream, *changedSource ); |
|
546 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
547 } |
|
548 |
|
549 // ----------------------------------------------------------------------------- |
|
550 // Although all states are not meaningfull for LiveSession, all states are |
|
551 // tested in order to force the updating of unit tests when behavior is changed |
|
552 // ----------------------------------------------------------------------------- |
|
553 // |
|
554 void UT_CMusEngLiveSession::UT_StreamStateChangedWithSinkL() |
|
555 { |
|
556 // Try without a session, nothing happens |
|
557 ESTABLISH_OUT_SESSION( iLiveSession ) |
|
558 |
|
559 iRecordedLiveSession->StreamStateChanged( |
|
560 *iLiveSession->iSession->Streams()[0], |
|
561 *iLiveSession->iSession->Streams()[0]->Sinks()[0] ); |
|
562 |
|
563 // Try with session |
|
564 |
|
565 ESTABLISH_OUT_SESSION( iRecordedLiveSession ) |
|
566 MLcDestinationFileControl* destinationFileControl = |
|
567 iRecordedLiveSession->LocalVideoPlayer()->LcDestinationFileControl(); |
|
568 destinationFileControl->LcRecordL( ETrue ); |
|
569 |
|
570 // Test state CMceMediaStream::ENoResources |
|
571 |
|
572 // Try without recording stream, nothing happens |
|
573 |
|
574 iLiveSession->StreamStateChanged( |
|
575 *iLiveSession->iSession->Streams()[0], |
|
576 *iLiveSession->iSession->Streams()[0]->Sinks()[0] ); |
|
577 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
578 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
579 iLcSessionObserver->Reset(); |
|
580 |
|
581 // Try again with recording stream, but indicate change in another stream, |
|
582 // nothing happens |
|
583 iRecordedLiveSession->StreamStateChanged( |
|
584 *iLiveSession->iSession->Streams()[0], |
|
585 *iLiveSession->iSession->Streams()[0]->Sinks()[0] ); |
|
586 |
|
587 // Try again with recording stream, but with stream state != ENoResources, |
|
588 // nothing happens |
|
589 CMceVideoStream* recordingStream = |
|
590 MusEngMceUtils::GetRecordingStream( *iRecordedLiveSession->iSession ); |
|
591 |
|
592 EUNIT_ASSERT( recordingStream ) |
|
593 EUNIT_ASSERT( recordingStream->State() != CMceMediaStream::ENoResources ) |
|
594 |
|
595 iRecordedLiveSession->StreamStateChanged( *recordingStream, |
|
596 *recordingStream->Sinks()[0] ); |
|
597 |
|
598 // Try again with recording stream and stream state == ENoResources, |
|
599 // but with enabled sink, nothing happens |
|
600 |
|
601 recordingStream->iState = CMceMediaStream::ENoResources; |
|
602 EUNIT_ASSERT( recordingStream->Sinks()[0]->iIsEnabled ) |
|
603 |
|
604 iRecordedLiveSession->StreamStateChanged( *recordingStream, |
|
605 *recordingStream->Sinks()[0] ); |
|
606 |
|
607 // Disk full case |
|
608 |
|
609 recordingStream->Sinks()[0]->iIsEnabled = EFalse; |
|
610 |
|
611 iRecordedLiveSession->StreamStateChanged( *recordingStream, |
|
612 *recordingStream->Sinks()[0] ); |
|
613 |
|
614 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
615 TInt( CLcSessionObserverStub::ESessionFailed ) ) |
|
616 EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, |
|
617 TInt( MLcSession::EDiskFull ) ) |
|
618 iLcSessionObserver->Reset(); |
|
619 |
|
620 |
|
621 // Test default stream state change behavior |
|
622 |
|
623 CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0]; |
|
624 CMceMediaSink* changedSink = changedStream->Sinks()[0]; |
|
625 |
|
626 // EUninitialized, stream is created, unexpected change, nothing happens |
|
627 changedStream->iState = CMceMediaStream::EUninitialized; |
|
628 iLiveSession->StreamStateChanged( *changedStream, *changedSink ); |
|
629 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
630 |
|
631 // EInitialized, stream is initialized |
|
632 changedStream->iState = CMceMediaStream::EInitialized; |
|
633 iLiveSession->StreamStateChanged( *changedStream, *changedSink ); |
|
634 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
635 |
|
636 // EBuffering, stream is buffering |
|
637 changedStream->iState = CMceMediaStream::EBuffering; |
|
638 iLiveSession->StreamStateChanged( *changedStream, *changedSink ); |
|
639 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
640 |
|
641 // EIdle, stream is not receiving RTP |
|
642 changedStream->iState = CMceMediaStream::EIdle; |
|
643 iLiveSession->StreamStateChanged( *changedStream, *changedSink ); |
|
644 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
645 |
|
646 // EStreaming, stream is streaming |
|
647 changedStream->iState = CMceMediaStream::EStreaming; |
|
648 iLiveSession->StreamStateChanged( *changedStream, *changedSink ); |
|
649 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
650 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
651 iLcSessionObserver->Reset(); |
|
652 |
|
653 // EDisabled, stream is explicitly disabled |
|
654 changedStream->iState = CMceMediaStream::EDisabled; |
|
655 iLiveSession->StreamStateChanged( *changedStream, *changedSink ); |
|
656 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
657 |
|
658 // ENoResources, stream has no needed resources to stream |
|
659 // This state has non-default meaning, tested before defaults |
|
660 |
|
661 // ETranscodingRequired, stream requires non-realtime transcoding |
|
662 changedStream->iState = CMceMediaStream::ETranscodingRequired; |
|
663 iLiveSession->StreamStateChanged( *changedStream, *changedSink ); |
|
664 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
665 |
|
666 // ETranscoding, stream is transcoding in non-realtime |
|
667 changedStream->iState = CMceMediaStream::ETranscoding; |
|
668 iLiveSession->StreamStateChanged( *changedStream, *changedSink ); |
|
669 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
670 |
|
671 } |
|
672 |
|
673 |
|
674 // ----------------------------------------------------------------------------- |
|
675 // |
|
676 // ----------------------------------------------------------------------------- |
|
677 // |
|
678 void UT_CMusEngLiveSession::UT_EstablishLcSessionL() |
|
679 { |
|
680 iLiveSession->EstablishLcSessionL(); |
|
681 EUNIT_ASSERT_EQUALS( TInt( CMceSession::EOffering ), |
|
682 TInt( iLiveSession->iSession->iState ) ) |
|
683 } |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // |
|
687 // ----------------------------------------------------------------------------- |
|
688 // |
|
689 void UT_CMusEngLiveSession::UT_LocalVideoPlayerL() |
|
690 { |
|
691 EUNIT_ASSERT( iLiveSession->LocalVideoPlayer() == |
|
692 iLiveSession->iLiveVideoPlayer ) |
|
693 } |
|
694 |
|
695 // TEST TABLE |
|
696 EUNIT_BEGIN_TEST_TABLE( |
|
697 UT_CMusEngLiveSession, |
|
698 "UT_CMusEngLiveSesssion", |
|
699 "UNIT" ) |
|
700 |
|
701 EUNIT_TEST( |
|
702 "NewL - test ", |
|
703 "CMusEngLiveSession", |
|
704 "NewL", |
|
705 "FUNCTIONALITY", |
|
706 SetupL, UT_NewLL, Teardown) |
|
707 |
|
708 EUNIT_TEST( |
|
709 "CompleteSessionStructureL - test ", |
|
710 "CMusEngLiveSession", |
|
711 "CompleteSessionStructureL", |
|
712 "FUNCTIONALITY", |
|
713 SetupL, UT_CompleteSessionStructureLL, Teardown) |
|
714 |
|
715 EUNIT_TEST( |
|
716 "AdjustVideoCodecL - test ", |
|
717 "CMusEngLiveSession", |
|
718 "AdjustVideoCodecL", |
|
719 "FUNCTIONALITY", |
|
720 SetupL, UT_AdjustVideoCodecLL, Teardown) |
|
721 |
|
722 EUNIT_TEST( |
|
723 "AdjustAudioCodecL - test ", |
|
724 "CMusEngLiveSession", |
|
725 "AdjustAudioCodecL", |
|
726 "FUNCTIONALITY", |
|
727 SetupL, UT_AdjustAudioCodecLL, Teardown) |
|
728 |
|
729 EUNIT_TEST( |
|
730 "DoCodecSelectionL- test ", |
|
731 "CMusEngLiveSession", |
|
732 "DoCodecSelectionL", |
|
733 "FUNCTIONALITY", |
|
734 SetupL, UT_DoCodecSelectionLL, Teardown) |
|
735 |
|
736 EUNIT_TEST( |
|
737 "StreamStateChangedL() - test ", |
|
738 "CMusEngLiveSession", |
|
739 "StreamStateChangedL()", |
|
740 "FUNCTIONALITY", |
|
741 SetupL, UT_StreamStateChangedL, Teardown) |
|
742 |
|
743 EUNIT_TEST( |
|
744 "StreamStateChangedL( src ) - test ", |
|
745 "CMusEngLiveSession", |
|
746 "StreamStateChangedL( src )", |
|
747 "FUNCTIONALITY", |
|
748 SetupL, UT_StreamStateChangedWithSourceL, Teardown) |
|
749 |
|
750 EUNIT_TEST( |
|
751 "StreamStateChangedL( sink ) - test ", |
|
752 "CMusEngLiveSession", |
|
753 "StreamStateChangedL( sink )", |
|
754 "FUNCTIONALITY", |
|
755 SetupL, UT_StreamStateChangedWithSinkL, Teardown) |
|
756 |
|
757 EUNIT_TEST( |
|
758 "EstablishLcSessionL - test ", |
|
759 "CMusEngLiveSession", |
|
760 "EstablishLcSessionL", |
|
761 "FUNCTIONALITY", |
|
762 SetupL, UT_EstablishLcSessionL, Teardown) |
|
763 |
|
764 EUNIT_TEST( |
|
765 "LocalVideoPlayer - test ", |
|
766 "CMusEngLiveSession", |
|
767 "LocalVideoPlayer", |
|
768 "FUNCTIONALITY", |
|
769 SetupL, UT_LocalVideoPlayerL, Teardown) |
|
770 |
|
771 EUNIT_END_TEST_TABLE |
|
772 |
|
773 // END OF FILE |
|
774 |
|
775 |