104 // |
107 // |
105 // ----------------------------------------------------------------------------- |
108 // ----------------------------------------------------------------------------- |
106 // |
109 // |
107 void UT_CMusEngClipSession::SetupL() |
110 void UT_CMusEngClipSession::SetupL() |
108 { |
111 { |
109 iObserver = new( ELeave ) CMusEngObserverStub; |
112 iLcSessionObserver = new( ELeave )CLcSessionObserverStub; |
110 iClipSession = CMusEngClipSession::NewL( TRect(0,0, 100,100), |
113 iLcUiProvider = new( ELeave )CLcUiProviderStub; |
111 *iObserver, |
114 iAudioRoutingObserver = new( ELeave )CMusEngObserverStub; |
112 *iObserver, |
115 |
113 *iObserver ); |
116 iClipSession = CMusEngClipSession::NewL(); |
114 iClipSession->SetClipL( KTestVideoFileName ); |
117 iClipSession->SetLcSessionObserver( iLcSessionObserver ); |
|
118 iClipSession->SetLcUiProvider( iLcUiProvider ); |
|
119 iClipSession->LocalVideoPlayer()->LcSourceFileControl()->SetLcFileNameL( |
|
120 KTestVideoFileName() ); |
|
121 delete iClipSession->iVideoCodecList; |
|
122 iClipSession->iVideoCodecList = NULL; |
115 iClipSession->iVideoCodecList = KMceSDPNameH264().AllocL(); |
123 iClipSession->iVideoCodecList = KMceSDPNameH264().AllocL(); |
116 |
124 |
117 SIPStrings::OpenL(); |
125 SIPStrings::OpenL(); |
118 } |
126 |
119 |
127 User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, |
120 // ----------------------------------------------------------------------------- |
128 NMusSessionApi::KRemoteSipAddress, |
121 // |
129 KTestRecipientSipUri ) ); |
122 // ----------------------------------------------------------------------------- |
130 } |
123 // |
131 |
124 void UT_CMusEngClipSession::Setup2L() |
|
125 { |
|
126 iObserver = new( ELeave ) CMusEngObserverStub; |
|
127 iClipSession = CMusEngClipSession::NewL( TRect(0,0, 100,100), |
|
128 *iObserver, |
|
129 *iObserver, |
|
130 *iObserver ); |
|
131 iClipSession->SetClipL( KTestVideoFileName ); |
|
132 iClipSession->iVideoCodecList = KMceSDPNameH263().AllocL(); |
|
133 |
|
134 SIPStrings::OpenL(); |
|
135 } |
|
136 |
132 |
137 // ----------------------------------------------------------------------------- |
133 // ----------------------------------------------------------------------------- |
138 // |
134 // |
139 // ----------------------------------------------------------------------------- |
135 // ----------------------------------------------------------------------------- |
140 // |
136 // |
141 void UT_CMusEngClipSession::Teardown() |
137 void UT_CMusEngClipSession::Teardown() |
142 { |
138 { |
143 SIPStrings::Close(); |
139 SIPStrings::Close(); |
144 delete iClipSession; |
140 delete iClipSession; |
145 delete iObserver; |
141 delete iLcSessionObserver; |
|
142 delete iLcUiProvider; |
|
143 delete iAudioRoutingObserver; |
|
144 PropertyHelper::Close(); |
146 } |
145 } |
147 |
146 |
148 |
147 |
149 |
148 |
150 // TEST CASES |
149 // TEST CASES |
151 |
150 |
152 |
|
153 // ----------------------------------------------------------------------------- |
151 // ----------------------------------------------------------------------------- |
154 // |
152 // |
155 // ----------------------------------------------------------------------------- |
153 // ----------------------------------------------------------------------------- |
156 // |
154 // |
157 void UT_CMusEngClipSession::UT_NewLL() |
155 void UT_CMusEngClipSession::UT_NewLL() |
158 { |
156 { |
159 EUNIT_ASSERT( iClipSession ) |
157 EUNIT_ASSERT( iClipSession ) |
160 EUNIT_ASSERT( iClipSession->iFileName != KNullDesC() ) |
|
161 EUNIT_ASSERT( !iClipSession->iSession ) |
158 EUNIT_ASSERT( !iClipSession->iSession ) |
162 } |
159 EUNIT_ASSERT( iClipSession->iMceManagerUid == TUid::Uid( KMusUiUid ) ); |
163 |
160 } |
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void UT_CMusEngClipSession::UT_SetClipLL() |
|
170 { |
|
171 // Try with protected file, cannot use EUNIT_ASSERT_SPECIFIC_LEAVE |
|
172 TRAPD( error, iClipSession->SetClipL( KMusDrmProtectedFileName() ) ) |
|
173 MUS_TEST_FORWARD_ALLOC_FAILURE( error ); |
|
174 EUNIT_ASSERT( error == KErrPermissionDenied ) |
|
175 EUNIT_ASSERT_EQUALS( iClipSession->iFileName, KTestVideoFileName() ) |
|
176 |
|
177 // Change the file before session is established |
|
178 iClipSession->SetClipL( KTestAvcVideoFileName() ); |
|
179 EUNIT_ASSERT_EQUALS( iClipSession->iFileName, KTestAvcVideoFileName() ) |
|
180 EUNIT_ASSERT( !iClipSession->iSession ) |
|
181 |
|
182 // simulate session establishment |
|
183 ESTABLISH_OUT_SESSION( iClipSession ); |
|
184 |
|
185 // Now test with established session |
|
186 iClipSession->SetClipL( KTestVideoFileName() ); |
|
187 |
|
188 CMceFileSource* file = |
|
189 MusEngMceUtils::GetFileSourceL( *iClipSession->iSession ); |
|
190 |
|
191 EUNIT_ASSERT_EQUALS( iClipSession->iFileName, KTestVideoFileName() ) |
|
192 EUNIT_ASSERT_EQUALS( file->iFileName, KTestVideoFileName() ) |
|
193 |
|
194 |
|
195 } |
|
196 |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 void UT_CMusEngClipSession::UT_FastForwardLL() |
|
203 { |
|
204 // Try before establishment |
|
205 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->FastForwardL( ETrue ), |
|
206 KErrNotReady ) |
|
207 |
|
208 // Establish session, simulate position and duration and try again |
|
209 ESTABLISH_OUT_SESSION( iClipSession ); |
|
210 |
|
211 CMceFileSource* file = |
|
212 MusEngMceUtils::GetFileSourceL( *iClipSession->iSession ); |
|
213 |
|
214 file->iDuration = KMusEngTestFileDuration; |
|
215 file->iPosition = KMusEngTestFilePosition; |
|
216 |
|
217 iClipSession->FastForwardL( ETrue ); |
|
218 |
|
219 EUNIT_ASSERT( !file->iIsEnabled ) |
|
220 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() > 0 ) |
|
221 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() == 0 ) |
|
222 |
|
223 // Simulate fastforwarding for a while |
|
224 User::After( 1000 ); |
|
225 |
|
226 // Try to fastforward when already fastforwarding, will be ignored |
|
227 iClipSession->FastForwardL( ETrue ); |
|
228 EUNIT_ASSERT( !file->iIsEnabled ) |
|
229 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() > 0 ) |
|
230 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() == 0 ) |
|
231 |
|
232 // Stop fastforwarding |
|
233 iClipSession->FastForwardL( EFalse ); |
|
234 EUNIT_ASSERT( file->iPosition > KMusEngTestFilePosition ) |
|
235 EUNIT_ASSERT( file->iPosition != file->iDuration ) |
|
236 EUNIT_ASSERT( !file->iIsEnabled ) |
|
237 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() == 0 ) |
|
238 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() == 0 ) |
|
239 |
|
240 // Try to stop fastforwarding again, leaves |
|
241 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->FastForwardL( EFalse ), |
|
242 KErrAlreadyExists ) |
|
243 |
|
244 // Start fastrewinding |
|
245 iClipSession->FastRewindL( ETrue ); |
|
246 EUNIT_ASSERT( !file->iIsEnabled ) |
|
247 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() == 0 ) |
|
248 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() > 0 ) |
|
249 |
|
250 // Start fastforwarding, rewinding should be stopped and FFWD started |
|
251 iClipSession->FastForwardL( ETrue ); |
|
252 EUNIT_ASSERT( !file->iIsEnabled ) |
|
253 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() > 0 ) |
|
254 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() == 0 ) |
|
255 |
|
256 // Simulate fastforwarding for a while |
|
257 User::After( 1000 ); |
|
258 |
|
259 // Simulate that clip is almost in end and fastforwarding would have |
|
260 // continued over end, position should be set to duration. |
|
261 |
|
262 file->iPosition = TTimeIntervalMicroSeconds( file->iDuration.Int64() - 1 ); |
|
263 |
|
264 iClipSession->FastForwardL( EFalse ); |
|
265 EUNIT_ASSERT( file->iPosition == file->iDuration ) |
|
266 EUNIT_ASSERT( !file->iIsEnabled ) |
|
267 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() == 0 ) |
|
268 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() == 0 ) |
|
269 |
|
270 } |
|
271 |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 void UT_CMusEngClipSession::UT_FastRewindLL() |
|
278 { |
|
279 // Try before establishment |
|
280 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->FastRewindL( ETrue ), |
|
281 KErrNotReady ) |
|
282 |
|
283 // Establish session, simulate position and duration and try again |
|
284 ESTABLISH_OUT_SESSION( iClipSession ); |
|
285 |
|
286 CMceFileSource* file = |
|
287 MusEngMceUtils::GetFileSourceL( *iClipSession->iSession ); |
|
288 |
|
289 file->iDuration = KMusEngTestFileDuration; |
|
290 file->iPosition = KMusEngTestFilePosition; |
|
291 |
|
292 iClipSession->FastRewindL( ETrue ); |
|
293 |
|
294 EUNIT_ASSERT( !file->iIsEnabled ) |
|
295 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() == 0 ) |
|
296 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() > 0 ) |
|
297 |
|
298 // Simulate fastrewinding for a while |
|
299 User::After( 1000 ); |
|
300 |
|
301 // Try to fastrewind when already fastrewinding, will be ignored |
|
302 iClipSession->FastRewindL( ETrue ); |
|
303 EUNIT_ASSERT( !file->iIsEnabled ) |
|
304 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() == 0 ) |
|
305 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() > 0 ) |
|
306 |
|
307 // Stop fastrewinding |
|
308 iClipSession->FastRewindL( EFalse ); |
|
309 EUNIT_ASSERT( file->iPosition < KMusEngTestFilePosition ) |
|
310 EUNIT_ASSERT( file->iPosition != TTimeIntervalMicroSeconds( 0 ) ) |
|
311 EUNIT_ASSERT( !file->iIsEnabled ) |
|
312 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() == 0 ) |
|
313 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() == 0 ) |
|
314 |
|
315 // Try to stop fastrewinding again, leaves |
|
316 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->FastRewindL( EFalse ), |
|
317 KErrAlreadyExists ) |
|
318 |
|
319 // Start fastforwarding |
|
320 iClipSession->FastForwardL( ETrue ); |
|
321 EUNIT_ASSERT( !file->iIsEnabled ) |
|
322 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() >= 0 ) |
|
323 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() == 0 ) |
|
324 |
|
325 // Start fastrewinding, forwarding should be stopped and FFWD started |
|
326 iClipSession->FastRewindL( ETrue ); |
|
327 EUNIT_ASSERT( !file->iIsEnabled ); |
|
328 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() == 0 ) |
|
329 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() >= 0 ) |
|
330 |
|
331 // Simulate that clip has just begun and fastrewinding would have |
|
332 // continued over beginning, position should be set to zero. |
|
333 |
|
334 file->iPosition = TTimeIntervalMicroSeconds( 1 ); |
|
335 |
|
336 // Simulate fastrewinding for a while |
|
337 User::After( 1000 ); |
|
338 |
|
339 iClipSession->FastRewindL( EFalse ); |
|
340 EUNIT_ASSERT( file->iPosition == TTimeIntervalMicroSeconds( 0 ) ) |
|
341 EUNIT_ASSERT( !file->iIsEnabled ) |
|
342 EUNIT_ASSERT( iClipSession->iFFWDStartTime.Int64() == 0 ) |
|
343 EUNIT_ASSERT( iClipSession->iFRWDStartTime.Int64() == 0 ) |
|
344 } |
|
345 |
|
346 |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 void UT_CMusEngClipSession::UT_PositionLL() |
|
352 { |
|
353 // Try before establishment |
|
354 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->PositionL(), KErrNotReady ) |
|
355 |
|
356 // Establish session and try again |
|
357 ESTABLISH_OUT_SESSION( iClipSession ); |
|
358 |
|
359 CMceFileSource* file = |
|
360 MusEngMceUtils::GetFileSourceL( *iClipSession->iSession ); |
|
361 file->iPosition = 2000000; |
|
362 |
|
363 EUNIT_ASSERT( iClipSession->PositionL().Int() * 1000000 == |
|
364 file->iPosition.Int64() ) |
|
365 |
|
366 // Ask position while fastforwarding, it should be bigger than real position |
|
367 iClipSession->FastForwardL( ETrue ); |
|
368 |
|
369 User::After( 1000000 ); // We have to wait since dividing in PositionL and |
|
370 // multiplying before comparison loses difference |
|
371 |
|
372 EUNIT_ASSERT( iClipSession->PositionL().Int() * 1000000 > |
|
373 file->iPosition.Int64() ) |
|
374 |
|
375 // Ask position while fastforwarding beyond end of clip, clip duration is |
|
376 // returned |
|
377 file->iPosition = file->iDuration; |
|
378 |
|
379 EUNIT_ASSERT( iClipSession->PositionL().Int() * 1000000 == |
|
380 file->iDuration.Int64() ) |
|
381 |
|
382 // Stop fastforwarding, start fastrewinding, position is set to the end clip |
|
383 iClipSession->FastForwardL( EFalse ); |
|
384 iClipSession->FastRewindL( ETrue ); |
|
385 |
|
386 User::After( 1000000 ); // We have to wait since dividing in PositionL and |
|
387 // multiplying before comparison loses difference |
|
388 |
|
389 // Ask position while fastrewinding, it should be smaller than real |
|
390 // position |
|
391 EUNIT_ASSERT( iClipSession->PositionL().Int() * 1000000 < |
|
392 file->iPosition.Int64() ) |
|
393 |
|
394 // Ask position while fastrewinding beyond the beginning of clip, zero |
|
395 // returned |
|
396 file->iPosition = 0; |
|
397 |
|
398 EUNIT_ASSERT( iClipSession->PositionL().Int() * 1000000 == 0 ) |
|
399 |
|
400 // Asking position when rewinded to beginning but rewinding has ended |
|
401 // and clip has not ended (position should not be altered in that case) |
|
402 iClipSession->iRewindedToBeginning = ETrue; |
|
403 file->iPosition = 0; |
|
404 iClipSession->iFRWDStartTime = TTime( 0 ); |
|
405 |
|
406 EUNIT_ASSERT( iClipSession->PositionL().Int() * 1000000 == 0 ) |
|
407 |
|
408 // Position has proceeded from beginning, rewinding to beginning info |
|
409 // is cleared. |
|
410 file->iPosition = 10000000; |
|
411 iClipSession->iFRWDStartTime = TTime( 0 ); |
|
412 iClipSession->iRewindedToBeginning = EFalse; |
|
413 EUNIT_ASSERT( iClipSession->PositionL().Int() * 1000000 == 10000000 ) |
|
414 EUNIT_ASSERT( iClipSession->iRewindedToBeginning == EFalse ) |
|
415 } |
|
416 |
|
417 |
|
418 // ----------------------------------------------------------------------------- |
|
419 // |
|
420 // ----------------------------------------------------------------------------- |
|
421 // |
|
422 void UT_CMusEngClipSession::UT_DurationLL() |
|
423 { |
|
424 // Try before establishment |
|
425 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->DurationL(), KErrNotReady ) |
|
426 |
|
427 // Establish session and try again |
|
428 ESTABLISH_OUT_SESSION( iClipSession ); |
|
429 |
|
430 CMceFileSource* file = |
|
431 MusEngMceUtils::GetFileSourceL( *iClipSession->iSession ); |
|
432 file->iDuration = 2000000; |
|
433 |
|
434 EUNIT_ASSERT( iClipSession->DurationL().Int() * 1000000 == |
|
435 file->iDuration.Int64() ) |
|
436 } |
|
437 |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 void UT_CMusEngClipSession::UT_SetPositionLL() |
|
444 { |
|
445 TTimeIntervalSeconds time( 20 ); |
|
446 |
|
447 // Try before establishment |
|
448 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->SetPositionL( time ), |
|
449 KErrNotReady ) |
|
450 |
|
451 // Normal case with already disabled file source |
|
452 ESTABLISH_OUT_SESSION( iClipSession ); |
|
453 |
|
454 CMceFileSource* file = |
|
455 MusEngMceUtils::GetFileSourceL( *iClipSession->iSession ); |
|
456 file->iIsEnabled = EFalse; |
|
457 |
|
458 iClipSession->SetPositionL( time ); |
|
459 |
|
460 EUNIT_ASSERT( file->iPosition.Int64() == |
|
461 static_cast<TInt64>(time.Int()) * 1000000 ) |
|
462 EUNIT_ASSERT( !file->iIsEnabled ) |
|
463 |
|
464 // Normal case with enabled file source |
|
465 TTimeIntervalSeconds anotherTime( 30 ); |
|
466 |
|
467 file->iIsEnabled = ETrue; |
|
468 iClipSession->SetPositionL( anotherTime ); |
|
469 |
|
470 EUNIT_ASSERT( file->iPosition.Int64() == |
|
471 static_cast<TInt64>(anotherTime.Int()) * 1000000 ) |
|
472 EUNIT_ASSERT( file->iIsEnabled ) |
|
473 } |
|
474 |
|
475 |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 // ----------------------------------------------------------------------------- |
|
479 // |
|
480 void UT_CMusEngClipSession::UT_TranscodeLToAvcL() |
|
481 { |
|
482 // Check that transcoding is not possible before invite |
|
483 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
484 iClipSession->TranscodeL( KTestVideoFileName() ), |
|
485 KErrNotReady ) |
|
486 |
|
487 // Construct session with video and audio streams that must transcoded |
|
488 |
|
489 CSIPProfile* profile = iClipSession->iSipProfileHandler->Profile(); |
|
490 |
|
491 iClipSession->iSession = CMceOutSession::NewL( |
|
492 *(iClipSession->iManager), |
|
493 *profile, |
|
494 KTestRecipientSipUri8() ); |
|
495 |
|
496 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
497 |
|
498 CMceRtpSink* rtpsink = CMceRtpSink::NewLC(); |
|
499 videoStream->AddSinkL( rtpsink ); |
|
500 CleanupStack::Pop( rtpsink ); |
|
501 |
|
502 CMceFileSource* fileSource = |
|
503 CMceFileSource::NewLC( *iClipSession->iManager, KTestAvcVideoFileName() ); |
|
504 videoStream->SetSourceL( fileSource ); |
|
505 CleanupStack::Pop( fileSource ); |
|
506 |
|
507 iClipSession->iSession->AddStreamL( videoStream ); |
|
508 CleanupStack::Pop( videoStream ); |
|
509 |
|
510 CMceAudioStream* audioStream = CMceAudioStream::NewLC(); |
|
511 |
161 |
512 audioStream->AddSinkL( CMceRtpSink::NewLC() ); |
|
513 CleanupStack::Pop(); |
|
514 |
|
515 audioStream->SetSourceL( fileSource ); |
|
516 |
|
517 iClipSession->iSession->AddStreamL( audioStream ); |
|
518 CleanupStack::Pop( audioStream ); |
|
519 |
|
520 videoStream->iState = CMceMediaStream::ETranscodingRequired; |
|
521 audioStream->iState = CMceMediaStream::ETranscodingRequired; |
|
522 |
|
523 // Remove all codecs (file has some unknown codec type) |
|
524 RPointerArray<CMceVideoCodec> videoCodecs = videoStream->Codecs(); |
|
525 for ( TInt i = 0; i < videoCodecs.Count(); i++ ) |
|
526 { |
|
527 videoStream->RemoveCodecL( *videoCodecs[ i ] ); |
|
528 } |
|
529 RPointerArray<CMceVideoCodec> videoCodecs2 = videoStream->Codecs(); |
|
530 EUNIT_ASSERT_EQUALS( videoCodecs2.Count(), 0 ) |
|
531 EUNIT_ASSERT( audioStream->Codecs().Count() > 1 ) |
|
532 |
|
533 // Add some stream which must not be transcoded |
|
534 |
|
535 CMceAudioStream* inStream = CMceAudioStream::NewLC(); |
|
536 |
|
537 inStream->AddSinkL( CMceSpeakerSink::NewLC() ); |
|
538 CleanupStack::Pop(); |
|
539 |
|
540 inStream->SetSourceL( CMceRtpSource::NewLC() ); |
|
541 CleanupStack::Pop(); |
|
542 |
|
543 iClipSession->iSession->AddStreamL( inStream ); |
|
544 CleanupStack::Pop( inStream ); |
|
545 |
|
546 // Transcode |
|
547 iClipSession->TranscodeL( KTestAvcVideoFileName() ); |
|
548 |
|
549 // Check that transcoding has begun (transcoding to AVC as we know |
|
550 // that other end supports it |
|
551 EUNIT_ASSERT( iClipSession->iTranscodingOngoing ) |
|
552 EUNIT_ASSERT( videoStream->State() == CMceMediaStream::ETranscoding ) |
|
553 EUNIT_ASSERT( audioStream->State() == CMceMediaStream::ETranscoding ) |
|
554 EUNIT_ASSERT( inStream->State() != CMceMediaStream::ETranscoding ) |
|
555 |
|
556 // Check that codecs have been replaced |
|
557 const RPointerArray<CMceVideoCodec> videoCodecs3 = videoStream->Codecs(); |
|
558 EUNIT_ASSERT_EQUALS( videoCodecs3.Count(), 1 ) |
|
559 EUNIT_ASSERT( videoCodecs3[0]->SdpName().FindF( KMceSDPNameH264() ) >= 0 ) |
|
560 EUNIT_ASSERT( audioStream->Codecs().Count() == 1 ) |
|
561 EUNIT_ASSERT( audioStream->Codecs()[0]->AllowedBitrates() == |
|
562 KMceAllowedAmrNbBitrate475 ) |
|
563 } |
|
564 |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 // ----------------------------------------------------------------------------- |
|
568 // |
|
569 void UT_CMusEngClipSession::UT_TranscodeLToH263L() |
|
570 { |
|
571 // Check that transcoding is not possible before invite |
|
572 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
573 iClipSession->TranscodeL( KTestVideoFileName() ), |
|
574 KErrNotReady ) |
|
575 |
|
576 // Construct session with video and audio streams that must transcoded |
|
577 |
|
578 CSIPProfile* profile = iClipSession->iSipProfileHandler->Profile(); |
|
579 |
|
580 iClipSession->iSession = CMceOutSession::NewL( |
|
581 *(iClipSession->iManager), |
|
582 *profile, |
|
583 KTestRecipientSipUri8() ); |
|
584 |
|
585 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
586 |
|
587 CMceRtpSink* rtpsink = CMceRtpSink::NewLC(); |
|
588 videoStream->AddSinkL( rtpsink ); |
|
589 CleanupStack::Pop( rtpsink ); |
|
590 |
|
591 CMceFileSource* fileSource = |
|
592 CMceFileSource::NewLC( *iClipSession->iManager, KTestAvcVideoFileName() ); |
|
593 videoStream->SetSourceL( fileSource ); |
|
594 CleanupStack::Pop( fileSource ); |
|
595 |
|
596 iClipSession->iSession->AddStreamL( videoStream ); |
|
597 CleanupStack::Pop( videoStream ); |
|
598 |
|
599 CMceAudioStream* audioStream = CMceAudioStream::NewLC(); |
|
600 |
|
601 audioStream->AddSinkL( CMceRtpSink::NewLC() ); |
|
602 CleanupStack::Pop(); |
|
603 |
|
604 audioStream->SetSourceL( fileSource ); |
|
605 |
|
606 iClipSession->iSession->AddStreamL( audioStream ); |
|
607 CleanupStack::Pop( audioStream ); |
|
608 |
|
609 videoStream->iState = CMceMediaStream::ETranscodingRequired; |
|
610 audioStream->iState = CMceMediaStream::ETranscodingRequired; |
|
611 |
|
612 const RPointerArray<CMceVideoCodec> videoCodecs = videoStream->Codecs(); |
|
613 EUNIT_ASSERT_EQUALS( videoCodecs.Count(), 1 ) |
|
614 EUNIT_ASSERT( videoCodecs[0]->SdpName().FindF( KMceSDPNameH264() ) >= 0 ) |
|
615 EUNIT_ASSERT( audioStream->Codecs().Count() > 1 ) |
|
616 |
|
617 TSize resolution(200,200); // Some value |
|
618 videoStream->Codecs()[0]->SetResolutionL( resolution ); |
|
619 audioStream->Codecs()[0]->SetBitrate( KMceAllowedAmrNbBitrateAll ); |
|
620 |
|
621 // Add some stream which must not be transcoded |
|
622 |
|
623 CMceAudioStream* inStream = CMceAudioStream::NewLC(); |
|
624 |
|
625 inStream->AddSinkL( CMceSpeakerSink::NewLC() ); |
|
626 CleanupStack::Pop(); |
|
627 |
|
628 inStream->SetSourceL( CMceRtpSource::NewLC() ); |
|
629 CleanupStack::Pop(); |
|
630 |
|
631 iClipSession->iSession->AddStreamL( inStream ); |
|
632 CleanupStack::Pop( inStream ); |
|
633 |
|
634 // Transcode |
|
635 iClipSession->TranscodeL( KTestAvcVideoFileName() ); |
|
636 |
|
637 // Check that transcoding has begun (transcoding to H263 as we don't |
|
638 // know whether other end supports H264) EUNIT_ASSERT( iClipSession->iTranscodingOngoing ) |
|
639 EUNIT_ASSERT( videoStream->State() == CMceMediaStream::ETranscoding ) |
|
640 EUNIT_ASSERT( audioStream->State() == CMceMediaStream::ETranscoding ) |
|
641 EUNIT_ASSERT( inStream->State() != CMceMediaStream::ETranscoding ) |
|
642 |
|
643 // Check that codecs have been replaced |
|
644 const RPointerArray<CMceVideoCodec> videoCodecs2 = videoStream->Codecs(); |
|
645 EUNIT_ASSERT_EQUALS( videoCodecs2.Count(), 1 ) |
|
646 EUNIT_ASSERT( videoCodecs2[0]->SdpName().FindF( KMceSDPNameH263() ) >= 0 ) |
|
647 EUNIT_ASSERT( audioStream->Codecs().Count() == 1 ) |
|
648 |
|
649 EUNIT_ASSERT( videoStream->Codecs()[0]->Resolution() != resolution ) |
|
650 EUNIT_ASSERT( audioStream->Codecs()[0]->AllowedBitrates() == |
|
651 KMceAllowedAmrNbBitrate475 ) |
|
652 } |
|
653 |
|
654 // ----------------------------------------------------------------------------- |
|
655 // |
|
656 // ----------------------------------------------------------------------------- |
|
657 // |
|
658 void UT_CMusEngClipSession::UT_CancelTranscodeLL() |
|
659 { |
|
660 // Check that canceling transcoding is not possible before actual |
|
661 // transcoding |
|
662 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->CancelTranscodeL(), |
|
663 KErrNotReady ) |
|
664 |
|
665 // Construct session structure |
|
666 |
|
667 CSIPProfile* profile = iClipSession->iSipProfileHandler->Profile(); |
|
668 |
|
669 iClipSession->iSession = CMceOutSession::NewL( |
|
670 *(iClipSession->iManager), |
|
671 *profile, |
|
672 KTestRecipientSipUri8() ); |
|
673 |
|
674 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
675 |
|
676 CMceRtpSink* rtpsink = CMceRtpSink::NewLC(); |
|
677 videoStream->AddSinkL( rtpsink ); |
|
678 CleanupStack::Pop( rtpsink ); |
|
679 |
|
680 CMceFileSource* fileSource = |
|
681 CMceFileSource::NewLC( *iClipSession->iManager, KTestVideoFileName() ); |
|
682 videoStream->SetSourceL( fileSource ); |
|
683 CleanupStack::Pop( fileSource ); |
|
684 |
|
685 iClipSession->iSession->AddStreamL( videoStream ); |
|
686 CleanupStack::Pop( videoStream ); |
|
687 |
|
688 CMceAudioStream* audioStream = CMceAudioStream::NewLC(); |
|
689 |
|
690 audioStream->AddSinkL( CMceRtpSink::NewLC() ); |
|
691 CleanupStack::Pop(); |
|
692 |
|
693 audioStream->SetSourceL( fileSource ); |
|
694 |
|
695 iClipSession->iSession->AddStreamL( audioStream ); |
|
696 CleanupStack::Pop( audioStream ); |
|
697 |
|
698 // Set need for transcoding |
|
699 videoStream->iState = CMceMediaStream::ETranscodingRequired; |
|
700 audioStream->iState = CMceMediaStream::ETranscodingRequired; |
|
701 |
|
702 // Transcode |
|
703 iClipSession->TranscodeL( KTestAvcVideoFileName() ); |
|
704 |
|
705 EUNIT_ASSERT( videoStream->State() == CMceMediaStream::ETranscoding ) |
|
706 EUNIT_ASSERT( audioStream->State() == CMceMediaStream::ETranscoding ) |
|
707 |
|
708 // Cancel |
|
709 iClipSession->CancelTranscodeL(); |
|
710 |
|
711 EUNIT_ASSERT( videoStream->State() == |
|
712 CMceMediaStream::ETranscodingRequired ) |
|
713 EUNIT_ASSERT( audioStream->State() == |
|
714 CMceMediaStream::ETranscodingRequired ) |
|
715 } |
|
716 |
|
717 |
|
718 // ----------------------------------------------------------------------------- |
|
719 // |
|
720 // ----------------------------------------------------------------------------- |
|
721 // |
|
722 void UT_CMusEngClipSession::UT_PlayLL() |
|
723 { |
|
724 // Check that resuming is not possible before invite |
|
725 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->PlayL(), KErrNotReady ) |
|
726 |
|
727 ESTABLISH_OUT_SESSION( iClipSession ); |
|
728 |
|
729 // Check that playing is not possible during FFWD |
|
730 iClipSession->iFFWDStartTime = TTime( 10 ); |
|
731 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->PlayL(), KErrNotReady ) |
|
732 iClipSession->iFFWDStartTime = TTime( 0 ); |
|
733 |
|
734 // Check that playing is not possible during FRWD |
|
735 iClipSession->iFRWDStartTime = TTime( 10 ); |
|
736 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->PlayL(), KErrNotReady ) |
|
737 iClipSession->iFRWDStartTime = TTime( 0 ); |
|
738 |
|
739 // Successful case |
|
740 CMceFileSource* file = |
|
741 MusEngMceUtils::GetFileSourceL( *(iClipSession->iSession) ); |
|
742 |
|
743 file->iIsEnabled = EFalse; |
|
744 |
|
745 iClipSession->PlayL(); |
|
746 |
|
747 EUNIT_ASSERT( file->IsEnabled() ) |
|
748 |
|
749 // Try to play again, request should be ignored |
|
750 |
|
751 iClipSession->PlayL(); |
|
752 |
|
753 EUNIT_ASSERT( file->IsEnabled() ) |
|
754 |
|
755 } |
|
756 |
|
757 |
|
758 // ----------------------------------------------------------------------------- |
|
759 // |
|
760 // ----------------------------------------------------------------------------- |
|
761 // |
|
762 void UT_CMusEngClipSession::UT_PauseLL() |
|
763 { |
|
764 // Check that pausing is not possible before invite |
|
765 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->PauseL(), KErrNotReady ) |
|
766 |
|
767 ESTABLISH_OUT_SESSION( iClipSession ); |
|
768 |
|
769 // Check that pausing is not possible during FFWD |
|
770 iClipSession->iFFWDStartTime = TTime( 10 ); |
|
771 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->PauseL(), KErrNotReady ) |
|
772 iClipSession->iFFWDStartTime = TTime( 0 ); |
|
773 |
|
774 // Check that pausing is not possible during FRWD |
|
775 iClipSession->iFRWDStartTime = TTime( 10 ); |
|
776 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->PauseL(), KErrNotReady ) |
|
777 iClipSession->iFRWDStartTime = TTime( 0 ); |
|
778 |
|
779 // Successful case |
|
780 |
|
781 CMceFileSource* file = |
|
782 MusEngMceUtils::GetFileSourceL( *(iClipSession->iSession) ); |
|
783 |
|
784 file->iIsEnabled = ETrue; |
|
785 |
|
786 iClipSession->PauseL(); |
|
787 |
|
788 EUNIT_ASSERT( !file->IsEnabled() ) |
|
789 |
|
790 // Try to pause again, request should be ignored |
|
791 |
|
792 iClipSession->PauseL(); |
|
793 |
|
794 EUNIT_ASSERT( !file->IsEnabled() ) |
|
795 |
|
796 } |
|
797 |
|
798 |
|
799 // ----------------------------------------------------------------------------- |
|
800 // |
|
801 // ----------------------------------------------------------------------------- |
|
802 // |
|
803 void UT_CMusEngClipSession::UT_IsPlayingLL() |
|
804 { |
|
805 // Try without a session |
|
806 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipSession->IsPlayingL(), KErrNotReady ); |
|
807 |
|
808 // Normal cases |
|
809 ESTABLISH_OUT_SESSION( iClipSession ); |
|
810 |
|
811 iClipSession->PlayL(); |
|
812 EUNIT_ASSERT( iClipSession->IsPlayingL() ) |
|
813 |
|
814 iClipSession->PauseL(); |
|
815 EUNIT_ASSERT( !iClipSession->IsPlayingL() ) |
|
816 } |
|
817 |
|
818 |
162 |
819 // ----------------------------------------------------------------------------- |
163 // ----------------------------------------------------------------------------- |
820 // |
164 // |
821 // ----------------------------------------------------------------------------- |
165 // ----------------------------------------------------------------------------- |
822 // |
166 // |
823 void UT_CMusEngClipSession::UT_CompleteSessionStructureLL() |
167 void UT_CMusEngClipSession::UT_CompleteSessionStructureLL() |
824 { |
168 { |
825 |
|
826 CMceStreamBundle* localBundle = |
169 CMceStreamBundle* localBundle = |
827 CMceStreamBundle::NewLC( CMceStreamBundle::ELS ); |
170 CMceStreamBundle::NewLC( CMceStreamBundle::ELS ); |
828 |
171 |
829 // Check that structure cannot be completed before creating the session |
172 // Check that structure cannot be completed before creating the session |
830 EUNIT_ASSERT_SPECIFIC_LEAVE( |
173 EUNIT_ASSERT_SPECIFIC_LEAVE( |
831 iClipSession->CompleteSessionStructureL( *localBundle ), |
174 iClipSession->CompleteSessionStructureL( *localBundle ), |
832 KErrNotReady ) |
175 KErrNotReady ) |
833 |
176 |
834 // Check that structure cannot be completed before setting the file name |
177 // Normal case |
835 iClipSession->iFileName = KNullDesC(); |
178 CSIPProfile* profile = iClipSession->iSipProfileHandler->Profile(); |
836 CSIPProfile* profile = iClipSession->iSipProfileHandler->Profile(); |
|
837 |
|
838 iClipSession->iSession = CMceOutSession::NewL( |
179 iClipSession->iSession = CMceOutSession::NewL( |
839 *(iClipSession->iManager), |
180 *iClipSession->iManager, *profile, KTestRecipientSipUri8() ); |
840 *profile, |
181 |
841 KTestRecipientSipUri8() ); |
|
842 |
|
843 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
844 iClipSession->CompleteSessionStructureL( *localBundle ), |
|
845 KErrNotReady ) |
|
846 |
|
847 // Normal case |
|
848 iClipSession->iFileName = KTestVideoFileName(); |
|
849 iClipSession->CompleteSessionStructureL( *localBundle ); |
182 iClipSession->CompleteSessionStructureL( *localBundle ); |
850 |
|
851 EUNIT_ASSERT( iClipSession->iSession->Streams().Count() == 3 ) |
183 EUNIT_ASSERT( iClipSession->iSession->Streams().Count() == 3 ) |
852 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Type() == KMceVideo ) |
184 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Type() == KMceVideo ) |
853 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Source() ) |
185 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Source() ) |
854 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Source()->Type() == |
186 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Source()->Type() == |
855 KMceFileSource ) |
187 KMceFileSource ) |
856 EUNIT_ASSERT( !iClipSession->IsPlayingL() ) |
|
857 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Sinks().Count() == 1 ) |
188 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Sinks().Count() == 1 ) |
858 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Sinks()[0]->Type() == |
189 EUNIT_ASSERT( iClipSession->iSession->Streams()[0]->Sinks()[0]->Type() == |
859 KMceRTPSink ) |
190 KMceRTPSink ) |
860 |
191 |
861 // Check that only stream with speaker has been added to a bundle |
192 // Check that only stream with speaker has been added to a bundle |
960 *rtpSource ); |
292 *rtpSource ); |
961 CleanupStack::PopAndDestroy( rtpSource ); |
293 CleanupStack::PopAndDestroy( rtpSource ); |
962 CleanupStack::PopAndDestroy( videoStream ); |
294 CleanupStack::PopAndDestroy( videoStream ); |
963 |
295 |
964 // Simulate sending invite |
296 // Simulate sending invite |
965 iClipSession->InviteL( KTestRecipientSipUri() ); |
297 iClipSession->EstablishLcSessionL(); |
966 |
298 |
967 // Try all the non-default stream states |
299 // Try all the non-default stream states |
968 CMceMediaStream* changedStream = iClipSession->iSession->Streams()[0]; |
300 CMceMediaStream* changedStream = iClipSession->iSession->Streams()[0]; |
969 CMceMediaSource* changedSource = changedStream->Source(); |
301 CMceMediaSource* changedSource = changedStream->Source(); |
970 |
302 |
971 // EDisabled, end of clip |
303 // EDisabled, end of clip |
972 changedStream->iState = CMceMediaStream::EDisabled; |
304 changedStream->iState = CMceMediaStream::EDisabled; |
973 changedSource->iIsEnabled = EFalse; |
305 changedSource->iIsEnabled = EFalse; |
974 iClipSession->StreamStateChanged( *changedStream, *changedSource ); |
306 iClipSession->StreamStateChanged( *changedStream, *changedSource ); |
975 |
307 |
976 EUNIT_ASSERT( iObserver->iEndOfClipCalled == ETrue ) |
308 // TODO: EUNIT_ASSERT( iLcSessionObserver->iEndOfClipCalled ) |
977 changedSource->iIsEnabled = ETrue; |
309 changedSource->iIsEnabled = ETrue; |
978 iObserver->Reset(); |
310 iLcSessionObserver->Reset(); |
979 |
|
980 // ETranscodingRequired, transcoding has failed |
|
981 iClipSession->iSession->iState = CMceSession::EIdle; |
|
982 iClipSession->iTranscodingOngoing = ETrue; |
|
983 changedStream->iState = CMceMediaStream::ETranscodingRequired; |
|
984 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
985 *changedStream, *changedSource ); |
|
986 EUNIT_ASSERT( iObserver->iTranscodingFailedCalled ) |
|
987 EUNIT_ASSERT( !iClipSession->iTranscodingOngoing ) |
|
988 iObserver->Reset(); |
|
989 |
|
990 // ETranscoding, transcoding has progresssed |
|
991 iClipSession->iSession->iState = CMceSession::EIdle; |
|
992 changedStream->iState = CMceMediaStream::ETranscoding; |
|
993 static_cast<CMceFileSource*>(changedSource)->iTranscodingPercentage = 20; |
|
994 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
995 *changedStream, *changedSource ); |
|
996 EUNIT_ASSERT( iObserver->iTranscodingProgressedPercentage == 20 ) |
|
997 iObserver->Reset(); |
|
998 |
|
999 // ETranscoding, transcoding has progresssed, querying percentage fails |
|
1000 iClipSession->iSession->iState = CMceSession::EIdle; |
|
1001 changedStream->iState = CMceMediaStream::ETranscoding; |
|
1002 iObserver->iTranscodingProgressedPercentage = -1; // make assertion possible |
|
1003 static_cast<CMceFileSource*>(changedSource)->iFailWithCode = KErrNotReady; |
|
1004 static_cast<CMceFileSource*>(changedSource)->iTranscodingPercentage = 30; |
|
1005 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
1006 *changedStream, *changedSource ); |
|
1007 EUNIT_ASSERT( iObserver->iTranscodingProgressedPercentage == 0 ) |
|
1008 iObserver->Reset(); |
|
1009 |
|
1010 // EInitialized, transcoding has completed, establishment fails |
|
1011 iClipSession->iSession->iState = CMceSession::EIdle; |
|
1012 iClipSession->iSession->iFailWithCode = KErrCorrupt; // != KErrNone |
|
1013 iClipSession->iTranscodingOngoing = ETrue; |
|
1014 changedStream->iState = CMceMediaStream::EInitialized; |
|
1015 static_cast<CMceFileSource*>(changedSource)->iTranscodingPercentage = 100; |
|
1016 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
1017 *changedStream, *changedSource ); |
|
1018 EUNIT_ASSERT( iObserver->iTranscodingCompletedInitCalled ) |
|
1019 EUNIT_ASSERT( iObserver->iTranscodingCompletedFinalizeCalled ) |
|
1020 EUNIT_ASSERT( iObserver->iSessionFailedCalled ) |
|
1021 EUNIT_ASSERT( !iClipSession->iTranscodingOngoing ) |
|
1022 iObserver->Reset(); |
|
1023 |
|
1024 // EInitialized, transcoding has completed, establishment succeeds |
|
1025 iClipSession->iSession->iState = CMceSession::EIdle; |
|
1026 iClipSession->iTranscodingOngoing = ETrue; |
|
1027 changedStream->iState = CMceMediaStream::EInitialized; |
|
1028 static_cast<CMceFileSource*>(changedSource)->iTranscodingPercentage = 100; |
|
1029 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
|
1030 *changedStream, *changedSource ); |
|
1031 EUNIT_ASSERT( iObserver->iTranscodingCompletedInitCalled ) |
|
1032 EUNIT_ASSERT( iObserver->iTranscodingCompletedFinalizeCalled ) |
|
1033 // Next cannot be asserted since it is not true with alloc decoration |
|
1034 // EUNIT_ASSERT( !iObserver->iSessionFailedCalled ) |
|
1035 EUNIT_ASSERT( !iClipSession->iTranscodingOngoing ) |
|
1036 iObserver->Reset(); |
|
1037 |
|
1038 |
311 |
1039 // Test default stream state change behavior, remove or change when |
312 // Test default stream state change behavior, remove or change when |
1040 // behavior changes |
313 // behavior changes |
1041 |
314 |
1042 |
315 |
1043 // EUninitialized, stream is created, unexpected change, nothing happens |
316 // EUninitialized, stream is created, unexpected change, nothing happens |
1044 changedStream->iState = CMceMediaStream::EUninitialized; |
317 changedStream->iState = CMceMediaStream::EUninitialized; |
1045 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
318 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
1046 *changedStream, *changedSource ); |
319 *changedStream, *changedSource ); |
1047 EUNIT_ASSERT( iObserver->IsReseted() ) |
320 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
1048 |
321 |
1049 // EInitialized, stream is initialized |
322 // EInitialized, stream is initialized |
1050 changedStream->iState = CMceMediaStream::EInitialized; |
323 changedStream->iState = CMceMediaStream::EInitialized; |
1051 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
324 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
1052 *changedStream, *changedSource ); |
325 *changedStream, *changedSource ); |
1053 EUNIT_ASSERT( iObserver->IsReseted() ) |
326 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
1054 |
327 |
1055 // Special meaning (Transcoding ready), tested separately |
328 // Special meaning (Transcoding ready), tested separately |
1056 |
329 |
1057 // EBuffering, stream is buffering |
330 // EBuffering, stream is buffering |
1058 changedStream->iState = CMceMediaStream::EBuffering; |
331 changedStream->iState = CMceMediaStream::EBuffering; |
1059 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
332 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
1060 *changedStream, *changedSource ); |
333 *changedStream, *changedSource ); |
1061 EUNIT_ASSERT( iObserver->IsReseted() ) |
334 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
1062 |
335 |
1063 // EIdle, stream is not receiving RTP |
336 // EIdle, stream is not receiving RTP |
1064 changedStream->iState = CMceMediaStream::EIdle; |
337 changedStream->iState = CMceMediaStream::EIdle; |
1065 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
338 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
1066 *changedStream, *changedSource ); |
339 *changedStream, *changedSource ); |
1067 EUNIT_ASSERT( iObserver->iStreamIdleCalled ) |
340 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
1068 |
341 |
1069 // EStreaming, stream is streaming |
342 // EStreaming, stream is streaming |
1070 changedStream->iState = CMceMediaStream::EStreaming; |
343 changedStream->iState = CMceMediaStream::EStreaming; |
1071 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
344 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
1072 *changedStream, *changedSource ); |
345 *changedStream, *changedSource ); |
1073 EUNIT_ASSERT( iObserver->iStreamStreamingCalled ) |
346 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
1074 iObserver->Reset(); |
347 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
348 iLcSessionObserver->Reset(); |
1075 |
349 |
1076 // EDisabled, stream is explicitly disabled |
350 // EDisabled, stream is explicitly disabled |
1077 // This state has non-default meaning, tested before defaults |
351 // This state has non-default meaning, tested before defaults |
1078 |
352 |
1079 // ENoResources, stream has no needed resources to stream |
353 // ENoResources, stream has no needed resources to stream |
1080 changedStream->iState = CMceMediaStream::ENoResources; |
354 changedStream->iState = CMceMediaStream::ENoResources; |
1081 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
355 static_cast<MMceStreamObserver*>(iClipSession)->StreamStateChanged( |
1082 *changedStream, *changedSource ); |
356 *changedStream, *changedSource ); |
1083 EUNIT_ASSERT( iObserver->IsReseted() ) |
357 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
1084 |
|
1085 |
|
1086 } |
358 } |
1087 |
359 |
1088 |
360 |
1089 // ----------------------------------------------------------------------------- |
361 // ----------------------------------------------------------------------------- |
1090 // Although all states are not meaningfull for LiveSession, all states are |
362 // Although all states are not meaningfull for LiveSession, all states are |
1451 EUNIT_ASSERT_EQUALS( codecs.Count(), 1 ) |
666 EUNIT_ASSERT_EQUALS( codecs.Count(), 1 ) |
1452 EUNIT_ASSERT( codecs[0]->SdpName().FindF( KMceSDPNameH264() ) >= 0 ) |
667 EUNIT_ASSERT( codecs[0]->SdpName().FindF( KMceSDPNameH264() ) >= 0 ) |
1453 |
668 |
1454 } |
669 } |
1455 } |
670 } |
1456 |
|
1457 EUNIT_ASSERT( !iObserver->iTranscodingNeededCalled ) |
|
1458 EUNIT_ASSERT( !iClipSession->iTranscodingRequiredDueMissingOptions ) |
|
1459 |
671 |
1460 /////// |
672 /////// |
1461 // 2.Test the case when we don't know whether peer supports H264, |
673 // 2.Test the case when we don't know whether peer supports H264, |
1462 // transcoding is needed, H264 codec has to be removed from the codec list |
674 // transcoding is needed => function will leave with KErrNotSupported |
1463 |
675 |
1464 delete iClipSession->iSession; |
676 delete iClipSession->iSession; |
1465 iClipSession->iSession = NULL; |
677 iClipSession->iSession = NULL; |
1466 |
678 |
1467 delete iClipSession->iVideoCodecList; |
679 delete iClipSession->iVideoCodecList; |
1468 iClipSession->iVideoCodecList = NULL; |
680 iClipSession->iVideoCodecList = NULL; |
1469 |
681 |
1470 // Call to CMusEngOutMceSession::InviteL leads to call to EstablishL |
682 MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( |
1471 iClipSession->InviteL( KTestRecipientSipUri ); |
683 iClipSession->EstablishLcSessionL(), |
1472 |
684 KErrNotSupported ) |
1473 const RPointerArray<CMceMediaStream>& streams2 = iClipSession->iSession->Streams(); |
685 |
1474 |
|
1475 for ( TInt i = 0; i < streams2.Count(); ++i ) |
|
1476 { |
|
1477 if ( streams2[i]->Type() == KMceVideo ) |
|
1478 { |
|
1479 CMceVideoStream* videoStream = static_cast<CMceVideoStream*>( streams2[i] ); |
|
1480 const RPointerArray<CMceVideoCodec> codecs = videoStream->Codecs(); |
|
1481 EUNIT_ASSERT_EQUALS( codecs.Count(), 1 ) |
|
1482 EUNIT_ASSERT( codecs[0]->SdpName().FindF( KMceSDPNameH263() ) >= 0 ) |
|
1483 } |
|
1484 } |
|
1485 |
|
1486 EUNIT_ASSERT( iObserver->iTranscodingNeededCalled ) |
|
1487 EUNIT_ASSERT( iObserver->iDueUnknowCapas ) |
|
1488 EUNIT_ASSERT( iClipSession->iTranscodingRequiredDueMissingOptions ) |
|
1489 |
686 |
1490 /////// |
687 /////// |
1491 // 3. Establish behaves differently at second round in case clip is AVC |
688 // 3.Test that if peer doesn't supports H264, transcoding is needed |
1492 // and because remote party's capabilities were unknown. Use-case is such |
689 // => function will leave with KErrNotSupported |
1493 // that AVC is tried to be transcoded first but if it fails, invite is retried |
|
1494 // by using AVC |
|
1495 iObserver->Reset(); |
|
1496 iClipSession->InviteL( KTestRecipientSipUri ); |
|
1497 const RPointerArray<CMceMediaStream>& testStreams = iClipSession->iSession->Streams(); |
|
1498 |
|
1499 for ( TInt i = 0; i < testStreams.Count(); ++i ) |
|
1500 { |
|
1501 if ( testStreams[i]->Type() == KMceVideo ) |
|
1502 { |
|
1503 CMceVideoStream* videoStream = static_cast<CMceVideoStream*>( testStreams[i] ); |
|
1504 const RPointerArray<CMceVideoCodec> codecs = videoStream->Codecs(); |
|
1505 EUNIT_ASSERT_EQUALS( codecs.Count(), 1 ) |
|
1506 EUNIT_ASSERT( codecs[0]->SdpName().FindF( KMceSDPNameH264() ) >= 0 ) |
|
1507 } |
|
1508 } |
|
1509 |
|
1510 EUNIT_ASSERT( !iObserver->iTranscodingNeededCalled ) |
|
1511 EUNIT_ASSERT( !iObserver->iDueUnknowCapas ) |
|
1512 |
|
1513 /////// |
|
1514 // 4.Test that if peer doesn't supports H264, transcoding is needed |
|
1515 // H264 codec has to be removed from the codec list |
|
1516 |
|
1517 iObserver->iTranscodingNeededCalled = EFalse; |
|
1518 |
690 |
1519 delete iClipSession->iSession; |
691 delete iClipSession->iSession; |
1520 iClipSession->iSession = NULL; |
692 iClipSession->iSession = NULL; |
1521 |
693 |
1522 iClipSession->iVideoCodecList = KMceSDPNameH263().AllocL(); |
694 iClipSession->iVideoCodecList = KMceSDPNameH263().AllocL(); |
1523 |
695 |
1524 // Call to CMusEngOutMceSession::InviteL leads to call to EstablishL |
696 MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( |
1525 iClipSession->InviteL( KTestRecipientSipUri ); |
697 iClipSession->EstablishLcSessionL(), |
1526 |
698 KErrNotSupported ) |
1527 const RPointerArray<CMceMediaStream>& streams3 = iClipSession->iSession->Streams(); |
699 } |
1528 |
700 |
1529 for ( TInt i = 0; i < streams3.Count(); ++i ) |
|
1530 { |
|
1531 if ( streams3[i]->Type() == KMceVideo ) |
|
1532 { |
|
1533 CMceVideoStream* videoStream = static_cast<CMceVideoStream*>( streams3[i] ); |
|
1534 const RPointerArray<CMceVideoCodec> codecs = videoStream->Codecs(); |
|
1535 EUNIT_ASSERT_EQUALS( codecs.Count(), 1 ) |
|
1536 EUNIT_ASSERT( codecs[0]->SdpName().FindF( KMceSDPNameH263() ) >= 0 ) |
|
1537 } |
|
1538 } |
|
1539 |
|
1540 EUNIT_ASSERT( iObserver->iTranscodingNeededCalled ) |
|
1541 EUNIT_ASSERT( !iObserver->iDueUnknowCapas ) |
|
1542 |
|
1543 } |
|
1544 |
|
1545 void UT_CMusEngClipSession::UT_IsRewindFromEndL() |
|
1546 { |
|
1547 // Try before establishing the session |
|
1548 EUNIT_ASSERT( !iClipSession->IsRewindFromEnd() ) |
|
1549 |
|
1550 // Try with session, but without video out stream |
|
1551 |
|
1552 CSIPProfile* profile = iClipSession->iSipProfileHandler->Profile(); |
|
1553 |
|
1554 iClipSession->iSession = CMceOutSession::NewL( |
|
1555 *(iClipSession->iManager), |
|
1556 *profile, |
|
1557 KTestRecipientSipUri8() ); |
|
1558 |
|
1559 EUNIT_ASSERT( !iClipSession->IsRewindFromEnd() ) |
|
1560 |
|
1561 // Try with video out stream without source... |
|
1562 CMceVideoStream* videoOut = CMceVideoStream::NewLC(); |
|
1563 |
|
1564 videoOut->AddSinkL( CMceRtpSink::NewLC() ); |
|
1565 CleanupStack::Pop(); |
|
1566 |
|
1567 iClipSession->iSession->AddStreamL( videoOut ); |
|
1568 CleanupStack::Pop( videoOut ); |
|
1569 |
|
1570 EUNIT_ASSERT( !iClipSession->IsRewindFromEnd() ) |
|
1571 |
|
1572 // And with enabled source and stream |
|
1573 videoOut->SetSourceL( CMceFileSource::NewLC( *iClipSession->iManager, |
|
1574 iClipSession->iFileName ) ); |
|
1575 CleanupStack::Pop(); |
|
1576 |
|
1577 EUNIT_ASSERT( !iClipSession->IsRewindFromEnd() ) |
|
1578 |
|
1579 // try with different position and duration |
|
1580 (static_cast<CMceFileSource*> (videoOut->Source()))->iPosition = 90; |
|
1581 (static_cast<CMceFileSource*> (videoOut->Source()))->iDuration = 111; |
|
1582 EUNIT_ASSERT( !iClipSession->IsRewindFromEnd() ) |
|
1583 |
|
1584 // Disapling source |
|
1585 (static_cast<CMceFileSource*> (videoOut->Source()))->DisableL(); |
|
1586 EUNIT_ASSERT( !iClipSession->IsRewindFromEnd() ) |
|
1587 |
|
1588 // Disapling stream |
|
1589 videoOut->iState = CMceMediaStream::EDisabled; |
|
1590 EUNIT_ASSERT( iClipSession->IsRewindFromEnd() ) |
|
1591 |
|
1592 iClipSession->iPause = ETrue; |
|
1593 EUNIT_ASSERT( !iClipSession->IsRewindFromEnd() ) |
|
1594 |
|
1595 iClipSession->iPause = EFalse; |
|
1596 EUNIT_ASSERT( iClipSession->IsRewindFromEnd() ) |
|
1597 |
|
1598 // and finaly try with "real" end of clip |
|
1599 (static_cast<CMceFileSource*> (videoOut->Source()))->iPosition = 0; |
|
1600 (static_cast<CMceFileSource*> (videoOut->Source()))->iDuration = 111; |
|
1601 |
|
1602 EUNIT_ASSERT( !iClipSession->IsRewindFromEnd() ) |
|
1603 } |
|
1604 |
701 |
1605 // TEST TABLE |
702 // TEST TABLE |
1606 |
703 |
1607 EUNIT_BEGIN_TEST_TABLE( |
704 EUNIT_BEGIN_TEST_TABLE( |
1608 UT_CMusEngClipSession, |
705 UT_CMusEngClipSession, |