|
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_musengClipsession.h" |
|
21 #include "musengstubs.h" |
|
22 #include "musengtestdefs.h" |
|
23 #include "musengclipsession.h" |
|
24 #include "mussipprofilehandler.h" |
|
25 #include "musengmceutils.h" |
|
26 #include "mussessionproperties.h" |
|
27 |
|
28 // SYSTEM INCLUDES |
|
29 #include <lcvideoplayer.h> |
|
30 #include <lcsourcefilecontrol.h> |
|
31 #include <eunitmacros.h> |
|
32 #include <mceoutsession.h> |
|
33 #include <mcestreambundle.h> |
|
34 #include <mcevideostream.h> |
|
35 #include <mceaudiostream.h> |
|
36 #include <mcefilesource.h> |
|
37 #include <mcertpsink.h> |
|
38 #include <mcedisplaysink.h> |
|
39 #include <mcespeakersink.h> |
|
40 #include <mcertpsource.h> |
|
41 #include <mcevideocodec.h> |
|
42 #include <mceamrcodec.h> |
|
43 #include <drmcommon.h> |
|
44 #include <sipprofile.h> |
|
45 #include <sipstrings.h> |
|
46 #include <e32property.h> |
|
47 |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 UT_CMusEngClipSession* UT_CMusEngClipSession::NewL() |
|
54 { |
|
55 UT_CMusEngClipSession* self = UT_CMusEngClipSession::NewLC(); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 UT_CMusEngClipSession* UT_CMusEngClipSession::NewLC() |
|
66 { |
|
67 UT_CMusEngClipSession* self = new( ELeave ) UT_CMusEngClipSession(); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 return self; |
|
71 } |
|
72 |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 UT_CMusEngClipSession::~UT_CMusEngClipSession() |
|
79 { |
|
80 // NOP |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // Default constructor |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 UT_CMusEngClipSession::UT_CMusEngClipSession() |
|
89 { |
|
90 // NOP |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // Second phase construct |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void UT_CMusEngClipSession::ConstructL() |
|
99 { |
|
100 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
101 // It generates the test case table. |
|
102 CEUnitTestSuiteClass::ConstructL(); |
|
103 } |
|
104 |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void UT_CMusEngClipSession::SetupL() |
|
111 { |
|
112 iLcSessionObserver = new( ELeave )CLcSessionObserverStub; |
|
113 iLcUiProvider = new( ELeave )CLcUiProviderStub; |
|
114 iAudioRoutingObserver = new( ELeave )CMusEngObserverStub; |
|
115 |
|
116 iClipSession = CMusEngClipSession::NewL(); |
|
117 iClipSession->SetLcSessionObserver( iLcSessionObserver ); |
|
118 iClipSession->SetLcUiProvider( iLcUiProvider ); |
|
119 iClipSession->LocalVideoPlayer()->LcSourceFileControl()->SetLcFileNameL( |
|
120 KTestVideoFileName() ); |
|
121 delete iClipSession->iVideoCodecList; |
|
122 iClipSession->iVideoCodecList = NULL; |
|
123 iClipSession->iVideoCodecList = KMceSDPNameH264().AllocL(); |
|
124 |
|
125 SIPStrings::OpenL(); |
|
126 |
|
127 User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, |
|
128 NMusSessionApi::KRemoteSipAddress, |
|
129 KTestRecipientSipUri ) ); |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void UT_CMusEngClipSession::Teardown() |
|
138 { |
|
139 SIPStrings::Close(); |
|
140 delete iClipSession; |
|
141 delete iLcSessionObserver; |
|
142 delete iLcUiProvider; |
|
143 delete iAudioRoutingObserver; |
|
144 PropertyHelper::Close(); |
|
145 } |
|
146 |
|
147 |
|
148 |
|
149 // TEST CASES |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void UT_CMusEngClipSession::UT_NewLL() |
|
156 { |
|
157 EUNIT_ASSERT( iClipSession ) |
|
158 EUNIT_ASSERT( !iClipSession->iSession ) |
|
159 EUNIT_ASSERT( iClipSession->iMceManagerUid == TUid::Uid( KMusUiUid ) ); |
|
160 } |
|
161 |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 void UT_CMusEngClipSession::UT_CompleteSessionStructureLL() |
|
168 { |
|
169 CMceStreamBundle* localBundle = |
|
170 CMceStreamBundle::NewLC( CMceStreamBundle::ELS ); |
|
171 |
|
172 // Check that structure cannot be completed before creating the session |
|
173 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
174 iClipSession->CompleteSessionStructureL( *localBundle ), |
|
175 KErrNotReady ) |
|
176 |
|
177 // Normal case |
|
178 CSIPProfile* profile = iClipSession->iSipProfileHandler->Profile(); |
|
179 iClipSession->iSession = CMceOutSession::NewL( |
|
180 *iClipSession->iManager, *profile, KTestRecipientSipUri8() ); |
|
181 |
|
182 iClipSession->CompleteSessionStructureL( *localBundle ); |
|
183 EUNIT_ASSERT( iClipSession->iSession->Streams().Count() == 3 ) |
|
184 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Type() == KMceVideo ) |
|
185 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Source() ) |
|
186 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Source()->Type() == |
|
187 KMceFileSource ) |
|
188 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Sinks().Count() == 1 ) |
|
189 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Sinks()[0]->Type() == |
|
190 KMceRTPSink ) |
|
191 |
|
192 // Check that only stream with speaker has been added to a bundle |
|
193 EUNIT_ASSERT( localBundle->Streams().Count() == 1 ) |
|
194 EUNIT_ASSERT( localBundle->Streams()[0]->Type() == KMceAudio ) |
|
195 EUNIT_ASSERT( localBundle->Streams()[0]->Sinks().Count() > 0 ) |
|
196 EUNIT_ASSERT( localBundle->Streams()[0]->Sinks()[0]->Type() == |
|
197 KMceSpeakerSink ) |
|
198 |
|
199 CleanupStack::PopAndDestroy( localBundle ); |
|
200 } |
|
201 |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // Although all states are not meaningfull for LiveSession, all states are |
|
205 // tested in order to force the updating of unit tests when behavior is changed |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void UT_CMusEngClipSession::UT_StreamStateChangedL() |
|
209 { |
|
210 // Try without a session, nothing happens |
|
211 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
212 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
213 *videoStream ); |
|
214 CleanupStack::PopAndDestroy( videoStream ); |
|
215 |
|
216 // Simulate sending invite |
|
217 iClipSession->EstablishLcSessionL(); |
|
218 |
|
219 // Try all the stream states |
|
220 CMceMediaStream* changedStream = iClipSession->iSession->Streams()[0]; |
|
221 |
|
222 // EUninitialized, stream is created, unexpected change, nothing happens |
|
223 changedStream->iState = CMceMediaStream::EUninitialized; |
|
224 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
225 *changedStream ); |
|
226 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
227 |
|
228 // EInitialized, stream is initialized |
|
229 changedStream->iState = CMceMediaStream::EInitialized; |
|
230 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
231 *changedStream ); |
|
232 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
233 |
|
234 // EBuffering, stream is buffering |
|
235 changedStream->iState = CMceMediaStream::EBuffering; |
|
236 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
237 *changedStream ); |
|
238 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
239 |
|
240 // EIdle, stream is not receiving RTP |
|
241 changedStream->iState = CMceMediaStream::EIdle; |
|
242 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
243 *changedStream ); |
|
244 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
245 |
|
246 // EStreaming, stream is streaming |
|
247 changedStream->iState = CMceMediaStream::EStreaming; |
|
248 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
249 *changedStream ); |
|
250 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
251 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
252 iLcSessionObserver->Reset(); |
|
253 |
|
254 // EDisabled, stream is explicitly disabled |
|
255 changedStream->iState = CMceMediaStream::EDisabled; |
|
256 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
257 *changedStream ); |
|
258 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
259 |
|
260 // ENoResources, stream has no needed resources to stream |
|
261 changedStream->iState = CMceMediaStream::ENoResources; |
|
262 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
263 *changedStream ); |
|
264 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
265 |
|
266 // ETranscodingRequired, stream requires non-realtime transcoding |
|
267 changedStream->iState = CMceMediaStream::ETranscodingRequired; |
|
268 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
269 *changedStream ); |
|
270 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
271 |
|
272 // ETranscoding, stream is transcoding in non-realtime |
|
273 changedStream->iState = CMceMediaStream::ETranscoding; |
|
274 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
275 *changedStream ); |
|
276 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
277 } |
|
278 |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // Although all states are not meaningfull for ClipSession, all states are |
|
282 // tested in order to force the updating of unit tests when behavior is changed |
|
283 // ----------------------------------------------------------------------------- |
|
284 // |
|
285 void UT_CMusEngClipSession::UT_StreamStateChangedWithSourceL() |
|
286 { |
|
287 // Try without a session, nothing happens |
|
288 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
289 CMceRtpSource* rtpSource = CMceRtpSource::NewLC(); |
|
290 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
291 *videoStream, |
|
292 *rtpSource ); |
|
293 CleanupStack::PopAndDestroy( rtpSource ); |
|
294 CleanupStack::PopAndDestroy( videoStream ); |
|
295 |
|
296 // Simulate sending invite |
|
297 iClipSession->EstablishLcSessionL(); |
|
298 |
|
299 // Try all the non-default stream states |
|
300 CMceMediaStream* changedStream = iClipSession->iSession->Streams()[0]; |
|
301 CMceMediaSource* changedSource = changedStream->Source(); |
|
302 |
|
303 // EDisabled, end of clip |
|
304 changedStream->iState = CMceMediaStream::EDisabled; |
|
305 changedSource->iIsEnabled = EFalse; |
|
306 iClipSession->StreamStateChanged( *changedStream, *changedSource ); |
|
307 |
|
308 // TODO: EUNIT_ASSERT( iLcSessionObserver->iEndOfClipCalled ) |
|
309 changedSource->iIsEnabled = ETrue; |
|
310 iLcSessionObserver->Reset(); |
|
311 |
|
312 // Test default stream state change behavior, remove or change when |
|
313 // behavior changes |
|
314 |
|
315 |
|
316 // EUninitialized, stream is created, unexpected change, nothing happens |
|
317 changedStream->iState = CMceMediaStream::EUninitialized; |
|
318 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
319 *changedStream, *changedSource ); |
|
320 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
321 |
|
322 // EInitialized, stream is initialized |
|
323 changedStream->iState = CMceMediaStream::EInitialized; |
|
324 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
325 *changedStream, *changedSource ); |
|
326 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
327 |
|
328 // Special meaning (Transcoding ready), tested separately |
|
329 |
|
330 // EBuffering, stream is buffering |
|
331 changedStream->iState = CMceMediaStream::EBuffering; |
|
332 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
333 *changedStream, *changedSource ); |
|
334 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
335 |
|
336 // EIdle, stream is not receiving RTP |
|
337 changedStream->iState = CMceMediaStream::EIdle; |
|
338 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
339 *changedStream, *changedSource ); |
|
340 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
341 |
|
342 // EStreaming, stream is streaming |
|
343 changedStream->iState = CMceMediaStream::EStreaming; |
|
344 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
345 *changedStream, *changedSource ); |
|
346 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
347 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
348 iLcSessionObserver->Reset(); |
|
349 |
|
350 // EDisabled, stream is explicitly disabled |
|
351 // This state has non-default meaning, tested before defaults |
|
352 |
|
353 // ENoResources, stream has no needed resources to stream |
|
354 changedStream->iState = CMceMediaStream::ENoResources; |
|
355 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
356 *changedStream, *changedSource ); |
|
357 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
358 } |
|
359 |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // Although all states are not meaningfull for LiveSession, all states are |
|
363 // tested in order to force the updating of unit tests when behavior is changed |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 void UT_CMusEngClipSession::UT_StreamStateChangedWithSinkL() |
|
367 { |
|
368 // Try without a session, nothing happens |
|
369 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
370 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
371 *videoStream, |
|
372 *CMceRtpSink::NewLC() ); |
|
373 CleanupStack::PopAndDestroy(); // rtp |
|
374 CleanupStack::PopAndDestroy( videoStream ); |
|
375 |
|
376 // Simulate sending invite |
|
377 iClipSession->EstablishLcSessionL(); |
|
378 |
|
379 // Test default stream state change behavior |
|
380 CMceMediaStream* changedStream = iClipSession->iSession->Streams()[0]; |
|
381 CMceMediaSink* changedSink = changedStream->Sinks()[0]; |
|
382 |
|
383 // EUninitialized, stream is created, unexpected change, nothing happens |
|
384 changedStream->iState = CMceMediaStream::EUninitialized; |
|
385 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
386 *changedStream, |
|
387 *changedSink ); |
|
388 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
389 |
|
390 // EInitialized, stream is initialized |
|
391 changedStream->iState = CMceMediaStream::EInitialized; |
|
392 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
393 *changedStream, |
|
394 *changedSink ); |
|
395 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
396 |
|
397 // EBuffering, stream is buffering |
|
398 changedStream->iState = CMceMediaStream::EBuffering; |
|
399 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
400 *changedStream, |
|
401 *changedSink ); |
|
402 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
403 |
|
404 // EIdle, stream is not receiving RTP |
|
405 changedStream->iState = CMceMediaStream::EIdle; |
|
406 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
407 *changedStream, |
|
408 *changedSink ); |
|
409 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
410 |
|
411 // EStreaming, stream is streaming |
|
412 changedStream->iState = CMceMediaStream::EStreaming; |
|
413 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
414 *changedStream, |
|
415 *changedSink ); |
|
416 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
417 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
418 iLcSessionObserver->Reset(); |
|
419 |
|
420 // EDisabled, stream is explicitly disabled |
|
421 changedStream->iState = CMceMediaStream::EDisabled; |
|
422 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
423 *changedStream, |
|
424 *changedSink ); |
|
425 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
426 |
|
427 // ENoResources, stream has no needed resources to stream |
|
428 changedStream->iState = CMceMediaStream::ENoResources; |
|
429 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
430 *changedStream, |
|
431 *changedSink ); |
|
432 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
433 |
|
434 // ETranscodingRequired, stream requires non-realtime transcoding |
|
435 changedStream->iState = CMceMediaStream::ETranscodingRequired; |
|
436 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
437 *changedStream, |
|
438 *changedSink ); |
|
439 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
440 |
|
441 // ETranscoding, stream is transcoding in non-realtime |
|
442 changedStream->iState = CMceMediaStream::ETranscoding; |
|
443 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
444 *changedStream, |
|
445 *changedSink ); |
|
446 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
447 } |
|
448 |
|
449 |
|
450 // ----------------------------------------------------------------------------- |
|
451 // |
|
452 // ----------------------------------------------------------------------------- |
|
453 // |
|
454 void UT_CMusEngClipSession::UT_AddAmrCodecLL() |
|
455 { |
|
456 // Check that all the codecs are replaced with AMR codec |
|
457 CMceAudioStream* audioStream = CMceAudioStream::NewLC(); |
|
458 |
|
459 audioStream->InitializeL( iClipSession->iManager ); |
|
460 |
|
461 EUNIT_ASSERT( audioStream->Codecs().Count() == 2 ) |
|
462 |
|
463 iClipSession->AddAmrCodecL( *audioStream ); |
|
464 |
|
465 EUNIT_ASSERT( audioStream->Codecs().Count() == 1 ) |
|
466 EUNIT_ASSERT( audioStream->Codecs()[0]->SdpName() == KMceSDPNameAMR() ) |
|
467 EUNIT_ASSERT( audioStream->Codecs()[0]->AllowedBitrates() == |
|
468 KMceAllowedAmrNbBitrate475 ) |
|
469 EUNIT_ASSERT( audioStream->Codecs()[0]->Bitrate() == |
|
470 KMceAmrNbBitrate475 ) |
|
471 |
|
472 // Check that function leaves if there is no AMR codec |
|
473 |
|
474 iClipSession->iManager->iSupportedAudioCodecs.ResetAndDestroy(); |
|
475 |
|
476 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->AddAmrCodecL( *audioStream ), |
|
477 KErrNotFound ) |
|
478 |
|
479 CleanupStack::PopAndDestroy( audioStream ); |
|
480 } |
|
481 |
|
482 |
|
483 // ----------------------------------------------------------------------------- |
|
484 // |
|
485 // ----------------------------------------------------------------------------- |
|
486 // |
|
487 void UT_CMusEngClipSession::UT_AddVideoCodecLL() |
|
488 { |
|
489 // Check that all the codecs are replaced with H263 codec if other end |
|
490 // does not support H264 |
|
491 // |
|
492 delete iClipSession->iVideoCodecList; |
|
493 iClipSession->iVideoCodecList = NULL; |
|
494 iClipSession->iVideoCodecList = KMceSDPNameH263().AllocL(); |
|
495 |
|
496 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
497 |
|
498 videoStream->InitializeL( iClipSession->iManager ); |
|
499 |
|
500 EUNIT_ASSERT( videoStream->Codecs().Count() > 1 ) |
|
501 |
|
502 iClipSession->AddVideoCodecL( *videoStream ); |
|
503 |
|
504 EUNIT_ASSERT( videoStream->Codecs().Count() == 1 ) |
|
505 EUNIT_ASSERT( videoStream->Codecs()[0]->SdpName() == KMceSDPNameH2632000() ) |
|
506 |
|
507 // Check that all codecs are replaced with H264 codec if other end |
|
508 // supports it |
|
509 // |
|
510 _LIT8( KMusTestCodecListDelim, ";" ); |
|
511 delete iClipSession->iVideoCodecList; |
|
512 iClipSession->iVideoCodecList = NULL; |
|
513 iClipSession->iVideoCodecList = |
|
514 HBufC8::NewL( KMceSDPNameH263().Length() + |
|
515 KMceSDPNameH264().Length() + |
|
516 KMusTestCodecListDelim().Length() ); |
|
517 iClipSession->iVideoCodecList->Des().Copy( KMceSDPNameH263() ); |
|
518 iClipSession->iVideoCodecList->Des().Append( KMusTestCodecListDelim() ); |
|
519 iClipSession->iVideoCodecList->Des().Append( KMceSDPNameH264() ); |
|
520 iClipSession->AddVideoCodecL( *videoStream ); |
|
521 |
|
522 EUNIT_ASSERT( videoStream->Codecs().Count() == 1 ) |
|
523 EUNIT_ASSERT( videoStream->Codecs()[0]->SdpName() == KMceSDPNameH264() ) |
|
524 |
|
525 // Check that function leaves if there is no H264 codec |
|
526 // |
|
527 iClipSession->iManager->iSupportedVideoCodecs.ResetAndDestroy(); |
|
528 |
|
529 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->AddVideoCodecL( *videoStream ), |
|
530 KErrNotFound ) |
|
531 |
|
532 CleanupStack::PopAndDestroy( videoStream ); |
|
533 } |
|
534 |
|
535 |
|
536 // ----------------------------------------------------------------------------- |
|
537 // |
|
538 // ----------------------------------------------------------------------------- |
|
539 // |
|
540 void UT_CMusEngClipSession::UT_ConstructAudioStructureLL() |
|
541 { |
|
542 |
|
543 CMceStreamBundle* localBundle = |
|
544 CMceStreamBundle::NewLC( CMceStreamBundle::ELS ); |
|
545 |
|
546 // Check that audio structure cannot be constructed before |
|
547 // creating the session |
|
548 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
549 iClipSession->ConstructAudioStructureL( *localBundle ), |
|
550 KErrNotReady ) |
|
551 |
|
552 // Try without a file source |
|
553 |
|
554 CSIPProfile* profile = iClipSession->iSipProfileHandler->Profile(); |
|
555 |
|
556 iClipSession->iSession = CMceOutSession::NewL( |
|
557 *(iClipSession->iManager), |
|
558 *profile, |
|
559 KTestRecipientSipUri8() ); |
|
560 |
|
561 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
562 iClipSession->ConstructAudioStructureL( *localBundle ), |
|
563 KErrNotFound ) |
|
564 |
|
565 // Normal case |
|
566 |
|
567 CMceVideoStream* videoOut = CMceVideoStream::NewLC(); |
|
568 |
|
569 videoOut->AddSinkL( CMceRtpSink::NewLC() ); |
|
570 CleanupStack::Pop(); |
|
571 |
|
572 videoOut->SetSourceL( CMceFileSource::NewLC( |
|
573 *iClipSession->iManager, |
|
574 iClipSession->LocalVideoPlayer()->LcSourceFileControl()->LcFileName() ) ); |
|
575 CleanupStack::Pop(); |
|
576 |
|
577 iClipSession->iSession->AddStreamL( videoOut ); |
|
578 CleanupStack::Pop( videoOut ); |
|
579 |
|
580 iClipSession->ConstructAudioStructureL( *localBundle ); |
|
581 |
|
582 EUNIT_ASSERT( iClipSession->iSession->Streams().Count() == 3 ) |
|
583 EUNIT_ASSERT( iClipSession->iSession->Streams()[1]->Type() == KMceAudio ) |
|
584 EUNIT_ASSERT( iClipSession->iSession->Streams()[2]->Type() == KMceAudio ) |
|
585 EUNIT_ASSERT( iClipSession->iSession->Streams()[1]->Source() == |
|
586 videoOut->Source() ) |
|
587 EUNIT_ASSERT( iClipSession->iSession->Streams()[2]->Source() == |
|
588 videoOut->Source() ) |
|
589 EUNIT_ASSERT( iClipSession->iSession->Streams()[1]->Sinks().Count() == 1 ) |
|
590 EUNIT_ASSERT( iClipSession->iSession->Streams()[2]->Sinks().Count() == 1 ) |
|
591 EUNIT_ASSERT( iClipSession->iSession->Streams()[1]->Sinks()[0]->Type() == |
|
592 KMceRTPSink ) |
|
593 EUNIT_ASSERT( iClipSession->iSession->Streams()[2]->Sinks()[0]->Type() == |
|
594 KMceSpeakerSink ) |
|
595 |
|
596 // Check that only stream with speaker has been added to a bundle |
|
597 EUNIT_ASSERT( localBundle->Streams().Count() == 1 ) |
|
598 EUNIT_ASSERT( localBundle->Streams()[0]->Type() == KMceAudio ) |
|
599 EUNIT_ASSERT( localBundle->Streams()[0]->Sinks().Count() == 1 ) |
|
600 EUNIT_ASSERT( localBundle->Streams()[0]->Sinks()[0]->Type() == |
|
601 KMceSpeakerSink ) |
|
602 |
|
603 CleanupStack::PopAndDestroy( localBundle ); |
|
604 } |
|
605 |
|
606 |
|
607 // ----------------------------------------------------------------------------- |
|
608 // Check that audio is not constructed in operator variant |
|
609 // ----------------------------------------------------------------------------- |
|
610 // |
|
611 void UT_CMusEngClipSession::UT_ConstructAudioStructureL_OperatorVariantL() |
|
612 { |
|
613 iClipSession->iOperatorVariant = ETrue; |
|
614 CSIPProfile* profile = iClipSession->iSipProfileHandler->Profile(); |
|
615 delete profile->iArray; |
|
616 profile->iArray = NULL; |
|
617 profile->iArray = new ( ELeave ) CDesC8ArrayFlat( 1 ); |
|
618 profile->iArray->AppendL( KMusSipUri ); |
|
619 |
|
620 // Establish session, ConstructAudioStructureL gets called |
|
621 ESTABLISH_OUT_SESSION( iClipSession ); |
|
622 |
|
623 // Check that only two video streams has been constructed |
|
624 EUNIT_ASSERT_EQUALS( iClipSession->iSession->Streams().Count(), 2 ) |
|
625 EUNIT_ASSERT_EQUALS( iClipSession->iSession->Streams()[0]->Type(), |
|
626 KMceVideo ) |
|
627 EUNIT_ASSERT_EQUALS( iClipSession->iSession->Streams()[1]->Type(), |
|
628 KMceVideo ) |
|
629 |
|
630 // Check that no bundles has been constructed |
|
631 EUNIT_ASSERT_EQUALS( iClipSession->iSession->Bundles().Count(), 0 ) |
|
632 } |
|
633 |
|
634 |
|
635 // ----------------------------------------------------------------------------- |
|
636 // |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 void UT_CMusEngClipSession::UT_EstablishSessionLL() |
|
640 { |
|
641 iClipSession->LocalVideoPlayer()->LcSourceFileControl()->SetLcFileNameL( |
|
642 KTestAvcVideoFileName() ); |
|
643 |
|
644 // Try to establish, must fail, because of missing session |
|
645 TRAPD( error, iClipSession->EstablishSessionL() ); |
|
646 MUS_TEST_FORWARD_ALLOC_FAILURE( error ); |
|
647 EUNIT_ASSERT( error == KErrNotReady ); |
|
648 |
|
649 EUNIT_ASSERT( iClipSession->iVideoCodecList ); |
|
650 |
|
651 /////// |
|
652 // 1.Test that in case the peer party supports H264, no transcoding is needed |
|
653 |
|
654 // Call to CMusEngOutMceSession::InviteL leads to call to EstablishL |
|
655 iClipSession->EstablishLcSessionL(); |
|
656 |
|
657 const RPointerArray<CMceMediaStream>& streams = iClipSession->iSession->Streams(); |
|
658 |
|
659 for ( TInt i = 0; i < streams.Count(); ++i ) |
|
660 { |
|
661 if ( streams[i]->Type() == KMceVideo ) |
|
662 { |
|
663 |
|
664 CMceVideoStream* videoStream = static_cast<CMceVideoStream*>( streams[i] ); |
|
665 const RPointerArray<CMceVideoCodec> codecs = videoStream->Codecs(); |
|
666 EUNIT_ASSERT_EQUALS( codecs.Count(), 1 ) |
|
667 EUNIT_ASSERT( codecs[0]->SdpName().FindF( KMceSDPNameH264() ) >= 0 ) |
|
668 |
|
669 } |
|
670 } |
|
671 |
|
672 /////// |
|
673 // 2.Test the case when we don't know whether peer supports H264, |
|
674 // transcoding is needed => function will leave with KErrNotSupported |
|
675 |
|
676 delete iClipSession->iSession; |
|
677 iClipSession->iSession = NULL; |
|
678 |
|
679 delete iClipSession->iVideoCodecList; |
|
680 iClipSession->iVideoCodecList = NULL; |
|
681 |
|
682 MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
683 iClipSession->EstablishLcSessionL(), |
|
684 KErrNotSupported ) |
|
685 |
|
686 |
|
687 /////// |
|
688 // 3.Test that if peer doesn't supports H264, transcoding is needed |
|
689 // => function will leave with KErrNotSupported |
|
690 |
|
691 delete iClipSession->iSession; |
|
692 iClipSession->iSession = NULL; |
|
693 |
|
694 iClipSession->iVideoCodecList = KMceSDPNameH263().AllocL(); |
|
695 |
|
696 MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
697 iClipSession->EstablishLcSessionL(), |
|
698 KErrNotSupported ) |
|
699 } |
|
700 |
|
701 |
|
702 // TEST TABLE |
|
703 |
|
704 EUNIT_BEGIN_TEST_TABLE( |
|
705 UT_CMusEngClipSession, |
|
706 "UT_CMusEngClipSesssion", |
|
707 "UNIT" ) |
|
708 |
|
709 EUNIT_TEST( |
|
710 "NewL - test ", |
|
711 "CMusEngClipSession", |
|
712 "NewL", |
|
713 "FUNCTIONALITY", |
|
714 SetupL, UT_NewLL, Teardown) |
|
715 |
|
716 EUNIT_TEST( |
|
717 "CompleteSessionStructureL - test ", |
|
718 "CMusEngClipSession", |
|
719 "CompleteSessionStructureL", |
|
720 "FUNCTIONALITY", |
|
721 SetupL, UT_CompleteSessionStructureLL, Teardown) |
|
722 |
|
723 EUNIT_TEST( |
|
724 "StreamStateChangedL() - test ", |
|
725 "CMusEngClipSession", |
|
726 "StreamStateChangedL()", |
|
727 "FUNCTIONALITY", |
|
728 SetupL, UT_StreamStateChangedL, Teardown) |
|
729 |
|
730 EUNIT_TEST( |
|
731 "StreamStateChangedL( source ) - test ", |
|
732 "CMusEngClipSession", |
|
733 "StreamStateChangedL( source )", |
|
734 "FUNCTIONALITY", |
|
735 SetupL, UT_StreamStateChangedWithSourceL, Teardown) |
|
736 |
|
737 EUNIT_TEST( |
|
738 "StreamStateChangedL( sink ) - test ", |
|
739 "CMusEngClipSession", |
|
740 "StreamStateChangedL( sink )", |
|
741 "FUNCTIONALITY", |
|
742 SetupL, UT_StreamStateChangedWithSinkL, Teardown) |
|
743 |
|
744 EUNIT_TEST( |
|
745 "AddAmrCodecL - test ", |
|
746 "CMusEngClipSession", |
|
747 "AddAmrCodecL", |
|
748 "FUNCTIONALITY", |
|
749 SetupL, UT_AddAmrCodecLL, Teardown) |
|
750 |
|
751 EUNIT_TEST( |
|
752 "AddVideoCodecL - test ", |
|
753 "CMusEngClipSession", |
|
754 "AddVideoCodecL", |
|
755 "FUNCTIONALITY", |
|
756 SetupL, UT_AddVideoCodecLL, Teardown) |
|
757 |
|
758 EUNIT_TEST( |
|
759 "ConstructAudioStructureL - test ", |
|
760 "CMusEngClipSession", |
|
761 "ConstructAudioStructureL", |
|
762 "FUNCTIONALITY", |
|
763 SetupL, UT_ConstructAudioStructureLL, Teardown) |
|
764 |
|
765 EUNIT_TEST( |
|
766 "ConstructAudioStructureL - test operator specific behavior ", |
|
767 "CMusEngClipSession", |
|
768 "ConstructAudioStructureL", |
|
769 "FUNCTIONALITY", |
|
770 SetupL, UT_ConstructAudioStructureL_OperatorVariantL, Teardown) |
|
771 |
|
772 EUNIT_TEST( |
|
773 "EstablishSessionL - test ", |
|
774 "CMusEngClipSession", |
|
775 "EstablishSessionL", |
|
776 "FUNCTIONALITY", |
|
777 SetupL, UT_EstablishSessionLL, Teardown) |
|
778 |
|
779 |
|
780 EUNIT_END_TEST_TABLE |
|
781 |
|
782 // END OF FILE |
|
783 |
|
784 |