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