34 #include <srtpcryptocontext.h> |
34 #include <srtpcryptocontext.h> |
35 #include <srtpmastersalt.h> |
35 #include <srtpmastersalt.h> |
36 #include <srtpstreamin.h> |
36 #include <srtpstreamin.h> |
37 #include "UT_CMccRtpInterface.h" |
37 #include "UT_CMccRtpInterface.h" |
38 #include "mccunittestmacros.h" |
38 #include "mccunittestmacros.h" |
39 #include "mccrtpmediaclock.h" |
|
40 |
39 |
41 // CONSTANTS |
40 // CONSTANTS |
42 _LIT8(KRFC3711_TestMasterKey128bits, "E1F97A0D3E018BE0D64FA32C06DE4139"); |
41 _LIT8(KRFC3711_TestMasterKey128bits, "E1F97A0D3E018BE0D64FA32C06DE4139"); |
43 _LIT8(KRFC3711_TestMasterSalt112bits, "0EC675AD498AFEEBB6960B3AABE6"); |
42 _LIT8(KRFC3711_TestMasterSalt112bits, "0EC675AD498AFEEBB6960B3AABE6"); |
44 _LIT8(KTestMKI128Bits, "ABCDEF1234567890ABCDEF1234567890"); |
43 _LIT8(KTestMKI128Bits, "ABCDEF1234567890ABCDEF1234567890"); |
102 TRtpId rtpSessionId(0); |
101 TRtpId rtpSessionId(0); |
103 iRtpKeepaliveMechanism = |
102 iRtpKeepaliveMechanism = |
104 CMccRtpKeepaliveContainer::NewL( *eventHandler, |
103 CMccRtpKeepaliveContainer::NewL( *eventHandler, |
105 *iRtpApi, |
104 *iRtpApi, |
106 rtpSessionId ); |
105 rtpSessionId ); |
107 |
106 |
108 iRtpMediaClock = CMccRtpMediaClock::NewL(); |
|
109 } |
107 } |
110 |
108 |
111 void UT_CMccRtpDataSource::Teardown() |
109 void UT_CMccRtpDataSource::Teardown() |
112 { |
110 { |
113 delete iRtpKeepaliveMechanism; |
111 delete iRtpKeepaliveMechanism; |
171 cInfo.iType = KUidMediaTypeAudio; |
163 cInfo.iType = KUidMediaTypeAudio; |
172 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
164 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
173 cInfo.iBitrate = 8000; |
165 cInfo.iBitrate = 8000; |
174 cInfo.iPayloadType = KDefaultAmrNbPT; |
166 cInfo.iPayloadType = KDefaultAmrNbPT; |
175 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
167 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
176 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf, iRtpMediaClock ) ); |
168 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf ) ); |
177 } |
169 } |
178 |
170 |
179 // TEST FUNCTIONS |
171 // TEST FUNCTIONS |
180 |
172 |
181 void UT_CMccRtpDataSource::UT_CMccRtpDataSource_RtpPacketReceivedL() |
173 void UT_CMccRtpDataSource::UT_CMccRtpDataSource_RtpPacketReceivedL() |
215 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
207 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
216 cInfo.iBitrate = 8000; |
208 cInfo.iBitrate = 8000; |
217 cInfo.iPayloadType = KDefaultAmrNbPT; |
209 cInfo.iPayloadType = KDefaultAmrNbPT; |
218 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
210 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
219 |
211 |
220 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf, iRtpMediaClock ) ); |
212 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf ) ); |
221 //iSource->NegotiateSourceL( *iEventHandler ); |
213 //iSource->NegotiateSourceL( *iEventHandler ); |
222 EUNIT_ASSERT_NO_LEAVE( iSource->NegotiateSourceL( *amrPfRead ) ); |
214 EUNIT_ASSERT_NO_LEAVE( iSource->NegotiateSourceL( *amrPfRead ) ); |
223 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePrimeL() ); |
215 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePrimeL() ); |
224 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePlayL() ); |
216 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePlayL() ); |
225 |
217 |
381 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
373 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
382 cInfo.iBitrate = 8000; |
374 cInfo.iBitrate = 8000; |
383 cInfo.iPayloadType = KDefaultAmrNbPT; |
375 cInfo.iPayloadType = KDefaultAmrNbPT; |
384 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
376 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
385 |
377 |
386 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf, iRtpMediaClock ) ); |
378 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf ) ); |
387 |
379 |
388 MCC_EUNIT_ASSERT_EQUALS( iSource->SourceThreadLogon( *iEventHandler ), KErrNone ); |
380 MCC_EUNIT_ASSERT_EQUALS( iSource->SourceThreadLogon( *iEventHandler ), KErrNone ); |
389 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePrimeL() ); |
381 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePrimeL() ); |
390 |
382 |
391 iSource->SourceThreadLogoff(); |
383 iSource->SourceThreadLogoff(); |
406 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
398 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
407 cInfo.iBitrate = 8000; |
399 cInfo.iBitrate = 8000; |
408 cInfo.iPayloadType = KDefaultAmrNbPT; |
400 cInfo.iPayloadType = KDefaultAmrNbPT; |
409 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
401 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
410 |
402 |
411 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf, iRtpMediaClock ) ); |
403 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf ) ); |
412 |
404 |
413 MCC_EUNIT_ASSERT_EQUALS( iSource->SourceThreadLogon( *iEventHandler ), KErrNone ); |
405 MCC_EUNIT_ASSERT_EQUALS( iSource->SourceThreadLogon( *iEventHandler ), KErrNone ); |
414 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePrimeL() ); |
406 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePrimeL() ); |
415 |
407 |
416 iSource->SourceThreadLogoff(); |
408 iSource->SourceThreadLogoff(); |
527 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
519 cInfo.iFourCC = TFourCC( ' ','A','M','R' ); |
528 cInfo.iBitrate = 8000; |
520 cInfo.iBitrate = 8000; |
529 cInfo.iPayloadType = KDefaultAmrNbPT; |
521 cInfo.iPayloadType = KDefaultAmrNbPT; |
530 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
522 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
531 |
523 |
532 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf, iRtpMediaClock ) ); |
524 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf ) ); |
533 MCC_EUNIT_ASSERT_EQUALS( iSource->SourceThreadLogon( *iEventHandler ), KErrNone ); |
525 MCC_EUNIT_ASSERT_EQUALS( iSource->SourceThreadLogon( *iEventHandler ), KErrNone ); |
534 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePrimeL() ); |
526 EUNIT_ASSERT_NO_LEAVE( iSource->SourcePrimeL() ); |
535 |
527 |
536 EUNIT_ASSERT_NO_LEAVE( iSource->NegotiateSourceL( *this ) ); |
528 EUNIT_ASSERT_NO_LEAVE( iSource->NegotiateSourceL( *this ) ); |
537 iSource->SourceThreadLogoff(); |
529 iSource->SourceThreadLogoff(); |
613 |
605 |
614 TMccCodecInfo cInfo; |
606 TMccCodecInfo cInfo; |
615 cInfo.iFourCC = TFourCC( KMccFourCCIdG711 ); |
607 cInfo.iFourCC = TFourCC( KMccFourCCIdG711 ); |
616 cInfo.iEnableDTX = ETrue; |
608 cInfo.iEnableDTX = ETrue; |
617 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
609 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
618 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf, iRtpMediaClock ) ); |
610 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf ) ); |
619 |
611 |
620 header.iPayloadType = KPcmuPayloadType; |
612 header.iPayloadType = KPcmuPayloadType; |
621 |
613 |
622 // Data ok, stream ok, payload type ok |
614 // Data ok, stream ok, payload type ok |
623 CAmrPayloadFormatRead* amrPfRead = CAmrPayloadFormatRead::NewL( NULL ); |
615 CAmrPayloadFormatRead* amrPfRead = CAmrPayloadFormatRead::NewL( NULL ); |
645 EUNIT_ASSERT_NO_LEAVE( iSource->SetSessionParamsL( params ) ); |
637 EUNIT_ASSERT_NO_LEAVE( iSource->SetSessionParamsL( params ) ); |
646 |
638 |
647 TMccCodecInfo cInfo; |
639 TMccCodecInfo cInfo; |
648 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
640 TMccCodecInfoBuffer cInfoBuf( cInfo ); |
649 |
641 |
650 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf, iRtpMediaClock ) ); |
642 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf ) ); |
651 |
643 |
652 // Get a new Source |
644 // Get a new Source |
653 Teardown(); |
645 Teardown(); |
654 SetupL(); |
646 SetupL(); |
655 |
647 |
656 // This should leave because the string is too short |
648 // This should leave because the string is too short |
657 TBuf8<5> dummy; |
649 TBuf8<5> dummy; |
658 dummy.Format( _L8( "foo42" ) ); |
650 dummy.Format( _L8( "foo42" ) ); |
659 EUNIT_ASSERT_NO_LEAVE( iSource->SetSessionParamsL( params ) ); |
651 EUNIT_ASSERT_NO_LEAVE( iSource->SetSessionParamsL( params ) ); |
660 EUNIT_ASSERT_LEAVE( iSource->ConfigureL( dummy, iRtpMediaClock ) ); |
652 EUNIT_ASSERT_LEAVE( iSource->ConfigureL( dummy ) ); |
661 |
653 |
662 // Get a new Source |
654 // Get a new Source |
663 Teardown(); |
655 Teardown(); |
664 SetupL(); |
656 SetupL(); |
665 |
657 |
676 cInfo2.iRedundantPayload = 97; |
668 cInfo2.iRedundantPayload = 97; |
677 cInfo2.iRedundancyCount = 1; |
669 cInfo2.iRedundancyCount = 1; |
678 cInfo2.iAlgoUsed = EGenRedUsed; |
670 cInfo2.iAlgoUsed = EGenRedUsed; |
679 TMccCodecInfoBuffer cInfoBuf2( cInfo2 ); |
671 TMccCodecInfoBuffer cInfoBuf2( cInfo2 ); |
680 |
672 |
681 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf2, iRtpMediaClock ) ); |
673 EUNIT_ASSERT_NO_LEAVE( iSource->ConfigureL( cInfoBuf2 ) ); |
682 } |
674 } |
683 |
675 |
684 void UT_CMccRtpDataSource::UT_CMccRtpDataSource_DoCreateSrtpStreamL() |
676 void UT_CMccRtpDataSource::UT_CMccRtpDataSource_DoCreateSrtpStreamL() |
685 { |
677 { |
686 // Rtp stream not created |
678 // Rtp stream not created |
707 iSource->iEventHandler = NULL; |
699 iSource->iEventHandler = NULL; |
708 iSource->SendStreamEventToClient( KMccStreamStopped, KErrNone, KMccPTNotDefined ); |
700 iSource->SendStreamEventToClient( KMccStreamStopped, KErrNone, KMccPTNotDefined ); |
709 EUNIT_ASSERT_EQUALS( iEventHandler->iLastEvent.iEventType, KMccStreamResumed ); |
701 EUNIT_ASSERT_EQUALS( iEventHandler->iLastEvent.iEventType, KMccStreamResumed ); |
710 |
702 |
711 // Jitter event when no event handler |
703 // Jitter event when no event handler |
712 TMccRtpEventDataExtended eventData; |
704 TMccRtpEventData eventData; |
713 iSource->SendJitterEvent( eventData, KErrNone ); |
705 iSource->SendJitterEvent( eventData, KErrNone ); |
714 EUNIT_ASSERT_EQUALS( iEventHandler->iLastEvent.iEventType, KMccStreamResumed ); |
706 EUNIT_ASSERT_EQUALS( iEventHandler->iLastEvent.iEventType, KMccStreamResumed ); |
715 |
707 |
716 // Event handler exists |
708 // Event handler exists |
717 iSource->iEventHandler = iEventHandler; |
709 iSource->iEventHandler = iEventHandler; |
785 iSource->SendSecureRtpEventToClient( |
777 iSource->SendSecureRtpEventToClient( |
786 NULL, KMccRtpSourceUid, EMccInternalEventNone, KMccStreamPaused, 0 ); |
778 NULL, KMccRtpSourceUid, EMccInternalEventNone, KMccStreamPaused, 0 ); |
787 iSource->SendSecureRtpEventToClient( |
779 iSource->SendSecureRtpEventToClient( |
788 iEventHandler, KMccRtpSourceUid, EMccInternalEventNone, KMccStreamPaused, 0 ); |
780 iEventHandler, KMccRtpSourceUid, EMccInternalEventNone, KMccStreamPaused, 0 ); |
789 EUNIT_ASSERT_EQUALS( iEventHandler->iLastEvent.iEventType, KMccStreamPaused ); |
781 EUNIT_ASSERT_EQUALS( iEventHandler->iLastEvent.iEventType, KMccStreamPaused ); |
790 |
|
791 // SendJitterEventToClient() |
|
792 iSource->SendJitterEventToClient( iEventHandler, KMccRtpSourceUid, |
|
793 EMccInternalEventNone, KMccEventNone, 0, 0, 1,2,3,4,5,6 ); |
|
794 EUNIT_ASSERT_EQUALS( iEventHandler->iLastEvent.iEventType, KMccEventNone ); |
|
795 const TMccRtpEventDataExtended& rtpEvent = |
|
796 (*reinterpret_cast<const TMccRtpEventDataExtendedPackage*>( &iEventHandler->iLastEvent.iEventData ))(); |
|
797 EUNIT_ASSERT_EQUALS( rtpEvent.iJitterEstimate, 1 ); |
|
798 EUNIT_ASSERT_EQUALS( rtpEvent.iPacketsReceived, 2 ); |
|
799 EUNIT_ASSERT_EQUALS( rtpEvent.iPrevTransTime, 3 ); |
|
800 EUNIT_ASSERT_EQUALS( rtpEvent.iTriggeredJitterLevel, 4 ); |
|
801 EUNIT_ASSERT_EQUALS( rtpEvent.iPacketLoss, 5 ); |
|
802 EUNIT_ASSERT_EQUALS( rtpEvent.iTriggeredPacketLoss, 6 ); |
|
803 } |
782 } |
804 |
783 |
805 void UT_CMccRtpDataSource::UT_CMccRtpDataSource_DoStandbyDecisionL() |
784 void UT_CMccRtpDataSource::UT_CMccRtpDataSource_DoStandbyDecisionL() |
806 { |
785 { |
807 // Standby not enabled |
786 // Standby not enabled |